Skip to content

Commit 021a22c

Browse files
changes
1 parent b69fe29 commit 021a22c

38 files changed

+771
-246
lines changed

e2e/testcafe-devextreme/helpers/accessibility/test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface Configuration<TComponentOptions = unknown> {
1111
a11yCheckConfig?: A11yCheckOptions;
1212
selector?: ElementContext;
1313
created?: (t: TestController, optionConfiguration?: TComponentOptions) => Promise<void>;
14+
meta?: Record<string, unknown>;
1415
}
1516

1617
export const defaultSelector = '#container';
@@ -39,12 +40,15 @@ export const testAccessibility = <TComponentOptions = unknown>(
3940
selector = defaultSelector,
4041
a11yCheckConfig = defaultA11yCheckConfig,
4142
created = defaultCreated,
43+
meta: testMeta,
4244
} = configuration;
4345

4446
const optionConfigurations = getOptionConfigurations(options);
4547

4648
optionConfigurations.forEach((optionConfiguration, index) => {
47-
test(`${component}: test with axe #${index}`, async (t) => {
49+
const testFn = testMeta ? test.meta(testMeta) : test;
50+
51+
testFn(`${component}: test with axe #${index}`, async (t) => {
4852
await a11yCheck(t, a11yCheckConfig, selector, optionConfiguration);
4953
}).before(async (t) => {
5054
await createWidget(

e2e/testcafe-devextreme/helpers/safeSizeTest.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,19 @@ const decorateTestCafeAfter = (
5353
});
5454
};
5555

56+
interface SafeSizeTestOptions {
57+
meta?: Record<string, string | boolean>;
58+
}
59+
5660
const safeSizeTest = (
5761
name: string,
5862
testFunction: TestCafeFn,
5963
size: BrowserSizeType = DEFAULT_BROWSER_SIZE as BrowserSizeType,
64+
options?: SafeSizeTestOptions,
6065
): TestFn => {
61-
const testCafeTest = test(name, testFunction);
66+
const testCafeTest = options?.meta
67+
? test.meta(options.meta)(name, testFunction)
68+
: test(name, testFunction);
6269

6370
decorateTestCafeBefore(testCafeTest, size);
6471
decorateTestCafeAfter(testCafeTest);

e2e/testcafe-devextreme/helpers/testPageUtils.ts

Lines changed: 246 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export async function clearTestPage(testController: TestController): Promise<voi
1616
const widgetNames = $widgetElement.data().dxComponents;
1717
widgetNames?.forEach((name) => {
1818
if ($widgetElement.hasClass('dx-widget')) {
19-
// @ts-expect-error ts-erroe
19+
// @ts-expect-error ts-error
2020
$widgetElement[name]?.('dispose');
2121
}
2222
});
@@ -51,18 +51,262 @@ export async function clearTestPage(testController: TestController): Promise<voi
5151
}
5252

5353
export async function loadAxeCore(t: TestController): Promise<void> {
54-
await t.eval(() => new Promise<void>((resolve, reject) => {
54+
const loadAxeCoreFn = ClientFunction(() => new Promise<void>((resolve, reject) => {
5555
// @ts-expect-error ts-error
5656
if (window.axe) {
5757
resolve();
5858
return;
5959
}
6060

6161
const script = document.createElement('script');
62+
script.id = 'axe-core-script';
6263
script.src = '../../../node_modules/axe-core/axe.min.js';
6364
// @ts-expect-error ts-error
6465
script.onload = resolve;
6566
script.onerror = reject;
6667
document.head.appendChild(script);
6768
}));
69+
70+
await loadAxeCoreFn.with({ boundTestRun: t })();
71+
}
72+
73+
export async function loadQuill(t: TestController): Promise<void> {
74+
const loadQuillFn = ClientFunction(() => new Promise<void>((resolve, reject) => {
75+
// @ts-expect-error ts-error
76+
if (window.Quill) {
77+
resolve();
78+
return;
79+
}
80+
81+
const script = document.createElement('script');
82+
script.id = 'dx-quill-script';
83+
script.src = '../../../packages/devextreme/artifacts/js/dx-quill.min.js';
84+
// @ts-expect-error ts-error
85+
script.onload = resolve;
86+
script.onerror = reject;
87+
document.head.prepend(script);
88+
}));
89+
90+
await loadQuillFn.with({ boundTestRun: t })();
91+
}
92+
93+
export async function loadGantt(t: TestController): Promise<void> {
94+
const loadGanttFn = ClientFunction(() => new Promise<void>((resolve, reject) => {
95+
// @ts-expect-error ts-error
96+
if (window.DevExpress?.ui?.dxGantt) {
97+
resolve();
98+
return;
99+
}
100+
101+
const script = document.createElement('script');
102+
script.id = 'dx-gantt-script';
103+
script.src = '../../../packages/devextreme/artifacts/js/dx-gantt.min.js';
104+
// @ts-expect-error ts-error
105+
script.onload = resolve;
106+
script.onerror = reject;
107+
document.head.appendChild(script);
108+
}));
109+
110+
await loadGanttFn.with({ boundTestRun: t })();
111+
}
112+
113+
export async function loadAspNetData(t: TestController): Promise<void> {
114+
const loadAspNetDataFn = ClientFunction(() => new Promise<void>((resolve, reject) => {
115+
// @ts-expect-error ts-error
116+
if (window.DevExpress?.data?.AspNet) {
117+
resolve();
118+
return;
119+
}
120+
121+
const script = document.createElement('script');
122+
script.id = 'dx-aspnet-data-script';
123+
script.src = '../../../packages/devextreme/artifacts/js/dx.aspnet.data.js';
124+
// @ts-expect-error ts-error
125+
script.onload = resolve;
126+
script.onerror = reject;
127+
document.head.appendChild(script);
128+
}));
129+
130+
await loadAspNetDataFn.with({ boundTestRun: t })();
131+
}
132+
133+
export async function loadDevExtreme(t: TestController): Promise<void> {
134+
const loadDevExtremeFn = ClientFunction(() => new Promise<void>((resolve, reject) => {
135+
// @ts-expect-error ts-error
136+
if (window.DevExpress?.ui?.dxCalendar) {
137+
resolve();
138+
return;
139+
}
140+
141+
const script = document.createElement('script');
142+
script.id = 'dx-all-script';
143+
script.src = '../../../packages/devextreme/artifacts/js/dx.all.js';
144+
// @ts-expect-error ts-error
145+
script.onload = resolve;
146+
script.onerror = reject;
147+
document.head.appendChild(script);
148+
}));
149+
150+
await loadDevExtremeFn.with({ boundTestRun: t })();
68151
}
152+
153+
export async function removeScript(t: TestController, scriptId: string): Promise<void> {
154+
await ClientFunction((id: string) => {
155+
const script = document.getElementById(id);
156+
if (script) {
157+
script.remove();
158+
}
159+
}).with({ boundTestRun: t })(scriptId);
160+
}
161+
162+
// interface LoadOptions {
163+
// basePath?: string;
164+
// checkExists?: string;
165+
// }
166+
167+
// // async function loadResources(
168+
// // t: TestController,
169+
// // urls: string[],
170+
// // type: 'script' | 'style',
171+
// // options?: LoadOptions,
172+
// // ): Promise<void> {
173+
// // await t.eval(
174+
// // ({
175+
// // urls: urlList, type: resourceType, basePath, checkExists,
176+
// // }) => new Promise<void>((resolve, reject) => {
177+
// // if (!urlList.length) {
178+
// // resolve();
179+
// // return;
180+
// // }
181+
182+
// // let remaining = urlList.length;
183+
184+
// // const handleLoad = () => {
185+
// // remaining -= 1;
186+
// // if (remaining === 0) resolve();
187+
// // };
188+
189+
// // const handleError = (err: Event) => reject(err);
190+
191+
// // const createResource = (url: string): void => {
192+
// // const fullUrl = basePath ? `${basePath}${url}` : url;
193+
194+
// // if (resourceType === 'script') {
195+
// // if (document.querySelector(`script[src*="${fullUrl}"]`) || (checkExists && (window as any)[checkExists])) {
196+
// // handleLoad();
197+
// // return;
198+
// // }
199+
200+
// // if (document.querySelector(`script[src*="${fullUrl}"]`)) {
201+
// // handleLoad();
202+
// // return;
203+
// // }
204+
// // const el = document.createElement('script');
205+
// // el.src = fullUrl;
206+
// // el.async = true;
207+
// // el.onload = () => setTimeout(handleLoad, 0);
208+
// // el.onerror = handleError;
209+
// // document.head.appendChild(el);
210+
// // } else {
211+
// // if (document.querySelector(`link[href*="${fullUrl}"]`)) {
212+
// // handleLoad();
213+
// // return;
214+
// // }
215+
// // const el = document.createElement('link');
216+
// // el.rel = 'stylesheet';
217+
// // el.type = 'text/css';
218+
// // el.href = fullUrl;
219+
// // el.onload = () => setTimeout(handleLoad, 0);
220+
// // el.onerror = handleError;
221+
// // document.head.appendChild(el);
222+
// // }
223+
// // };
224+
225+
// // urls.forEach(createResource);
226+
// // }),
227+
// // {
228+
// // dependencies: {
229+
// // urls,
230+
// // type,
231+
// // basePath: options?.basePath,
232+
// // checkExists: options?.checkExists,
233+
// // },
234+
// // },
235+
// // );
236+
// // }
237+
238+
// async function loadResource(
239+
// t: TestController,
240+
// url: string,
241+
// type: 'script' | 'style',
242+
// options?: LoadOptions,
243+
// ): Promise<void> {
244+
// await t.eval(
245+
// ({
246+
// // eslint-disable-next-line @typescript-eslint/no-shadow
247+
// url, type, basePath, checkExists,
248+
// }) => new Promise<void>((resolve, reject) => {
249+
// const fullUrl = basePath ? `${basePath}${url}` : url;
250+
251+
// if (type === 'script') {
252+
// if (document.querySelector(`script[src*="${fullUrl}"]`) || (checkExists && (window as any)[checkExists])) {
253+
// resolve();
254+
// return;
255+
// }
256+
257+
// const el = document.createElement('script');
258+
// el.src = fullUrl;
259+
// el.async = true;
260+
// el.onload = () => {
261+
// if (checkExists) {
262+
// const interval = setInterval(() => {
263+
// if ((window as any)[checkExists]) {
264+
// clearInterval(interval);
265+
// resolve();
266+
// }
267+
// }, 10);
268+
// } else {
269+
// resolve();
270+
// }
271+
// };
272+
// el.onerror = reject;
273+
// document.head.appendChild(el);
274+
// } else {
275+
// if (document.querySelector(`link[href*="${fullUrl}"]`)) {
276+
// resolve();
277+
// return;
278+
// }
279+
280+
// const el = document.createElement('link');
281+
// el.rel = 'stylesheet';
282+
// el.type = 'text/css';
283+
// el.href = fullUrl;
284+
// // @ts-expect-error ts-error
285+
// el.onload = resolve;
286+
// el.onerror = reject;
287+
// document.head.appendChild(el);
288+
// }
289+
// }),
290+
// {
291+
// dependencies: {
292+
// url, type, basePath: options?.basePath, checkExists: options?.checkExists,
293+
// },
294+
// },
295+
// );
296+
// }
297+
298+
// export async function loadScripts(
299+
// t: TestController,
300+
// script: string,
301+
// options?: LoadOptions,
302+
// ): Promise<void> {
303+
// await loadResource(t, script, 'script', options);
304+
// }
305+
306+
// export async function loadStyles(
307+
// t: TestController,
308+
// style: string,
309+
// options?: LoadOptions,
310+
// ): Promise<void> {
311+
// await loadResource(t, style, 'style', options);
312+
// }

0 commit comments

Comments
 (0)