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
21 changes: 0 additions & 21 deletions .github/workflows/pr-filter-stubs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: exit 1
demos_visual_tests7:
name: 'jquery-accessibility-fluent.blue.light'
needs: [ stubChecksReady ]
if: false
runs-on: ubuntu-latest
steps:
- run: exit 1
demos_visual_tests16:
name: 'jquery-accessibility-fluent.blue.dark'
needs: [ stubChecksReady ]
Expand All @@ -322,13 +315,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: exit 1
demos_visual_tests18:
name: 'jquery-accessibility-material.blue.light'
needs: [ stubChecksReady ]
if: false
runs-on: ubuntu-latest
steps:
- run: exit 1
demos_visual_tests19:
name: 'react(1/3)-screenshots-fluent.blue.light'
needs: [ stubChecksReady ]
Expand Down Expand Up @@ -490,13 +476,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: exit 1
demos_visual_tests43:
name: 'jquery-accessibility-fluent-next.blue.light'
needs: [ stubChecksReady ]
if: false
runs-on: ubuntu-latest
steps:
- run: exit 1
demos_visual_tests44:
name: 'jquery-accessibility-fluent-next.blue.dark'
needs: [ stubChecksReady ]
Expand Down
14 changes: 5 additions & 9 deletions .github/workflows/visual-tests-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,6 @@ jobs:
- { STRATEGY: screenshots, THEME: fluent-next.blue.light, CONSTEL: jquery(1/3) }
- { STRATEGY: screenshots, THEME: fluent-next.blue.light, CONSTEL: jquery(2/3) }
- { STRATEGY: screenshots, THEME: fluent-next.blue.light, CONSTEL: jquery(3/3) }
- { STRATEGY: accessibility, THEME: material.blue.light, CONSTEL: jquery }
- { STRATEGY: accessibility, THEME: fluent.blue.light, CONSTEL: jquery }
- { STRATEGY: accessibility, THEME: fluent-next.blue.light, CONSTEL: jquery }
- { STRATEGY: accessibility, THEME: material.blue.dark, CONSTEL: jquery }
- { STRATEGY: accessibility, THEME: fluent.blue.dark, CONSTEL: jquery }
- { STRATEGY: accessibility, THEME: fluent-next.blue.dark, CONSTEL: jquery }
Expand Down Expand Up @@ -523,6 +520,9 @@ jobs:
# The default blob name is built from the test paths only, so jobs that differ by theme or
# shard alone would write the same zip and overwrite each other once merged.
PLAYWRIGHT_BLOB_OUTPUT_NAME: report-${{ env.PLAYWRIGHT_JOB_NAME }}.zip
# With the agent's X display the Azure maps of Map-Markers and Map-Routes never draw their
# controls, and their accessibility tests wait for them.
DISPLAY: ''
run: pnpm run test-playwright

- name: Run Playwright accessibility tests (jQuery)
Expand Down Expand Up @@ -585,15 +585,11 @@ jobs:
path: ${{ runner.temp }}/etalons
if-no-files-found: ignore

- name: Sanitize job name
if: ${{ failure() }}
run: echo "JOB_NAME=$(echo "${{ matrix.CONSTEL }}-${{ matrix.THEME }}" | tr '/' '-')" >> $GITHUB_ENV

- name: Copy accessibility report
if: always() && matrix.STRATEGY == 'accessibility'
if: always()
uses: actions/upload-artifact@v7
with:
name: accessibility-reports-${{ env.JOB_NAME }}-${{ matrix.THEME }}
name: accessibility-reports-${{ env.PLAYWRIGHT_JOB_NAME }}
path: apps/demos/testing/artifacts/axe-reports/*
if-no-files-found: ignore

Expand Down
4 changes: 2 additions & 2 deletions apps/demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pnpm run convert-to-js "JSDemos/Demos/Diagram/**/React"
The "Check generated JS demos" GitHub Action ensures that the React JavaScript and TypeScript sources remain in sync.
## Screenshot Tests

Every demo page is compared with an etalon in `testing/etalons` (`testing/common.spec.ts`), and the widget tests in `testing/widgets` click through some demos and compare the steps with their own etalons. Both run on [Playwright](https://playwright.dev/) for jQuery, React, Vue and Angular, as do the jQuery accessibility checks (`testing/accessibility.spec.ts`).
Every demo page is compared with an etalon in `testing/etalons` (`testing/common.spec.ts`), and the widget tests in `testing/widgets` click through some demos and compare the steps with their own etalons. Both run on [Playwright](https://playwright.dev/) for jQuery, React, Vue and Angular. The jQuery demo tests also check the page with axe (see [Accessibility Tests](#accessibility-tests)).

One etalon serves all four frameworks of a demo, and it is recorded from the jQuery demo. A framework that draws a demo differently is not given an etalon of its own: find out why it differs and make the demo the same in every framework.

Expand Down Expand Up @@ -199,7 +199,7 @@ A failed comparison uploads its `-expected`, `-actual` and `-diff` images with t

## Accessibility Tests

`testing/accessibility.spec.ts` checks the `.demo-container` of every jQuery demo with [axe](https://github.com/dequelabs/axe-core) on Playwright. Fluent-next themes run only the `color-contrast` rule. The rules switched off for a demo are listed in `getIgnoredRules` of the same file. CI runs the light and dark variants of fluent, material and fluent-next.
The `.demo-container` of every jQuery demo is checked with [axe](https://github.com/dequelabs/axe-core). In the themes with screenshot tests (the light fluent, material and fluent-next), `testing/common.spec.ts` runs the check on the page of the screenshot test, after the comparison; a demo without a screenshot test gets a test with the check alone. The dark themes have no screenshot tests, so CI checks them with `testing/accessibility.spec.ts`, which runs only axe in any theme. Fluent-next themes run only the `color-contrast` rule. The rules switched off for a demo are listed in `getIgnoredRules` of `utils/visual-tests/playwright/accessibility.ts`.

Build DevExtreme as for the screenshot tests, then:

Expand Down
3 changes: 1 addition & 2 deletions apps/demos/playwright.accessibility.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { defineConfig } from '@playwright/test';
import baseConfig from './playwright.config';
import { ACCESSIBILITY_VIEWPORT } from './utils/visual-tests/playwright/const';

export default defineConfig(baseConfig, {
testMatch: 'accessibility.spec.ts',
retries: 0,
use: { viewport: ACCESSIBILITY_VIEWPORT, trace: 'off', screenshot: 'off' },
use: { trace: 'off', screenshot: 'off' },
});
111 changes: 8 additions & 103 deletions apps/demos/testing/accessibility.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { readFileSync, rmSync } from 'fs';
import { join } from 'path';
import AxeBuilder from '@axe-core/playwright';
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { FRAMEWORKS } from '../utils/visual-tests/matrix-test-core';
import { isFluent, isMaterial } from '../utils/visual-tests/helpers/theme-utils';
import { createMdReport } from '../utils/axe-reporter/reporter';
import {
checkAccessibility,
createAxeBuilder,
findViolations,
hasAccessibilityCheck,
} from '../utils/visual-tests/playwright/accessibility';
import { mockApi } from '../utils/visual-tests/playwright/api-mocks';
import { BASE_URL, THEME } from '../utils/visual-tests/playwright/const';
import {
Expand All @@ -15,115 +17,18 @@ import {
} from '../utils/visual-tests/playwright/demo-page';
import { getDemos, loadDemo } from '../utils/visual-tests/playwright/demos';

const COLOR_CONTRAST_RULE = 'color-contrast';

const isColorContrastOnly = THEME.startsWith('fluent-next');

const DEMOS_ROOT = join(__dirname, '..');

const getIgnoredRules = (testName: string): string[] => {
const ignoredRules: string[] = [];

if ((isMaterial() || isFluent())
&& [
// False positive: contrast rules do not apply to custom orange color
'CardView-FieldTemplate',
// False positive: contrast rules do not apply to read-only editors on the custom option panel background
'VectorMap-DynamicViewport',
].includes(testName)
) {
ignoredRules.push('color-contrast');
}

const specificRules: Record<string, string[]> = {
'Diagram-Adaptability': ['aria-dialog-name', 'label'],
'Diagram-AdvancedDataBinding': ['aria-dialog-name', 'label'],
'Diagram-Containers': ['aria-dialog-name', 'label'],
'Diagram-CustomShapesWithIcons': ['aria-dialog-name', 'label'],
'Diagram-CustomShapesWithTemplates': ['label'],
'Diagram-CustomShapesWithTemplatesWithEditing': ['aria-dialog-name', 'label'],
'Diagram-CustomShapesWithTexts': ['aria-dialog-name', 'label'],
'Diagram-ImagesInShapes': ['aria-dialog-name', 'label'],
'Diagram-ItemSelection': ['label'],
'Diagram-NodesAndEdgesArrays': ['aria-dialog-name', 'label'],
'Diagram-NodesArrayHierarchicalStructure': ['aria-dialog-name', 'label'],
'Diagram-NodesArrayPlainStructure': ['aria-dialog-name', 'label'],
'Diagram-OperationRestrictions': ['aria-dialog-name', 'label'],
'Diagram-Overview': ['aria-dialog-name', 'label'],
'Diagram-ReadOnly': ['label'],
'Diagram-SimpleView': ['label'],
'Diagram-UICustomization': ['aria-dialog-name', 'label'],
'Diagram-WebAPIService': ['aria-dialog-name', 'label'],

'FileManager-BindingToEF': ['aria-command-name', 'empty-table-header', 'label'],
'FileManager-BindingToFileSystem': ['aria-command-name', 'empty-table-header', 'label'],
'FileManager-BindingToHierarchicalStructure': ['aria-command-name', 'empty-table-header', 'label'],
'FileManager-CustomThumbnails': ['aria-allowed-attr', 'aria-command-name', 'image-alt', 'label'],
'FileManager-Overview': ['aria-command-name', 'empty-table-header', 'label'],
'FileManager-UICustomization': ['aria-command-name', 'empty-table-header', 'label'],

'Gantt-Appearance': ['aria-toggle-field-name'],
'Gantt-ExportToPDF': ['aria-toggle-field-name'],
};

return [
...ignoredRules,
...(specificRules[testName] || []),
];
};

const areAriaOwnsResolved = (): boolean => Array
.from(document.querySelectorAll('[aria-owns]'))
.every((element) => (element.getAttribute('aria-owns') ?? '')
.split(' ')
.every((id) => !id || document.getElementById(id)));

const createAxeBuilder = (page: Page, ignoredRules: string[], colorContrastOnly: boolean): AxeBuilder => {
const builder = new AxeBuilder({ page })
.include('.demo-container')
.setLegacyMode();

return colorContrastOnly
? builder.withRules([COLOR_CONTRAST_RULE])
: builder.disableRules(ignoredRules);
};

const findViolations = async (
page: Page,
testName: string,
ignoredRules: string[],
colorContrastOnly: boolean,
): Promise<string[]> => {
await page.waitForFunction(areAriaOwnsResolved);

const results = await createAxeBuilder(page, ignoredRules, colorContrastOnly).analyze();

if (results.violations.length > 0) {
createMdReport({ testName, results });
}

return results.violations.map(({ id, impact, nodes }) => `${id} (${impact}): ${nodes.map(({ target }) => target.join(' ')).join(', ')}`);
};

const getPageTheme = (page: Page): Promise<string> => page.evaluate(
() => window.DevExpress.ui.themes.current(),
);

test.describe(FRAMEWORKS.jquery, () => {
getDemos(FRAMEWORKS.jquery).forEach((demo) => {
const ignoredRules = getIgnoredRules(demo.testName);

if (isColorContrastOnly && ignoredRules.includes(COLOR_CONTRAST_RULE)) { return; }
if (!hasAccessibilityCheck(demo.testName)) { return; }

test(demo.testName, async ({ page }) => {
const pageErrors = await loadDemo(page, demo);

expect(pageErrors, 'uncaught errors in the page').toEqual([]);
expect(await getPageTheme(page), 'theme of the page').toBe(THEME);

const violations = await findViolations(page, demo.testName, ignoredRules, isColorContrastOnly);

expect(violations, 'accessibility violations').toEqual([]);
await checkAccessibility(page, demo.testName);
});
});
});
Expand Down
26 changes: 24 additions & 2 deletions apps/demos/testing/common.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
shouldSkipDemo,
} from '../utils/visual-tests/matrix-test-core';
import { DEFAULT_THEME_NAME, getScreenshotName } from '../utils/visual-tests/helpers/theme-utils';
import { checkAccessibility, hasAccessibilityCheck } from '../utils/visual-tests/playwright/accessibility';
import { THEME } from '../utils/visual-tests/playwright/const';
import { collectCspViolations, getConsoleMessages } from '../utils/visual-tests/playwright/demo-page';
import { CSP_LOAD_TEST_TIMEOUT, checkDemoLoadUnderCsp } from '../utils/visual-tests/playwright/csp-load';
Expand Down Expand Up @@ -32,9 +33,15 @@ Object.values(FRAMEWORKS).forEach((approach) => {
const demos = listDemos(approach);
const hasScreenshotTest = ({ demo, ignored }: ListedDemo): boolean => !ignored
&& !shouldSkipDemo(approach, demo.widgetName, demo.demoName, skippedTests);
// The jQuery demos are also checked with axe, on the page of the screenshot test.
const isAccessibilityChecked = ({ demo, ignored }: ListedDemo): boolean => approach === FRAMEWORKS.jquery
&& !ignored
&& hasAccessibilityCheck(demo.testName);

test.describe(approach, () => {
demos.filter(hasScreenshotTest).forEach(({ demo }) => {
demos.filter(hasScreenshotTest).forEach((listed) => {
const { demo } = listed;

test(demo.testName, async ({ page, cspViolations }) => {
const pageErrors = await loadDemo(page, demo, true);

Expand All @@ -46,7 +53,22 @@ Object.values(FRAMEWORKS).forEach((approach) => {
expect(consoleMessages, 'console errors and warnings').toEqual([]);
expect(pageErrors, 'uncaught errors in the page').toEqual([]);

await expect(page).toHaveScreenshot([getScreenshotName(`${demo.testName}.png`, THEME)]);
// Soft, so that a changed screenshot does not hide the accessibility violations.
await expect.soft(page).toHaveScreenshot([getScreenshotName(`${demo.testName}.png`, THEME)]);

if (isAccessibilityChecked(listed)) {
await checkAccessibility(page, demo.testName);
}
});
});

demos.filter((listed) => !hasScreenshotTest(listed) && isAccessibilityChecked(listed)).forEach(({ demo }) => {
test(`${demo.testName} accessibility`, async ({ page }) => {
const pageErrors = await loadDemo(page, demo);

expect(pageErrors, 'uncaught errors in the page').toEqual([]);

await checkAccessibility(page, demo.testName);
});
});
});
Expand Down
Loading
Loading