Skip to content

Commit fa783ca

Browse files
authored
Merge pull request #210 from UgnisSoftware/UGN-407
Add browser testing
2 parents 5366884 + 0547a4b commit fa783ca

File tree

11 files changed

+242
-41
lines changed

11 files changed

+242
-41
lines changed

.github/workflows/test.yaml

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,51 @@ on:
77
branches: [master]
88

99
jobs:
10-
build:
10+
unit-tests:
1111
runs-on: ubuntu-latest
12-
1312
steps:
14-
- uses: actions/checkout@v2
15-
- name: Use Node.js
16-
uses: actions/setup-node@v1
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-node@v3
1715
with:
18-
node-version: "16.x"
19-
- run: npm ci
16+
node-version: 18
17+
- name: Install dependencies
18+
run: npm ci
2019
- run: npm run lint
2120
- run: npm run ts
22-
- run: npm run test
21+
- run: npm run test:unit
22+
23+
e2e-tests:
24+
timeout-minutes: 60
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v3
28+
- uses: actions/setup-node@v3
29+
with:
30+
node-version: 18
31+
- name: Install dependencies
32+
run: npm ci
33+
- name: Install Playwright
34+
run: npx playwright install --with-deps
35+
- name: Run Playwright tests
36+
run: npx playwright test
37+
- uses: actions/upload-artifact@v3
38+
if: always()
39+
with:
40+
name: playwright-report
41+
path: playwright-report/
42+
retention-days: 30
43+
44+
45+
chromatic-test:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v2
49+
with:
50+
fetch-depth: 0 # Required to retrieve git history
51+
- name: Install dependencies
52+
run: npm ci
53+
- name: Publish to Chromatic
54+
uses: chromaui/action@v1
55+
with:
56+
# Grab this from the Chromatic manage page
57+
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ web_modules
77
dist
88
dist-commonjs
99
types
10-
coverage
10+
coverage
11+
/test-results/
12+
/playwright-report/
13+
/playwright/.cache/

e2e/example.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { test } from '@playwright/test';
2+
3+
test('has title', async ({ page }) => {
4+
await page.goto('http://localhost:6006/iframe.html?args=&id=select-header-step--basic&viewMode=story');
5+
6+
await page.getByRole('row', ).filter({ hasText: 'second' }).click();
7+
});

package-lock.json

Lines changed: 72 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
],
1313
"scripts": {
1414
"start": "storybook dev -p 6006",
15-
"test": "jest",
15+
"test:unit": "jest",
16+
"test:e2e": "npx playwright test",
17+
"test:chromatic": "npx chromatic ",
1618
"ts": "tsc",
1719
"lint": "eslint \"src/**/*.{ts,tsx}\"",
1820
"lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix",
@@ -39,7 +41,9 @@
3941
"automatic",
4042
"match"
4143
],
42-
"author": "Ugnis",
44+
"author": {
45+
"name": "Ugnis"
46+
},
4347
"license": "MIT",
4448
"bugs": {
4549
"url": "https://github.com/UgnisSoftware/react-spreadsheet-import/issues"
@@ -71,6 +75,7 @@
7175
"@babel/preset-typescript": "7.21.5",
7276
"@emotion/jest": "11.11.0",
7377
"@jest/types": "27.5.1",
78+
"@playwright/test": "^1.39.0",
7479
"@storybook/addon-essentials": "7.0.14",
7580
"@storybook/addon-interactions": "7.0.14",
7681
"@storybook/addon-links": "7.0.14",
@@ -85,13 +90,15 @@
8590
"@testing-library/user-event": "14.4.3",
8691
"@types/jest": "27.4.1",
8792
"@types/js-levenshtein": "1.1.1",
93+
"@types/node": "^20.8.7",
8894
"@types/react": "18.2.6",
8995
"@types/react-dom": "18.2.4",
9096
"@types/styled-system": "5.1.16",
9197
"@types/uuid": "9.0.1",
9298
"@typescript-eslint/eslint-plugin": "5.59.7",
9399
"@typescript-eslint/parser": "5.59.7",
94100
"babel-loader": "9.1.2",
101+
"chromatic": "^7.4.0",
95102
"eslint": "8.41.0",
96103
"eslint-config-prettier": "8.8.0",
97104
"eslint-plugin-prettier": "4.2.1",
@@ -144,6 +151,7 @@
144151
"moduleNameMapper": {
145152
"~/(.*)": "<rootDir>/src/$1"
146153
},
154+
"modulePathIgnorePatterns": ["<rootDir>/e2e/"],
147155
"transformIgnorePatterns": [
148156
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
149157
],
@@ -162,5 +170,7 @@
162170
"jest-watch-typeahead/filename",
163171
"jest-watch-typeahead/testname"
164172
]
165-
}
173+
},
174+
"readme": "ERROR: No README data found!",
175+
166176
}

playwright.config.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
/**
4+
* Read environment variables from file.
5+
* https://github.com/motdotla/dotenv
6+
*/
7+
// require('dotenv').config();
8+
9+
/**
10+
* See https://playwright.dev/docs/test-configuration.
11+
*/
12+
export default defineConfig({
13+
testDir: './e2e',
14+
/* Run tests in files in parallel */
15+
fullyParallel: true,
16+
/* Fail the build on CI if you accidentally left test.only in the source code. */
17+
forbidOnly: !!process.env.CI,
18+
/* Retry on CI only */
19+
retries: process.env.CI ? 2 : 0,
20+
/* Opt out of parallel tests on CI. */
21+
workers: process.env.CI ? 1 : undefined,
22+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
23+
reporter: 'html',
24+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
25+
use: {
26+
/* Base URL to use in actions like `await page.goto('/')`. */
27+
// baseURL: 'http://127.0.0.1:3000',
28+
29+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
30+
trace: 'on-first-retry',
31+
},
32+
33+
/* Configure projects for major browsers */
34+
projects: [
35+
{
36+
name: 'chromium',
37+
use: { ...devices['Desktop Chrome'] },
38+
},
39+
40+
{
41+
name: 'firefox',
42+
use: { ...devices['Desktop Firefox'] },
43+
},
44+
45+
{
46+
name: 'webkit',
47+
use: { ...devices['Desktop Safari'] },
48+
},
49+
50+
/* Test against mobile viewports. */
51+
// {
52+
// name: 'Mobile Chrome',
53+
// use: { ...devices['Pixel 5'] },
54+
// },
55+
// {
56+
// name: 'Mobile Safari',
57+
// use: { ...devices['iPhone 12'] },
58+
// },
59+
60+
/* Test against branded browsers. */
61+
// {
62+
// name: 'Microsoft Edge',
63+
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
64+
// },
65+
// {
66+
// name: 'Google Chrome',
67+
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
68+
// },
69+
],
70+
71+
/* Run your local dev server before starting the tests */
72+
webServer: {
73+
command: 'npm run start',
74+
url: 'http://localhost:6006',
75+
reuseExistingServer: !process.env.CI,
76+
},
77+
});

src/steps/SelectHeaderStep/SelectHeaderStep.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ export const SelectHeaderStep = ({ data, onContinue }: SelectHeaderProps) => {
3232
<>
3333
<ModalBody pb={0}>
3434
<Heading {...styles.heading}>{translations.selectHeaderStep.title}</Heading>
35-
<Box h={0} flexGrow={1}>
36-
<SelectHeaderTable data={data} selectedRows={selectedRows} setSelectedRows={setSelectedRows} />
37-
</Box>
35+
<SelectHeaderTable data={data} selectedRows={selectedRows} setSelectedRows={setSelectedRows} />
3836
</ModalBody>
3937
<ContinueButton
4038
onContinue={handleContinue}

0 commit comments

Comments
 (0)