Skip to content

Commit 2820f64

Browse files
Gururajj77tay1orjonesguidari
authored
test(e2e): add toContainAStory assertion to visitStory(new) (#16582)
* test(playwright): add toContainAStory assertion to visitStory * fix: datatable, errorboundary, modal * fix: renamed story urls for textinput, tag and uishell * fix: fixed fluid datepicker test and skipped datatable * fix: changed playwright config * feat: removed commented test * fix(playwright): re-enable tests * test(playwright): fix flaky tests, update playwright, improve ci artifacts * test(datepicker): fix flaky tests * chore: yarn dedupe * test(ci): fix playwright merge reports, flaky menu test --------- Co-authored-by: Taylor Jones <[email protected]> Co-authored-by: Taylor Jones <[email protected]> Co-authored-by: Guilherme Datilio Ribeiro <[email protected]>
1 parent d5aaf60 commit 2820f64

File tree

60 files changed

+445
-276
lines changed

Some content is hidden

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

60 files changed

+445
-276
lines changed

.github/workflows/ci.yml

Lines changed: 96 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ jobs:
6868
path: |
6969
node_modules
7070
*/**/node_modules
71-
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'packages/**/yarn.lock') }}
71+
key:
72+
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock',
73+
'packages/**/yarn.lock') }}
7274
- name: Install dependencies
7375
run: yarn install --immutable --immutable-cache
7476
- name: Build project
@@ -95,7 +97,9 @@ jobs:
9597
path: |
9698
node_modules
9799
*/**/node_modules
98-
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'packages/**/yarn.lock') }}
100+
key:
101+
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock',
102+
'packages/**/yarn.lock') }}
99103
- name: Install dependencies
100104
run: yarn install --immutable --immutable-cache
101105
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
@@ -119,8 +123,10 @@ jobs:
119123

120124
vrt-runner:
121125
strategy:
126+
fail-fast: false
122127
matrix:
123-
shard: [1, 2, 3, 4]
128+
shardIndex: [1, 2, 3, 4]
129+
shardTotal: [4]
124130
runs-on: ubuntu-latest
125131
steps:
126132
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
@@ -135,7 +141,9 @@ jobs:
135141
path: |
136142
node_modules
137143
*/**/node_modules
138-
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'packages/**/yarn.lock') }}
144+
key:
145+
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock',
146+
'packages/**/yarn.lock') }}
139147
- name: Install dependencies
140148
run: yarn install --immutable --immutable-cache
141149
- name: Install browsers
@@ -161,15 +169,16 @@ jobs:
161169
PERCY_TOKEN: c9a21a3fde4fda0a0f822d633426ab26e2ab2c1cba55221d342d4047744c8c24
162170
PERCY_PARALLEL_TOTAL: 4
163171
run: |
164-
yarn percy exec --parallel -- yarn playwright test --project chromium --grep @vrt --shard="${{ matrix.shard }}/4"
172+
yarn percy exec --parallel -- yarn playwright test --project chromium --grep @vrt --shard="${{ matrix.shardIndex }}/${{ matrix.shardTotal }}"
165173
- name: Stop storybook
166174
run: kill ${{ steps.storybook.outputs.pid }}
167-
- name: Upload test results
168-
if: always()
169-
uses: actions/upload-artifact@v3
175+
- name: Upload blob report to GitHub Actions Artifacts
176+
if: ${{ !cancelled() }}
177+
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a #4.3.6
170178
with:
171-
name: playwright-vrt-report
172-
path: .playwright
179+
name: playwright-vrt-blob-report-${{ matrix.shardIndex }}
180+
path: blob-report
181+
retention-days: 1
173182

174183
vrt:
175184
if: ${{ always() }}
@@ -182,8 +191,10 @@ jobs:
182191

183192
avt-runner:
184193
strategy:
194+
fail-fast: false
185195
matrix:
186-
shard: [1, 2, 3, 4]
196+
shardIndex: [1, 2, 3, 4]
197+
shardTotal: [4]
187198
runs-on: ubuntu-latest
188199
steps:
189200
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
@@ -198,7 +209,9 @@ jobs:
198209
path: |
199210
node_modules
200211
*/**/node_modules
201-
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'packages/**/yarn.lock') }}
212+
key:
213+
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock',
214+
'packages/**/yarn.lock') }}
202215
- name: Install dependencies
203216
run: yarn install --immutable --immutable-cache
204217
- name: Install browsers
@@ -221,15 +234,16 @@ jobs:
221234
- name: Run AVT
222235
if: github.repository == 'carbon-design-system/carbon'
223236
run: |
224-
yarn playwright test --project chromium --grep @avt --shard="${{ matrix.shard }}/4"
237+
yarn playwright test --project chromium --grep @avt --shard="${{ matrix.shardIndex }}/${{ matrix.shardTotal }}"
225238
- name: Stop storybook
226239
run: kill ${{ steps.storybook.outputs.pid }}
227-
- name: Upload test results
228-
if: always()
229-
uses: actions/upload-artifact@v3
240+
- name: Upload blob report to GitHub Actions Artifacts
241+
if: ${{ !cancelled() }}
242+
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a #4.3.6
230243
with:
231-
name: playwright-avt-report
232-
path: .playwright
244+
name: playwright-avt-blob-report-${{ matrix.shardIndex }}
245+
path: blob-report
246+
retention-days: 1
233247

234248
avt:
235249
if: ${{ always() }}
@@ -238,4 +252,67 @@ jobs:
238252
steps:
239253
- name: Check AVT Runner job status
240254
if: ${{ needs.avt-runner.result != 'success' }}
241-
run: exit 1
255+
run: exit 1
256+
257+
merge-playwright-reports:
258+
# Merge reports after *-runner jobs, even if some shards have failed
259+
if: ${{ !cancelled() }}
260+
needs: [vrt-runner, avt-runner]
261+
262+
runs-on: ubuntu-latest
263+
steps:
264+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
265+
- name: Use Node.js 20.x
266+
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b #v4.0.3
267+
with:
268+
node-version: '20.x'
269+
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 #v4.0.2
270+
if: github.event_name != 'merge_group'
271+
id: cache
272+
with:
273+
path: |
274+
node_modules
275+
*/**/node_modules
276+
key:
277+
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock',
278+
'packages/**/yarn.lock') }}
279+
- name: Install dependencies
280+
run: yarn install --immutable --immutable-cache
281+
282+
- name: Download vrt blob reports from GitHub Actions Artifacts
283+
uses: actions/download-artifact@v4
284+
with:
285+
path: all-playwright-vrt-blob-reports
286+
pattern: playwright-vrt-blob-report-*
287+
merge-multiple: true
288+
289+
- name: Merge vrt reports into HTML Report
290+
run:
291+
npx playwright merge-reports --reporter html
292+
./all-playwright-vrt-blob-reports
293+
294+
- name: Upload vrt HTML report
295+
uses: actions/upload-artifact@v4
296+
with:
297+
name: html-playwright-vrt-report--attempt-${{ github.run_attempt }}
298+
path: playwright-vrt-report
299+
retention-days: 14
300+
301+
- name: Download avt blob reports from GitHub Actions Artifacts
302+
uses: actions/download-artifact@v4
303+
with:
304+
path: all-playwright-avt-blob-reports
305+
pattern: playwright-avt-blob-report-*
306+
merge-multiple: true
307+
308+
- name: Merge avt reports into HTML Report
309+
run:
310+
npx playwright merge-reports --reporter html
311+
./all-playwright-avt-blob-reports
312+
313+
- name: Upload avt HTML report
314+
uses: actions/upload-artifact@v4
315+
with:
316+
name: html-playwright-avt-report--attempt-${{ github.run_attempt }}
317+
path: playwright-avt-report
318+
retention-days: 14

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
run: kill ${{ steps.storybook.outputs.pid }}
5959
- name: Upload test results
6060
if: always()
61-
uses: actions/upload-artifact@v3
61+
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a #4.3.6
6262
with:
6363
name: playwright-avt-report
6464
path: .playwright

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ package-lock.json
5757

5858
# Playwright
5959
.playwright
60+
blob-report
6061

6162
# Local token
6263
.env
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

e2e/components/Button/Button-test.avt.e2e.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ test.describe('@avt Button', () => {
150150
},
151151
});
152152
await expect(page.getByRole('button')).toBeVisible();
153-
page.getByRole('button').hover();
153+
await page.getByRole('button').hover();
154154

155155
await expect(page).toHaveNoACViolations('Button-hover');
156156
});

e2e/components/CodeSnippet/CodeSnippet-test.avt.e2e.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test.describe('@avt CodeSnippet', () => {
3232
});
3333

3434
await expect(page.getByRole('button')).toBeVisible();
35-
page.getByRole('button').hover();
35+
await page.getByRole('button').hover();
3636
await expect(page).toHaveNoACViolations('CodeSnippet inline hover');
3737
});
3838

e2e/components/DataTable/DataTable-test.avt.e2e.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,19 @@ test.describe('@avt DataTable', () => {
276276
'components-datatable-selection--default'
277277
);
278278
});
279-
test('@avt-advanced-states with-radio-expansion', async ({ page }) => {
279+
test.skip('@avt-advanced-states with-radio-expansion', async ({ page }) => {
280280
await visitStory(page, {
281281
component: 'DataTable',
282-
id: 'components-datatable-selection--with-radio-expansion',
282+
id: 'components-datatable-dynamic--playground',
283283
globals: {
284284
theme: 'white',
285285
},
286+
args: {
287+
radio: true,
288+
},
286289
});
287290
await expect(page).toHaveNoACViolations(
288-
'components-datatable-selection--with-radio-expansion'
291+
'components-datatable-with-radio-expansion'
289292
);
290293
});
291294
test('@avt-advanced-states with-selection-and-sorting', async ({

e2e/components/DatePicker/DatePicker-test.avt.e2e.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ test.describe('@avt DatePicker', () => {
4949
await expect(page).toHaveNoACViolations('DatePicker-Disabled');
5050
});
5151

52-
// skipping for now due to accessibility violation
5352
test('@avt-advanced-states skeleton', async ({ page }) => {
5453
await visitStory(page, {
5554
component: 'DatePicker',
@@ -62,8 +61,8 @@ test.describe('@avt DatePicker', () => {
6261
await expect(page).toHaveNoACViolations('DatePicker-Skeleton');
6362
});
6463

65-
// skipping for now due to accessibility violation
66-
test('@avt-advanced-states open', async ({ page }) => {
64+
// skipped due to text contrast accessibility violation
65+
test.skip('@avt-advanced-states open', async ({ page }) => {
6766
await visitStory(page, {
6867
component: 'DatePicker',
6968
id: 'components-datepicker--playground',
@@ -92,13 +91,26 @@ test.describe('@avt DatePicker', () => {
9291
await expect(
9392
page.getByRole('textbox', { name: 'Date Picker label' })
9493
).toBeFocused();
95-
await expect(page.locator('div.flatpickr-calendar')).toHaveClass(/open/);
96-
await page.keyboard.press('ArrowDown');
97-
await expect(page.locator('span.today')).toBeFocused();
98-
await page.keyboard.press('Escape');
99-
await expect(page.locator('div.flatpickr-calendar')).not.toHaveClass(
100-
/open/
101-
);
94+
const calendar = await page.locator('div.flatpickr-calendar');
95+
await expect(calendar).toHaveClass(/open/);
96+
97+
// avoid flaky test failures from the keyboard press happening too quickly
98+
// this retries the keypress along with the focus assertion until it passes
99+
await expect(async () => {
100+
await page.keyboard.press('ArrowDown');
101+
const today = await page.locator('span.today');
102+
await expect(today).toBeVisible();
103+
await expect(today).toBeFocused();
104+
}).toPass();
105+
106+
// avoid flaky test failures from the keyboard press happening too quickly
107+
// this retries the keypress along with the focus assertion until it passes
108+
await expect(async () => {
109+
await page.keyboard.press('Escape');
110+
await expect(page.locator('div.flatpickr-calendar')).not.toHaveClass(
111+
/open/
112+
);
113+
}).toPass();
102114
});
103115

104116
test('@avt-keyboard-nav range state', async ({ page }) => {

e2e/components/ErrorBoundary/ErrorBoundary-test.avt.e2e.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test.describe('@avt ErrorBoundary', () => {
2525
test('@avt-advanced-states with Custom context', async ({ page }) => {
2626
await visitStory(page, {
2727
component: 'ErrorBoundary',
28-
id: 'components-errorboundary--skeleton',
28+
id: 'components-errorboundary--with-custom-context',
2929
globals: {
3030
theme: 'white',
3131
},

e2e/components/FluidDatePicker/FluidDatePicker-test.avt.e2e.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,29 @@ test.describe('@avt FluidDatePicker', () => {
6565
});
6666
// for some reason the firs tab is not working to focus the first tabstop, so focusing manually
6767
await page.getByRole('textbox', { name: 'Label' }).focus();
68-
await expect(page.getByRole('textbox', { name: 'Label' })).toBeFocused();
69-
await expect(page.locator('div.flatpickr-calendar')).toHaveClass(/open/);
70-
await page.keyboard.press('ArrowDown');
71-
await expect(page.locator('span.today')).toBeFocused();
72-
await page.keyboard.press('Escape');
73-
await expect(page.locator('div.flatpickr-calendar')).not.toHaveClass(
74-
/open/
75-
);
68+
const textbox = await page.getByRole('textbox', { name: 'Label' });
69+
await expect(textbox).toBeFocused();
70+
const calendar = await page.locator('div.flatpickr-calendar');
71+
await expect(calendar).toHaveClass(/open/);
72+
await expect(calendar).toBeVisible();
73+
74+
const today = await page.locator('.flatpickr-day.today');
75+
76+
// avoid flaky test failures from the keyboard press happening too quickly
77+
// this retries the keypress along with the focus assertion until it passes
78+
await expect(async () => {
79+
await page.keyboard.press('ArrowDown');
80+
await expect(today).toBeVisible();
81+
await expect(today).toBeFocused();
82+
}).toPass();
83+
84+
// avoid flaky test failures from the keyboard press happening too quickly
85+
// this retries the keypress along with the focus assertion until it passes
86+
await expect(async () => {
87+
await page.keyboard.press('Escape');
88+
await expect(calendar).not.toHaveClass(/open/);
89+
await expect(calendar).toBeHidden();
90+
}).toPass();
7691
});
7792

7893
test('@avt-keyboard-nav range', async ({ page }) => {

e2e/components/FluidTextInput/FluidTextInput-test.avt.e2e.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test.describe('@avt FluidTextInput', () => {
2525
test('@avt-advanced-states password input', async ({ page }) => {
2626
await visitStory(page, {
2727
component: 'FluidTextInput',
28-
id: 'experimental-fluid-components-unstable-fluidtextinput--password-input',
28+
id: 'experimental-fluid-components-unstable-fluidpasswordinput--default',
2929
globals: {
3030
theme: 'white',
3131
},

e2e/components/FluidTextInput/FluidTextInput-test.e2e.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ test.describe('FluidTextInput', () => {
2222
});
2323

2424
await snapshotStory(page, {
25-
component: 'FluidTextInput',
26-
id: 'experimental-fluid-components-unstable-fluidtextinput--password-input',
25+
component: 'FluidPasswordInput',
26+
id: 'experimental-fluid-components-unstable-fluidpasswordinput--default',
2727
theme,
2828
});
2929
});

0 commit comments

Comments
 (0)