Skip to content

Commit a570ecd

Browse files
e2e tests: switch on native automation (#31218)
1 parent 33378db commit a570ecd

File tree

104 files changed

+695
-643
lines changed

Some content is hidden

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

104 files changed

+695
-643
lines changed

.github/workflows/demos_visual_tests_frameworks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
needs: check-should-run
3636
if: needs.check-should-run.outputs.should-run == 'true'
3737
env:
38-
NODE_OPTIONS: "--max-old-space-size=8192"
38+
NODE_OPTIONS: --max-old-space-size=8192
3939
timeout-minutes: 40
4040

4141
steps:
@@ -154,7 +154,7 @@ jobs:
154154
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'force all tests')
155155
working-directory: apps/demos
156156
env:
157-
NODE_OPTIONS: "--max-old-space-size=8192"
157+
NODE_OPTIONS: --max-old-space-size=8192
158158
run: pnpx nx prepare-bundles
159159

160160
- name: Demos - Run tsc

.github/workflows/qunit_tests.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,15 @@ jobs:
149149
matrix:
150150
constel: [
151151
'ui',
152-
'ui.widgets(1/3)',
153-
'ui.widgets(2/3)',
154-
'ui.widgets(3/3)',
152+
'ui.widgets(1/2)',
153+
'ui.widgets(2/2)',
155154
'ui.editors(1/2)',
156155
'ui.editors(2/2)',
157156
'ui.htmlEditor',
158-
'ui.grid(1/4)',
159-
'ui.grid(2/4)',
160-
'ui.grid(3/4)',
161-
'ui.grid(4/4)',
162-
'ui.scheduler(1/3)',
163-
'ui.scheduler(2/3)',
164-
'ui.scheduler(3/3)',
157+
'ui.grid(1/2)',
158+
'ui.grid(2/2)',
159+
'ui.scheduler(1/2)',
160+
'ui.scheduler(2/2)',
165161
'viz'
166162
]
167163

.github/workflows/testcafe_tests.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ jobs:
7070
run: pnpm install
7171

7272
- name: Build
73-
run: pnpx nx build devextreme
73+
shell: bash
74+
env:
75+
NODE_OPTIONS: --max-old-space-size=8192
76+
run: pnpx nx build devextreme --uglify
7477

7578
- name: Zip artifacts
7679
working-directory: ./packages/devextreme
@@ -92,18 +95,13 @@ jobs:
9295
fail-fast: false
9396
matrix:
9497
ARGS: [
95-
{ componentFolder: "accessibility", name: "accessibility (1/2)", indices: "1/2" },
96-
{ componentFolder: "accessibility", name: "accessibility (2/2)", indices: "2/2" },
98+
{ componentFolder: "accessibility", name: "accessibility" },
9799
{ componentFolder: "common", name: "common" },
98100

99101
# Grids tests need to be reworked to work in fluent theme
100-
{ componentFolder: "dataGrid/common", name: "dataGrid / common (1/5)", indices: "1/5" },
101-
{ componentFolder: "dataGrid/common", name: "dataGrid / common (2/5)", indices: "2/5" },
102-
{ componentFolder: "dataGrid/common", name: "dataGrid / common (3/5)", indices: "3/5" },
103-
{ componentFolder: "dataGrid/common", name: "dataGrid / common (4/5)", indices: "4/5" },
104-
{ componentFolder: "dataGrid/common", name: "dataGrid / common (5/5)", indices: "5/5" },
105-
{ componentFolder: "dataGrid/sticky", name: "dataGrid / sticky (1/2)", indices: "1/2" },
106-
{ componentFolder: "dataGrid/sticky", name: "dataGrid / sticky (2/2)", indices: "2/2" },
102+
{ componentFolder: "dataGrid", name: "dataGrid (1/3)", indices: "1/3" },
103+
{ componentFolder: "dataGrid", name: "dataGrid (2/3)", indices: "2/3" },
104+
{ componentFolder: "dataGrid", name: "dataGrid (3/3)", indices: "3/3" },
107105
{ componentFolder: "cardView", name: "cardView" },
108106

109107
# Scheduler tests need to be reworked to work in fluent theme
@@ -163,8 +161,8 @@ jobs:
163161
run: |
164162
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
165163
166-
- uses: actions/cache@v4
167-
name: Setup pnpm cache
164+
- uses: actions/cache/restore@v4
165+
name: Restore pnpm cache
168166
with:
169167
path: |
170168
${{ env.STORE_PATH }}
@@ -178,6 +176,8 @@ jobs:
178176

179177
- name: Run TestCafe tests
180178
working-directory: ./e2e/testcafe-devextreme
179+
env:
180+
NODE_OPTIONS: --max-old-space-size=8192
181181
run: |
182182
if [ "${{ matrix.ARGS.theme }}" != "" ]; then
183183
THEME="--theme ${{ matrix.ARGS.theme }}"

e2e/testcafe-devextreme/.testcaferc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"screenshots": {
33
"path": "./",
44
"takeOnFails": true,
5+
"thumbnails": false,
56
"pathPattern": "/artifacts/failedtests/${TEST}"
67
},
78
"screenshots-comparer": {

e2e/testcafe-devextreme/helpers/domUtils.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,23 @@ export const addCaptionTo = ClientFunction((
116116

117117
element?.insertAdjacentText(where, caption);
118118
});
119+
120+
export const addFocusableElementBefore = ClientFunction((
121+
targetSelector: string,
122+
elementId = 'focusable-start',
123+
) => {
124+
const existing = document.getElementById(elementId);
125+
existing?.remove();
126+
127+
const target = document.querySelector(targetSelector);
128+
const button = document.createElement('button');
129+
button.id = elementId;
130+
button.textContent = 'Start';
131+
button.style.position = 'fixed';
132+
button.style.top = '0';
133+
button.style.left = '0';
134+
button.style.zIndex = '-1';
135+
button.style.opacity = '0';
136+
target?.parentElement?.insertBefore(button, target);
137+
return button.id;
138+
});

e2e/testcafe-devextreme/helpers/getPageUrl.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@ import { pathToFileURL } from 'url';
22
import { join } from 'path';
33

44
export default (currentDir: string, pagePath: string): string => {
5-
let path = pagePath;
6-
7-
if (process.env.shadowDom === 'true') {
8-
const lastIndexOfSlash = path.lastIndexOf('/');
9-
10-
path = `${path.substring(0, lastIndexOfSlash + 1)}shadowDom/${path.substring(lastIndexOfSlash + 1)}`;
11-
}
5+
const path = pagePath;
126

137
const fullPath = join(currentDir, path);
148

e2e/testcafe-devextreme/helpers/testPageUtils.ts

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import {
44
removeStylesheetRulesFromPage,
55
} from './domUtils';
66

7-
export async function clearTestPage(testController: TestController): Promise<void> {
8-
const shadowDom = process.env.shadowDom === 'true';
9-
10-
const clearTestPageFn = ClientFunction(() => {
7+
export async function clearTestPage(t: TestController): Promise<void> {
8+
await ClientFunction(() => {
119
const widgetSelector = '.dx-widget';
1210
const $elements = $(widgetSelector)
1311
.filter((_, element) => $(element).parents(widgetSelector).length === 0);
@@ -23,6 +21,9 @@ export async function clearTestPage(testController: TestController): Promise<voi
2321
$widgetElement.empty();
2422
});
2523

24+
const element = document.getElementById('focusable-start');
25+
element?.remove();
26+
2627
const body = document.querySelector('body');
2728
if (body) {
2829
body.innerHTML = '';
@@ -40,29 +41,58 @@ export async function clearTestPage(testController: TestController): Promise<voi
4041
`;
4142

4243
body?.prepend(temp.firstElementChild!);
43-
}, {
44-
dependencies: {
45-
shadowDom,
46-
},
47-
});
44+
}).with({ boundTestRun: t })();
4845

49-
await clearTestPageFn.with({ boundTestRun: testController })();
50-
await removeStylesheetRulesFromPage.with({ boundTestRun: testController })();
46+
await removeStylesheetRulesFromPage.with({ boundTestRun: t })();
5147
}
5248

5349
export async function loadAxeCore(t: TestController): Promise<void> {
54-
await t.eval(() => new Promise<void>((resolve, reject) => {
50+
await ClientFunction(() => new Promise<void>((resolve, reject) => {
5551
// @ts-expect-error ts-error
5652
if (window.axe) {
5753
resolve();
5854
return;
5955
}
6056

6157
const script = document.createElement('script');
58+
script.id = 'axe-core-script';
6259
script.src = '../../../node_modules/axe-core/axe.min.js';
6360
// @ts-expect-error ts-error
6461
script.onload = resolve;
6562
script.onerror = reject;
6663
document.head.appendChild(script);
67-
}));
64+
})).with({ boundTestRun: t })();
65+
}
66+
67+
export async function loadShadowDomExtension(t: TestController): Promise<void> {
68+
await ClientFunction(() => new Promise<void>((resolve, reject) => {
69+
if (document.getElementById('shadow-dom-extension-script')) {
70+
resolve();
71+
return;
72+
}
73+
74+
const script = document.createElement('script');
75+
script.id = 'shadow-dom-extension-script';
76+
script.src = '../../helpers/shadowDom/shadowDomExtension.js';
77+
// @ts-expect-error ts-error
78+
script.onload = resolve;
79+
script.onerror = reject;
80+
document.head.appendChild(script);
81+
})).with({ boundTestRun: t })();
6882
}
83+
84+
export const addShadowRootTree = async (t: TestController): Promise<void> => {
85+
await ClientFunction(() => {
86+
const root = document.querySelector('#parentContainer') as HTMLElement;
87+
const { childNodes } = root;
88+
89+
if (!root.shadowRoot) {
90+
root.attachShadow({ mode: 'open' });
91+
}
92+
93+
const shadowContainer = document.createElement('div');
94+
shadowContainer.append(...Array.from(childNodes));
95+
96+
root.shadowRoot!.appendChild(shadowContainer);
97+
}).with({ boundTestRun: t })();
98+
};

e2e/testcafe-devextreme/helpers/themeUtils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { isString } from 'devextreme/core/utils/type';
2+
import { ClientFunction } from 'testcafe';
23
import { changeTheme } from './changeTheme';
34

45
const defaultThemeName = 'fluent.blue.light';
@@ -8,6 +9,13 @@ export const getThemePostfix = (theme?: string): string => {
89
return ` (${themeName})`;
910
};
1011

12+
export const getCurrentTheme = async (t: TestController): Promise<string> => {
13+
// eslint-disable-next-line max-len
14+
const currentTheme = await ClientFunction(() => (window as any).DevExpress?.ui.themes.current()).with({ boundTestRun: t })();
15+
16+
return currentTheme;
17+
};
18+
1119
export const isMaterial = (): boolean => process.env.theme === 'material.blue.light';
1220

1321
export const isFluent = (): boolean => process.env.theme === 'fluent.blue.light';

e2e/testcafe-devextreme/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"mockdate": "3.0.5",
2929
"nconf": "0.12.1",
3030
"testcafe": "3.7.2",
31+
"testcafe-reporter-spec-time": "4.0.0",
3132
"ts-node": "10.9.2"
3233
}
3334
}

0 commit comments

Comments
 (0)