Skip to content

Commit 7a11c6a

Browse files
authored
Merge pull request #527 from strapi/1.0.0
1.0.0
2 parents b0f4351 + ca2725d commit 7a11c6a

File tree

249 files changed

+39722
-29637
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+39722
-29637
lines changed

.github/workflows/playwright-ci.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Playwright tests
22
on:
33
pull_request:
4-
branches: ["main"]
4+
branches: "*"
55
workflow_dispatch:
66

77
jobs:
@@ -32,6 +32,9 @@ jobs:
3232
- name: Install yarn dependencies
3333
run: yarn global add http-server && yarn
3434

35+
- name: Install Playwright
36+
run: npx playwright install --with-deps
37+
3538
- name: Link locale packages and install their dependencies
3639
run: yarn bootstrap
3740

.specifyrc.json

+50-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
]
3535
},
3636
{
37-
"name": "Design Tokens / colors",
38-
"path": "packages/strapi-design-system/src/themes/colors.js",
37+
"name": "Design Tokens / light colors",
38+
"path": "packages/strapi-design-system/src/themes/lightTheme/light-colors.js",
3939
"filter": {
4040
"types": ["color"]
4141
},
@@ -71,7 +71,54 @@
7171
"shadowFormat": "string"
7272
},
7373
"formatConfig": {
74-
"jssObjectName": "colorTokenObject",
74+
"jssObjectName": "lightColorTokenObject",
75+
"exportDefault": false,
76+
"tabWidth": 2,
77+
"singleQuote": true
78+
}
79+
}
80+
}
81+
]
82+
},
83+
{
84+
"name": "Design Tokens / dark colors",
85+
"path": "packages/strapi-design-system/src/themes/darkTheme/dark-colors.js",
86+
"filter": {
87+
"types": ["color"]
88+
},
89+
"parsers": [
90+
{
91+
"name": "filter",
92+
"options": {
93+
"key": "name",
94+
"regex": {
95+
"pattern": "Dark mode/",
96+
"flags": "g"
97+
}
98+
}
99+
},
100+
{
101+
"name": "replace-string",
102+
"options": {
103+
"keys": ["name"],
104+
"regex": {
105+
"pattern": "Dark mode/",
106+
"flags": "g"
107+
},
108+
"trim": true
109+
}
110+
},
111+
{
112+
"name": "to-jss",
113+
"options": {
114+
"formatName": "camelCase",
115+
"formatTokens": {
116+
"colorFormat": "hex6",
117+
"fontSizeUnit": "px",
118+
"shadowFormat": "string"
119+
},
120+
"formatConfig": {
121+
"jssObjectName": "darkColorTokenObject",
75122
"exportDefault": false,
76123
"tabWidth": 2,
77124
"singleQuote": true

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</a>
2121
</p>
2222

23-
# Welcome! 👋
23+
# Welcome! 👋👋👋
2424

2525
Strapi Design System provides guidelines and tools to help anyone make Strapi's contributions more cohesive and to build plugins more efficiently.
2626

@@ -29,11 +29,11 @@ Strapi Design System provides guidelines and tools to help anyone make Strapi's
2929
Install Strapi Design System and its peer dependencies:
3030

3131
```sh
32-
$ yarn add @strapi/design-system @strapi/icons styled-components react-router-dom
32+
$ yarn add @strapi/design-system @strapi/icons styled-components
3333

3434
# or
3535

36-
$ npm i @strapi/design-system @strapi/icons styled-components react-router-dom
36+
$ npm i @strapi/design-system @strapi/icons styled-components
3737
```
3838

3939
## Usage
+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
node_modules
22
dist
33
storybook-static
4-
.DS_Store
4+
.DS_Store
5+
test-results/
6+
playwright-report/
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import React from 'react';
2-
import { MemoryRouter } from 'react-router-dom';
2+
import { parse } from 'qs';
33
import { ThemeProvider } from '../src/ThemeProvider';
44
import { VisuallyHidden } from '../src/VisuallyHidden';
5-
import { lightTheme } from '../src/themes/light-theme';
5+
import { Box } from '../src/Box';
6+
import { lightTheme } from '../src/themes/lightTheme';
7+
import { darkTheme } from '../src/themes/darkTheme';
68

79
export const parameters = {
810
options: {
@@ -14,18 +16,23 @@ export const parameters = {
1416
};
1517

1618
export const decorators = [
17-
(Story) => (
18-
<MemoryRouter>
19-
<ThemeProvider theme={lightTheme}>
20-
<main>
21-
<VisuallyHidden>
22-
{/* Necessary in order to prevent axe core from providing errors on main / heading */}
23-
<h1>Storybook story</h1>
24-
</VisuallyHidden>
19+
(Story) => {
20+
const themeQueryURL = parse(document.location.search).theme;
2521

26-
<Story />
27-
</main>
28-
</ThemeProvider>
29-
</MemoryRouter>
30-
),
22+
return (
23+
<>
24+
<ThemeProvider theme={themeQueryURL === 'dark' ? darkTheme : lightTheme}>
25+
<main>
26+
<VisuallyHidden>
27+
{/* Necessary in order to prevent axe core from providing errors on main / heading */}
28+
<h1>Storybook story</h1>
29+
</VisuallyHidden>
30+
<Box background={themeQueryURL === "dark" ? 'neutral100' : 'neutral0'} height="100%" padding={2}>
31+
<Story />
32+
</Box>
33+
</main>
34+
</ThemeProvider>
35+
</>
36+
)
37+
},
3138
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// jscodeshift can take a parser, like "babel", "babylon", "flow", "ts", or "tsx"
2+
// Read more: https://github.com/facebook/jscodeshift#parser
3+
export const parser = 'babel';
4+
5+
// Press ctrl+space for code completion
6+
export default function transformer(file, api) {
7+
const j = api.jscodeshift;
8+
const root = j(file.source);
9+
10+
let result;
11+
12+
const importPlaywright = j.importDeclaration(
13+
[j.importSpecifier(j.identifier('test'))],
14+
j.literal('@playwright/test'),
15+
);
16+
const imports = root.find(j.ImportDeclaration);
17+
const importsLength = imports.length;
18+
19+
if (importsLength) {
20+
j(imports.at(importsLength - 1).get()).insertAfter(importPlaywright);
21+
} else {
22+
root.get().node.program.body.unshift(importPlaywright);
23+
}
24+
25+
const newAsyncArrowFunction = (params, body) => {
26+
const arrowFunc = j.arrowFunctionExpression(params, body);
27+
arrowFunc.async = true;
28+
return arrowFunc;
29+
};
30+
31+
result = root
32+
.find(j.ArrowFunctionExpression)
33+
.forEach((path) => {
34+
if (path.value.async) {
35+
j(path).replaceWith(
36+
newAsyncArrowFunction(
37+
[{ type: 'ObjectPattern', properties: [{ type: 'Identifier', name: 'page' }] }],
38+
path.value.body,
39+
),
40+
);
41+
}
42+
})
43+
.toSource();
44+
45+
result = root
46+
.find(j.Identifier)
47+
.forEach((path) => {
48+
if (['describe', 'beforeEach', 'afterEach', 'beforeAll', 'afterAll'].includes(path.node.name)) {
49+
j(path).replaceWith(j.identifier('test.' + path.node.name));
50+
}
51+
if (path.node.name == 'it') {
52+
j(path).replaceWith(j.identifier('test'));
53+
}
54+
})
55+
.toSource();
56+
57+
return result;
58+
}

packages/strapi-design-system/jest.e2e.js

-15
This file was deleted.

packages/strapi-design-system/package.json

+5-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"@babel/preset-env": "^7.13.0",
1010
"@babel/preset-react": "^7.12.13",
1111
"@figspec/react": "^0.1.5",
12+
"@playwright/test": "^1.19.1",
1213
"@storybook/addon-actions": "^6.4.0",
1314
"@storybook/addon-essentials": "^6.4.0",
1415
"@storybook/addon-links": "^6.4.0",
@@ -25,17 +26,14 @@
2526
"eslint-config-prettier": "^7.2.0",
2627
"eslint-plugin-prettier": "^3.3.1",
2728
"eslint-plugin-react": "^7.22.0",
28-
"expect-playwright": "^0.3.3",
2929
"intl": "^1.2.5",
3030
"jest": "^26.6.3",
31-
"jest-playwright-preset": "^1.5.2",
3231
"jest-styled-components": "^7.0.4",
33-
"playwright": "^1.18.0",
3432
"prettier": "^2.2.1",
33+
"qs": "^6.10.3",
3534
"react": "^17.0.1",
3635
"react-copy-to-clipboard": "^5.0.4",
3736
"react-dom": "^17.0.1",
38-
"react-router-dom": "^5.2.0",
3937
"styled-components": "^5.2.1",
4038
"webpack-bundle-analyzer": "^4.4.0",
4139
"webpack-cli": "^4.5.0"
@@ -44,7 +42,6 @@
4442
"@strapi/icons": "^0.0.1-alpha.73",
4543
"react": "^17.0.1",
4644
"react-dom": "^17.0.1",
47-
"react-router-dom": "^5.2.0",
4845
"styled-components": "^5.2.1"
4946
},
5047
"dependencies": {
@@ -66,10 +63,10 @@
6663
"storybook": "start-storybook -p 6006",
6764
"test": "jest -c jest.config.js",
6865
"test:watch": "jest -c jest.config.js --watchAll",
69-
"test:e2e": "jest -c jest.e2e.js",
66+
"test:e2e": "playwright test",
67+
"test:e2e:ci": "cross-env CI=true playwright test",
7068
"test:e2e:watch": "jest -c jest.e2e.js --watchAll",
71-
"test:e2e:debug": "cross-env PWDEBUG=1 jest -c jest.e2e.js",
72-
"test:e2e:ci": "jest -c jest.e2e.js"
69+
"test:e2e:debug": "cross-env PWDEBUG=1 playwright test"
7370
},
7471
"gitHead": "bf52e690f743703a47f768ba83ebff55a3a12795"
7572
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const { devices } = require('@playwright/test');
2+
3+
const config = {
4+
testMatch: '**/__tests__/*.e2e.js',
5+
// Forbid test.only on CI
6+
forbidOnly: !!process.env.CI,
7+
/* Retry on CI only */
8+
retries: process.env.CI ? 2 : 0,
9+
use: {
10+
baseURL: 'http://localhost:6006',
11+
headless: true,
12+
contextOptions: {
13+
locale: 'en-US',
14+
},
15+
actionTimeout: 0,
16+
},
17+
projects: [
18+
{
19+
name: 'chromium',
20+
use: {
21+
...devices['Desktop Chrome'],
22+
},
23+
},
24+
{
25+
name: 'firefox',
26+
use: {
27+
...devices['Desktop Firefox'],
28+
},
29+
},
30+
{
31+
name: 'webkit',
32+
use: {
33+
...devices['Desktop Safari'],
34+
},
35+
},
36+
],
37+
};
38+
39+
module.exports = config;

0 commit comments

Comments
 (0)