Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .github/workflows/default_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ jobs:
devextreme-react-playground
devextreme-vue-playground

# The project's test target is the whole Playwright suite, so run-many leaves it out. The nx cache
# skips this one unless the tools changed.
- name: Test Playwright tools
run: pnpm exec nx run devextreme-playwright-tests:test-tools

- name: Save nx cache
if: github.event_name != 'pull_request'
uses: actions/cache/save@v5
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ jobs:
working-directory: ./e2e/playwright
run: pnpm exec nx type-check

- name: Type-check Playwright tools
working-directory: ./tools/playwright
run: pnpm exec nx type-check

- name: Save nx cache
if: github.event_name != 'pull_request'
uses: actions/cache/save@v5
Expand Down
19 changes: 12 additions & 7 deletions .github/workflows/playwright_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ jobs:
# The default blob name is built from the test paths only, so jobs that differ by theme or
# timezone alone would write the same zip and overwrite each other once merged.
PLAYWRIGHT_BLOB_OUTPUT_NAME: report-${{ env.JOB_NAME }}.zip
# tools/flakyReporter.ts stamps every flaky test it records with the job it ran in.
# tools/playwright/flakyReporter.ts stamps every flaky test it records with the job it ran in.
FLAKY_REPORT_JOB: ${{ matrix.name }}${{ !matrix.theme && ' - fluent' || '' }}
FLAKY_REPORT_COMPONENT_FOLDER: ${{ matrix.componentFolder }}
FLAKY_REPORT_BASE_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref || github.ref_name }}
Expand Down Expand Up @@ -320,7 +320,8 @@ jobs:
if-no-files-found: ignore

# One folder at repository paths: the new etalons the tests wrote, and the etalons of the failed
# shots that tools/etalonCollector.ts collected. Two paths would be rooted at their common ancestor.
# shots that tools/playwright/etalonCollector.ts collected. Two paths would be rooted at their
# common ancestor.
- name: Collect etalons
if: ${{ always() }}
run: |
Expand Down Expand Up @@ -415,8 +416,10 @@ jobs:
path: ${{ github.workspace }}/playwright-report
if-no-files-found: error

# The steps below do not need the HTML report, so they also run after a step above fails: an `if`
# without a status function such as !cancelled() gets an implicit success().
- name: Merge test traces
if: steps.mergeable-artifacts.outputs.traces == 'true'
if: ${{ !cancelled() && steps.mergeable-artifacts.outputs.traces == 'true' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
Expand All @@ -426,7 +429,7 @@ jobs:
delete-merged: true

- name: Merge etalons
if: steps.mergeable-artifacts.outputs.etalons == 'true'
if: ${{ !cancelled() && steps.mergeable-artifacts.outputs.etalons == 'true' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
Expand All @@ -435,15 +438,17 @@ jobs:
delete-merged: true

- name: Download flaky test reports
if: steps.mergeable-artifacts.outputs.flaky == 'true'
id: download-flaky-reports
if: ${{ !cancelled() && steps.mergeable-artifacts.outputs.flaky == 'true' }}
uses: actions/download-artifact@v7
with:
pattern: playwright-flaky-report-*
path: ${{ github.workspace }}/flaky-reports

# The file tools/flaky-test-reporter collects from every run of this workflow (repository-check.yml).
- name: Build flaky candidates report
if: steps.mergeable-artifacts.outputs.flaky == 'true'
id: build-flaky-candidates
if: ${{ !cancelled() && steps.download-flaky-reports.outcome == 'success' }}
run: |
mkdir -p artifacts
report=artifacts/flaky-candidates.json
Expand All @@ -464,7 +469,7 @@ jobs:
} >> "$GITHUB_STEP_SUMMARY"

- name: Upload flaky candidates report
if: steps.mergeable-artifacts.outputs.flaky == 'true'
if: ${{ !cancelled() && steps.build-flaky-candidates.outcome == 'success' }}
uses: actions/upload-artifact@v7
with:
name: flaky-candidates
Expand Down
124 changes: 85 additions & 39 deletions .github/workflows/visual-tests-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,18 @@ jobs:
DISPLAY: ''
run: pnpm run test-playwright:accessibility

# A test that writes a missing etalon passes (updateSnapshots: 'missing'), so this step fails the job
# and names the new files. It comes before the blob upload, which runs only after a failure.
- name: Fail on new etalons
if: always() && matrix.STRATEGY == 'screenshots'
run: |
new_etalons=$(git ls-files --others --exclude-standard -- 'apps/demos/testing/*etalons/*.png')
if [ -n "$new_etalons" ]; then
echo "::error::The tests wrote etalons that are not in the repository. They are in the playwright-etalons-jquery artifact:"
echo "$new_etalons"
exit 1
fi

- name: Upload Playwright blob report
if: failure()
uses: actions/upload-artifact@v7
Expand All @@ -549,32 +561,25 @@ jobs:
path: ${{ github.workspace }}/apps/demos/testing/artifacts/playwright/test-results
if-no-files-found: ignore

- name: Collect new etalons
# One folder at repository paths: the new etalons the tests wrote, and the etalons of the failed
# shots that tools/playwright/etalonCollector.ts collected.
- name: Collect etalons
if: always() && matrix.STRATEGY == 'screenshots'
run: |
mkdir -p "$RUNNER_TEMP/new-etalons"
mkdir -p "$RUNNER_TEMP/etalons"
git ls-files --others --exclude-standard -z -- 'apps/demos/testing/*etalons/*.png' \
| xargs -0 -r cp --parents -t "$RUNNER_TEMP/new-etalons"
| xargs -0 -r cp --parents -t "$RUNNER_TEMP/etalons"
collected=apps/demos/testing/artifacts/playwright/collected-etalons
if [ -d "$collected" ]; then cp -R "$collected/." "$RUNNER_TEMP/etalons"; fi

- name: Upload new etalons
- name: Upload etalons
if: always() && matrix.STRATEGY == 'screenshots'
uses: actions/upload-artifact@v7
with:
name: playwright-etalons-${{ env.PLAYWRIGHT_JOB_NAME }}
path: ${{ runner.temp }}/new-etalons
path: ${{ runner.temp }}/etalons
if-no-files-found: ignore

# A retry passes against the etalon its first attempt wrote, so new etalons fail the job here.
- name: Fail on new etalons
if: always() && matrix.STRATEGY == 'screenshots'
run: |
new_etalons=$(git ls-files --others --exclude-standard -- 'apps/demos/testing/*etalons/*.png')
if [ -n "$new_etalons" ]; then
echo "::error::The tests wrote etalons that are not in the repository. They are in the playwright-etalons artifact:"
echo "$new_etalons"
exit 1
fi

- name: Sanitize job name
if: ${{ failure() }}
run: echo "JOB_NAME=$(echo "${{ matrix.CONSTEL }}-${{ matrix.THEME }}" | tr '/' '-')" >> $GITHUB_ENV
Expand Down Expand Up @@ -735,6 +740,20 @@ jobs:
PLAYWRIGHT_BLOB_OUTPUT_NAME: report-${{ env.PLAYWRIGHT_JOB_NAME }}.zip
run: pnpm run test-playwright

# A test that writes a missing etalon passes (updateSnapshots: 'missing'), so this step fails the job
# and names the new files. It comes before the blob upload, which runs only after a failure.
- name: Fail on new etalons
if: always()
env:
CONSTEL: ${{ matrix.CONSTEL }}
run: |
new_etalons=$(git ls-files --others --exclude-standard -- 'apps/demos/testing/*etalons/*.png')
if [ -n "$new_etalons" ]; then
echo "::error::The tests wrote etalons that are not in the repository. They are in the playwright-etalons-${CONSTEL%%(*} artifact:"
echo "$new_etalons"
exit 1
fi

- name: Upload Playwright blob report
if: failure()
uses: actions/upload-artifact@v7
Expand All @@ -751,32 +770,25 @@ jobs:
path: ${{ github.workspace }}/apps/demos/testing/artifacts/playwright/test-results
if-no-files-found: ignore

- name: Collect new etalons
# One folder at repository paths: the new etalons the tests wrote, and the etalons of the failed
# shots that tools/playwright/etalonCollector.ts collected.
- name: Collect etalons
if: always()
run: |
mkdir -p "$RUNNER_TEMP/new-etalons"
mkdir -p "$RUNNER_TEMP/etalons"
git ls-files --others --exclude-standard -z -- 'apps/demos/testing/*etalons/*.png' \
| xargs -0 -r cp --parents -t "$RUNNER_TEMP/new-etalons"
| xargs -0 -r cp --parents -t "$RUNNER_TEMP/etalons"
collected=apps/demos/testing/artifacts/playwright/collected-etalons
if [ -d "$collected" ]; then cp -R "$collected/." "$RUNNER_TEMP/etalons"; fi

- name: Upload new etalons
- name: Upload etalons
if: always()
uses: actions/upload-artifact@v7
with:
name: playwright-etalons-${{ env.PLAYWRIGHT_JOB_NAME }}
path: ${{ runner.temp }}/new-etalons
path: ${{ runner.temp }}/etalons
if-no-files-found: ignore

# A retry passes against the etalon its first attempt wrote, so new etalons fail the job here.
- name: Fail on new etalons
if: always()
run: |
new_etalons=$(git ls-files --others --exclude-standard -- 'apps/demos/testing/*etalons/*.png')
if [ -n "$new_etalons" ]; then
echo "::error::The tests wrote etalons that are not in the repository. They are in the playwright-etalons artifact:"
echo "$new_etalons"
exit 1
fi

merge-artifacts:
runs-on: ubuntu-latest
timeout-minutes: 6
Expand All @@ -799,7 +811,10 @@ jobs:
const artifactGroups = {
blobs: /^playwright-blob-/,
traces: /^playwright-traces-/,
etalons: /^playwright-etalons-/,
etalons_jquery: /^playwright-etalons-jquery\(/,
etalons_react: /^playwright-etalons-react\(/,
etalons_vue: /^playwright-etalons-vue\(/,
etalons_angular: /^playwright-etalons-angular\(/,
};

for (const [outputName, pattern] of Object.entries(artifactGroups)) {
Expand Down Expand Up @@ -853,8 +868,10 @@ jobs:
path: ${{ github.workspace }}/playwright-report
if-no-files-found: error

# The steps below do not need the HTML report, so they also run after a step above fails: an `if`
# without a status function such as !cancelled() gets an implicit success().
- name: Merge Playwright traces
if: steps.playwright-artifacts.outputs.traces == 'true'
if: ${{ !cancelled() && steps.playwright-artifacts.outputs.traces == 'true' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
Expand All @@ -863,17 +880,46 @@ jobs:
separate-directories: true
delete-merged: true

- name: Merge new etalons
if: steps.playwright-artifacts.outputs.etalons == 'true'
# One etalon serves every framework of a demo, so each framework gets its own artifact: merged
# together, a framework that renders differently would overwrite another's picture.
- name: Merge jQuery etalons
if: ${{ !cancelled() && steps.playwright-artifacts.outputs.etalons_jquery == 'true' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
name: playwright-etalons-jquery
pattern: playwright-etalons-jquery(*
delete-merged: true

- name: Merge React etalons
if: ${{ !cancelled() && steps.playwright-artifacts.outputs.etalons_react == 'true' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
name: playwright-etalons-react
pattern: playwright-etalons-react(*
delete-merged: true

- name: Merge Vue etalons
if: ${{ !cancelled() && steps.playwright-artifacts.outputs.etalons_vue == 'true' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
name: playwright-etalons-vue
pattern: playwright-etalons-vue(*
delete-merged: true

- name: Merge Angular etalons
if: ${{ !cancelled() && steps.playwright-artifacts.outputs.etalons_angular == 'true' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
name: playwright-etalons
pattern: playwright-etalons-*
name: playwright-etalons-angular
pattern: playwright-etalons-angular(*
delete-merged: true

- name: Merge jQuery accessibility reports
if: needs.playwright-jquery.result == 'failure'
if: ${{ !cancelled() && needs.playwright-jquery.result == 'failure' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
Expand Down
15 changes: 11 additions & 4 deletions apps/demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,25 @@ done

`--grep` takes test names, `<Product>-<Demo>`, which also select the widget tests of that demo; without it every jQuery demo and widget test runs, about ten minutes per theme. Record etalons from the jQuery demos only; check a framework against them with `CONSTEL=react` (or `vue`, `angular`) and without `--update-snapshots`. The first run builds the image and takes a few minutes more. The second loop compares as CI does: exactly.

A verify run that fails has already collected the picture of every shot that failed the same way in both attempts into `testing/artifacts/playwright/collected-etalons`, and prints the command that applies them. The next run empties the folder, so apply it after each theme:

```
THEME=fluent.blue.light utils/visual-tests/playwright/docker/run.sh --grep DataGrid-Overview
pnpm run apply-etalons testing/artifacts/playwright/collected-etalons/apps
```

The repository is mounted case-insensitively on macOS: a file that a demo requests in the wrong case loads in the container and is missing on CI.

### Etalons from CI

Without a container CI records the etalon: delete the file and push. The job fails on the missing etalon and uploads what it rendered:
A failed run collects the etalons too: the picture of every shot that failed the same way in both attempts, and the new etalons the tests wrote (delete an etalon and push to have CI record it; the job fails on it). Each framework gets its own artifact: `playwright-etalons-jquery`, `-react`, `-vue` and `-angular`. One etalon serves all frameworks of a demo, so apply the jQuery one; the others show what a framework renders, which matters when it differs from jQuery. Download the artifact outside the repository and apply its `apps` folder from `apps/demos`:

```
gh run download <run-id> -n playwright-etalons -D ci-etalons
cp -R ci-etalons/. ../.. # from apps/demos: the paths start at the repository root
gh run download <run-id> -n playwright-etalons-jquery -D ~/Downloads/playwright-etalons-jquery-<run-id>
pnpm run apply-etalons ~/Downloads/playwright-etalons-jquery-<run-id>/apps
```

Look at the image before you commit it. One etalon serves all frameworks of a demo.
The script writes only PNG files at an etalon path of this checkout and prints what it replaced, created, found up to date or did not apply. Look at the images before you commit them. A failed shot that was not collected is listed in the job summary with the reason; "Update etalons" in `e2e/playwright/README.md` explains the reasons.

### Files next to a demo

Expand Down
1 change: 1 addition & 0 deletions apps/demos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"lint": "pnpm exec nx run-many -t lint-js lint-demos lint-css lint-html -p devextreme-demos",
"test-playwright": "playwright test",
"test-playwright:accessibility": "playwright test --config playwright.accessibility.config.ts",
"apply-etalons": "node ../../tools/playwright/apply-etalons.mjs",
"build-vendor-bundles": "node utils/server/build-vendor-bundles.js",
"fix-lint": "prettier --write . && eslint --fix . && stylelint **/*.{css,vue} --fix",
"prettier": "prettier",
Expand Down
13 changes: 12 additions & 1 deletion apps/demos/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,20 @@ export default defineConfig({
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
// Playwright's default fails a test that writes a missing etalon and skips its retry, so the
// collector could not take the test's changed etalons in the same run. The job still fails on
// the new etalon.
updateSnapshots: process.env.CI ? 'missing' : undefined,
workers: process.env.CONCURRENCY ? Number(process.env.CONCURRENCY) : undefined,
reporter: process.env.CI
? [['list'], ['blob', { outputDir: './testing/artifacts/playwright/blob-report' }]]
? [
['list'],
['blob', { outputDir: './testing/artifacts/playwright/blob-report' }],
['../../tools/playwright/etalonCollector.ts', {
outputDir: './testing/artifacts/playwright/collected-etalons',
repositoryRoot: '../..',
}],
]
: [['list']],
timeout: 60000,
expect: {
Expand Down
6 changes: 4 additions & 2 deletions e2e/playwright/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ pnpm run apply-etalons <e2e folder>

The script writes only PNG files at an etalon path of this checkout and prints what it replaced,
created, found up to date or did not apply. Look through the changes before committing them — an
etalon is only as right as the render it captured.
etalon is only as right as the render it captured. The collector and the script live in
`tools/playwright`, shared with the demo screenshot tests; apply their `apps` folder from
`apps/demos` (see `apps/demos/README.md`).

A failed shot that was not collected is named with the reason, in the output of a local run and in
the job summary on CI:
Expand Down Expand Up @@ -312,7 +314,7 @@ in [Flaky tests](#flaky-tests).
A test that passes only on its retry is flaky. It does not fail the job, but it is not forgotten
either:

- the job annotates it ("Flaky test"), and `tools/flakyReporter.ts` records it;
- the job annotates it ("Flaky test"), and `tools/playwright/flakyReporter.ts` records it;
- the run summary lists the flaky tests of every job, and the run keeps them in its
`flaky-candidates` artifact;
- `repository-check.yml` adds those up over 72 hours in the repository monitor issue, the tests that
Expand Down
3 changes: 0 additions & 3 deletions e2e/playwright/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ export default [
ignores: [
'playwright.config.ts',
'tests/scheduler/**/*.ts',
// The tools and their self-tests: the rules are for tests, and a nested Playwright run needs more
// than the default timeout.
'tools/**',
],
rules: {
'no-restricted-syntax': ['error', {
Expand Down
3 changes: 1 addition & 2 deletions e2e/playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"version": "26.2.2",
"scripts": {
"test": "node ./runner.mjs",
"test:tools": "playwright test -c tools/playwright.config.ts",
"apply-etalons": "node tools/apply-etalons.mjs",
"apply-etalons": "node ../../tools/playwright/apply-etalons.mjs",
"lint": "eslint",
"type-check": "tsc --noEmit -p tsconfig.json"
},
Expand Down
Loading
Loading