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
71 changes: 71 additions & 0 deletions e2e/testcafe-devextreme/eslint-rules/no-is-ready-without-expect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* ESLint rule: no-is-ready-without-expect
*
* Disallows calling `.isReady()` outside of `t.expect()`.
*
* Correct:
* await t.expect(dataGrid.isReady()).ok()
* or
* await t
* .expect(dataGrid.isReady())
* .ok()
*
* Incorrect:
* await dataGrid.isReady()
* dataGrid.isReady()
* const ready = await dataGrid.isReady()
*/

/* eslint-disable spellcheck/spell-checker */
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Disallow calling .isReady() outside of t.expect()',
},
messages: {
noIsReadyWithoutExpect:
'isReady() must be used inside t.expect(), e.g.: await t.expect(widget.isReady()).ok()',
},
schema: [],
},
create(context) {
return {
CallExpression(node) {
const { callee } = node;

if (
callee.type !== 'MemberExpression'
|| callee.property.type !== 'Identifier'
|| callee.property.name !== 'isReady'
) {
return;
}

// Walk up to find if this call is an argument of .expect()
let current = node;
let parent = current.parent;

while(parent) {
if (
parent.type === 'CallExpression'
&& parent.callee.type === 'MemberExpression'
&& parent.callee.property.type === 'Identifier'
&& parent.callee.property.name === 'expect'
) {
// isReady() is inside .expect() — allowed
return;
}

current = parent;
parent = current.parent;
}

context.report({
node,
messageId: 'noIsReadyWithoutExpect',
});
},
};
},
};
20 changes: 20 additions & 0 deletions e2e/testcafe-devextreme/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import spellCheckConfig from 'eslint-config-devextreme/spell-check';
import typescriptConfig from 'eslint-config-devextreme/typescript';
import testcafeConfig from 'eslint-config-devextreme/testcafe';

import noIsReadyWithoutExpect from './eslint-rules/no-is-ready-without-expect.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compatibility = new FlatCompatibility({
Expand Down Expand Up @@ -258,4 +260,22 @@ export default [
'@typescript-eslint/no-empty-object-type': 'off',
}
},
{
files: [
'tests/dataGrid/**/*.ts',
'tests/cardView/**/*.ts',
'tests/common/treeList/**/*.ts',
'tests/common/filterBuilder/**/*.ts',
],
plugins: {
'local': {
rules: {
'no-is-ready-without-expect': noIsReadyWithoutExpect,
},
},
},
rules: {
'local/no-is-ready-without-expect': 'error',
},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ const config = {

test('should show default values in popup fields after onInitNewCard', async (t) => {
const cardView = new CardView(CARD_VIEW_SELECTOR);
await cardView.isReady();
await t
.expect(cardView.isReady())
.ok();

await t.click(cardView.getToolbar().getAddButton().element);
await cardView.isReady();
await t
.expect(cardView.isReady())
.ok();

const popup = cardView.getEditingPopup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ fixture.disablePageReloads`Filter Builder Scrolling Test`
test('FilterBuilder - The field drop-down closes with the page scroll', async (t) => {
const filterBuilder = new FilterBuilder('#container');

await filterBuilder.isReady();
await t
.expect(filterBuilder.isReady())
.ok();

await t
.click(filterBuilder.getItem('operation'))
Expand Down
4 changes: 3 additions & 1 deletion e2e/testcafe-devextreme/tests/common/treeList/adaptiveRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ fixture.disablePageReloads`Adaptive Row`

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

const adaptiveButton = treeList.getAdaptiveButton();
await t.expect(adaptiveButton.exists).ok();
Expand Down
4 changes: 3 additions & 1 deletion e2e/testcafe-devextreme/tests/common/treeList/rowDragging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ test('TreeList - Expand/collapse mechanism breaks after dragging action in the s
test(`TreeList - The W1025 warning occurs when dragging a row (height: ${height ?? 'not set'}). (T1280519)`, async (t) => {
const treeList = new TreeList('#container');

await treeList.isReady();
await t
.expect(treeList.isReady())
.ok();

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

Expand Down
7 changes: 5 additions & 2 deletions e2e/testcafe-devextreme/tests/common/treeList/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ fixture.disablePageReloads`Toasts in TreeList`
test('Toast should be visible after calling and should be not visible after default display time', async (t) => {
const treeList = new TreeList('#container');
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
await treeList.isReady();
await t
.expect(treeList.isReady())
.ok();

await treeList.apiShowErrorToast();
await t.expect(treeList.getToast().exists).ok();

Expand All @@ -21,5 +24,5 @@ test('Toast should be visible after calling and should be not visible after defa
.ok(compareResults.errorMessages());
await t.expect(treeList.getToast().exists).notOk();
}).before(async () => {
createWidget('dxTreeList', {});
await createWidget('dxTreeList', {});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ fixture.disablePageReloads`Adaptivity.Functional`

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

const adaptiveButton = dataGrid.getAdaptiveButton();
await t.expect(adaptiveButton.exists).ok();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,10 @@ test(

test('ColumnChooser should receive and render custom texts', async (t) => {
const dataGrid = new DataGrid('#container');
await dataGrid.isReady();
await t
.expect(dataGrid.isReady())
.ok();

const columnChooserBtn = dataGrid.getColumnChooserButton();
await t.click(columnChooserBtn);
const columnChooser = dataGrid.getColumnChooser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ test('DataGrid cell with checkbox should have outline on focused', async (t) =>

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ test('Filter Row\'s Reset button does not work after a custom filter is set in F
const dataGrid = new DataGrid('#container');
const filterCell = dataGrid.getFilterCell(0);

await dataGrid.isReady();
await t
.expect(dataGrid.isReady())
.ok();

await t
.expect(dataGrid.dataRows.count)
Expand Down Expand Up @@ -107,7 +109,9 @@ test('DataGrid - filter row\'s search-box\'s aria-label should be customizable v
const dataGrid = new DataGrid('#container');
const filterCell = dataGrid.getFilterCell(0);

await dataGrid.isReady();
await t
.expect(dataGrid.isReady())
.ok();

const ariaLabel = await filterCell.menuButton.getAttribute('aria-label');

Expand Down Expand Up @@ -138,7 +142,9 @@ test('DataGrid - NVDA reads filter menu items as "Search box 1 of 8" (T1290386)'
const dataGrid = new DataGrid('#container');
const filterCell = dataGrid.getFilterCell(0);

await dataGrid.isReady();
await t
.expect(dataGrid.isReady())
.ok();

await t
.expect(filterCell.menuButton.getAttribute('aria-label'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ test('DataGrid - The `between` filter dropdown sticks to the viewport edge durin
const dataGrid = new DataGrid('#container');
const filterCell = dataGrid.getFilterCell(0);

await dataGrid.isReady();
await t
.expect(dataGrid.isReady())
.ok();

await t
.click(filterCell.menuButton)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ test(
async (t) => {
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);

await dataGrid.isReady();
await t
.expect(dataGrid.isReady())
.ok();
await dataGrid.apiColumnOption('group', 'calculateGroupValue', () => 'ALL');

await t
Expand Down Expand Up @@ -57,7 +59,9 @@ test(
async (t) => {
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);

await dataGrid.isReady();
await t
.expect(dataGrid.isReady())
.ok();
await dataGrid.apiColumnOption('group', 'calculateGroupValue', () => 'ALL');

await t
Expand Down Expand Up @@ -100,7 +104,9 @@ test(
async (t) => {
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);

await dataGrid.isReady();
await t
.expect(dataGrid.isReady())
.ok();
await dataGrid.apiColumnOption('group', 'calculateGroupValue', () => 'ALL');

await t
Expand Down Expand Up @@ -154,7 +160,9 @@ test(
async (t) => {
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);

await dataGrid.isReady();
await t
.expect(dataGrid.isReady())
.ok();
await dataGrid.apiColumnOption('group', 'calculateGroupValue', () => 'ALL');

await t
Expand Down Expand Up @@ -204,7 +212,9 @@ test(
test('Should not reset sorting parameters after calculateGroupValue update [T1298901]', async (t) => {
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);

await dataGrid.isReady();
await t
.expect(dataGrid.isReady())
.ok();

await t
.expect(await dataGrid.apiColumnOption('A', 'sortOrder'))
Expand Down Expand Up @@ -237,7 +247,9 @@ test('Should not reset sorting parameters after calculateGroupValue update [T129
test('Should not reset multiple sorting parameters after calculateGroupValue update [T1298901]', async (t) => {
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);

await dataGrid.isReady();
await t
.expect(dataGrid.isReady())
.ok();

await t
.expect(await dataGrid.apiColumnOption('A', 'sortOrder'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ test('DataGrid – Header filters show "No data to display" when "not and" or "n
const headerFilter = new HeaderFilter();
const listCount = headerFilter.getList().getItems();

await dataGrid.isReady();
await t
.expect(dataGrid.isReady())
.ok();
await t.click(headerFilterButton);

await t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,9 @@ const verifyGridStyles = async (t: TestController, dataGrid: DataGrid, {
const functionalTest = (matrixOptions: MatrixOptions) => {
test(`Should have correct applied styles with ${getTestParams(matrixOptions)}`, async (t) => {
const dataGrid = new DataGrid(`#${SELECTORS.gridContainer}`);
await dataGrid.isReady();
await t
.expect(dataGrid.isReady())
.ok();

await verifyGridStyles(t, dataGrid, matrixOptions);

Expand Down
7 changes: 5 additions & 2 deletions e2e/testcafe-devextreme/tests/dataGrid/common/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ fixture.disablePageReloads`Toasts in DataGrid`.page(
test('Toast should be visible after calling and should be not visible after default display time', async (t) => {
const dataGrid = new DataGrid('#container');
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
await dataGrid.isReady();
await t
.expect(dataGrid.isReady())
.ok();

await dataGrid.apiShowErrorToast();
await t.expect(dataGrid.getToast().exists).ok();
await testScreenshot(t, takeScreenshot, 'ai-column__toast__at-the-right-position.png', { element: dataGrid.element });
Expand All @@ -20,5 +23,5 @@ test('Toast should be visible after calling and should be not visible after defa
.ok(compareResults.errorMessages());
await t.expect(dataGrid.getToast().exists).notOk();
}).before(async () => {
createWidget('dxDataGrid', {});
await createWidget('dxDataGrid', {});
});
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ test('DataGrid - Group row content is scrolled if repaintChangesOnly is enabled
const groupRow = dataGrid.getGroupRow(0);
const groupPanelToggle = groupRow.getCell(0).element;

await dataGrid.isReady();
await t
.expect(dataGrid.isReady())
.ok();

await t
.click(groupPanelToggle);
Expand Down
Loading