Skip to content

Commit bf1f4b7

Browse files
RaushenRaushen
authored andcommitted
Fix unstable tests (DevExpress#33267)
1 parent f9364f8 commit bf1f4b7

17 files changed

Lines changed: 163 additions & 24 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* ESLint rule: no-is-ready-without-expect
3+
*
4+
* Disallows calling `.isReady()` outside of `t.expect()`.
5+
*
6+
* Correct:
7+
* await t.expect(dataGrid.isReady()).ok()
8+
* or
9+
* await t
10+
* .expect(dataGrid.isReady())
11+
* .ok()
12+
*
13+
* Incorrect:
14+
* await dataGrid.isReady()
15+
* dataGrid.isReady()
16+
* const ready = await dataGrid.isReady()
17+
*/
18+
19+
/* eslint-disable spellcheck/spell-checker */
20+
module.exports = {
21+
meta: {
22+
type: 'problem',
23+
docs: {
24+
description: 'Disallow calling .isReady() outside of t.expect()',
25+
},
26+
messages: {
27+
noIsReadyWithoutExpect:
28+
'isReady() must be used inside t.expect(), e.g.: await t.expect(widget.isReady()).ok()',
29+
},
30+
schema: [],
31+
},
32+
create(context) {
33+
return {
34+
CallExpression(node) {
35+
const { callee } = node;
36+
37+
if (
38+
callee.type !== 'MemberExpression'
39+
|| callee.property.type !== 'Identifier'
40+
|| callee.property.name !== 'isReady'
41+
) {
42+
return;
43+
}
44+
45+
// Walk up to find if this call is an argument of .expect()
46+
let current = node;
47+
let parent = current.parent;
48+
49+
while(parent) {
50+
if (
51+
parent.type === 'CallExpression'
52+
&& parent.callee.type === 'MemberExpression'
53+
&& parent.callee.property.type === 'Identifier'
54+
&& parent.callee.property.name === 'expect'
55+
) {
56+
// isReady() is inside .expect() — allowed
57+
return;
58+
}
59+
60+
current = parent;
61+
parent = current.parent;
62+
}
63+
64+
context.report({
65+
node,
66+
messageId: 'noIsReadyWithoutExpect',
67+
});
68+
},
69+
};
70+
},
71+
};

e2e/testcafe-devextreme/eslint.config.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { FlatCompat as FlatCompatibility } from '@eslint/eslintrc';
1010
import stylistic from '@stylistic/eslint-plugin';
1111
import { changeRulesToStylistic } from 'eslint-migration-utils';
1212

13+
import noIsReadyWithoutExpect from './eslint-rules/no-is-ready-without-expect.js';
14+
1315
const __filename = fileURLToPath(import.meta.url);
1416
const __dirname = path.dirname(__filename);
1517
const compatibility = new FlatCompatibility({
@@ -255,4 +257,22 @@ export default [
255257
'@typescript-eslint/no-empty-object-type': 'off',
256258
}
257259
},
260+
{
261+
files: [
262+
'tests/dataGrid/**/*.ts',
263+
'tests/cardView/**/*.ts',
264+
'tests/common/treeList/**/*.ts',
265+
'tests/common/filterBuilder/**/*.ts',
266+
],
267+
plugins: {
268+
'local': {
269+
rules: {
270+
'no-is-ready-without-expect': noIsReadyWithoutExpect,
271+
},
272+
},
273+
},
274+
rules: {
275+
'local/no-is-ready-without-expect': 'error',
276+
},
277+
},
258278
];

e2e/testcafe-devextreme/tests/cardView/editing/editing.functional.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@ const config = {
3030

3131
test('should show default values in popup fields after onInitNewCard', async (t) => {
3232
const cardView = new CardView(CARD_VIEW_SELECTOR);
33-
await cardView.isReady();
33+
await t
34+
.expect(cardView.isReady())
35+
.ok();
3436

3537
await t.click(cardView.getToolbar().getAddButton().element);
36-
await cardView.isReady();
38+
await t
39+
.expect(cardView.isReady())
40+
.ok();
3741

3842
const popup = cardView.getEditingPopup();
3943

e2e/testcafe-devextreme/tests/common/filterBuilder/filterBuilderScrolling.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ fixture.disablePageReloads`Filter Builder Scrolling Test`
1111
test('FilterBuilder - The field drop-down closes with the page scroll', async (t) => {
1212
const filterBuilder = new FilterBuilder('#container');
1313

14-
await filterBuilder.isReady();
14+
await t
15+
.expect(filterBuilder.isReady())
16+
.ok();
1517

1618
await t
1719
.click(filterBuilder.getItem('operation'))

e2e/testcafe-devextreme/tests/common/treeList/adaptiveRow.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ fixture.disablePageReloads`Adaptive Row`
77

88
test.meta({ browserSize: [400, 400] })('Should be shown and hidden when the window is resized', async (t) => {
99
const treeList = new TreeList('#container');
10-
await treeList.isReady();
10+
await t
11+
.expect(treeList.isReady())
12+
.ok();
1113

1214
const adaptiveButton = treeList.getAdaptiveButton();
1315
await t.expect(adaptiveButton.exists).ok();

e2e/testcafe-devextreme/tests/common/treeList/rowDragging.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ test('TreeList - Expand/collapse mechanism breaks after dragging action in the s
6767
test(`TreeList - The W1025 warning occurs when dragging a row (height: ${height ?? 'not set'}). (T1280519)`, async (t) => {
6868
const treeList = new TreeList('#container');
6969

70-
await treeList.isReady();
70+
await t
71+
.expect(treeList.isReady())
72+
.ok();
7173

7274
await treeList.moveRow(0, 10, 10, true);
7375

e2e/testcafe-devextreme/tests/common/treeList/toast.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ fixture.disablePageReloads`Toasts in TreeList`
1010
test('Toast should be visible after calling and should be not visible after default display time', async (t) => {
1111
const treeList = new TreeList('#container');
1212
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
13-
await treeList.isReady();
13+
await t
14+
.expect(treeList.isReady())
15+
.ok();
16+
1417
await treeList.apiShowErrorToast();
1518
await t.expect(treeList.getToast().exists).ok();
1619

@@ -21,5 +24,5 @@ test('Toast should be visible after calling and should be not visible after defa
2124
.ok(compareResults.errorMessages());
2225
await t.expect(treeList.getToast().exists).notOk();
2326
}).before(async () => {
24-
createWidget('dxTreeList', {});
27+
await createWidget('dxTreeList', {});
2528
});

e2e/testcafe-devextreme/tests/dataGrid/common/adaptivity/functional.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ fixture.disablePageReloads`Adaptivity.Functional`
77

88
test.meta({ browserSize: [400, 400] })('Should be shown and hidden when the window is resized', async (t) => {
99
const dataGrid = new DataGrid('#container');
10-
await dataGrid.isReady();
10+
await t
11+
.expect(dataGrid.isReady())
12+
.ok();
1113

1214
const adaptiveButton = dataGrid.getAdaptiveButton();
1315
await t.expect(adaptiveButton.exists).ok();

e2e/testcafe-devextreme/tests/dataGrid/common/columnChooser.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,10 @@ test(
277277

278278
test('ColumnChooser should receive and render custom texts', async (t) => {
279279
const dataGrid = new DataGrid('#container');
280-
await dataGrid.isReady();
280+
await t
281+
.expect(dataGrid.isReady())
282+
.ok();
283+
281284
const columnChooserBtn = dataGrid.getColumnChooserButton();
282285
await t.click(columnChooserBtn);
283286
const columnChooser = dataGrid.getColumnChooser();

e2e/testcafe-devextreme/tests/dataGrid/common/editing/visual.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ test('DataGrid cell with checkbox should have outline on focused', async (t) =>
305305

306306
const scrollTo = async (y) => {
307307
await dataGrid.scrollTo(t, { y });
308+
// eslint-disable-next-line local/no-is-ready-without-expect
308309
return dataGrid.isReady();
309310
};
310311

0 commit comments

Comments
 (0)