Skip to content

Commit 667c349

Browse files
fix qunit tests
1 parent 61e4edc commit 667c349

17 files changed

Lines changed: 404 additions & 212 deletions

File tree

e2e/testcafe-devextreme/tests/accessibility/dataGrid/fixedColumns.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,12 @@ test('Accessibility: Scrollable should have focusable element when navigate out
160160

161161
test('Accessibility: Scrollable should have focusable when fixed on the right side columns are focused', async (t) => {
162162
const dataGrid = new DataGrid('#container');
163+
const targetCell = dataGrid.getFixedDataCell(0, COLUMNS_LENGTH - 1);
163164

164-
// focus through headers
165-
await pressKey(t, 'tab', COLUMNS_LENGTH);
166-
167-
// focus through data row till last cell (which is fixed)
168-
await pressKey(t, 'tab', COLUMNS_LENGTH);
165+
await t.click(targetCell.element);
169166

170167
await t
171-
.expect(dataGrid.getFixedDataCell(0, COLUMNS_LENGTH - 1).isFocused)
168+
.expect(targetCell.element.focused)
172169
.ok();
173170

174171
await a11yCheck(t);

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

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,53 @@
1+
import { Selector } from 'testcafe';
12
import CardView from 'devextreme-testcafe-models/cardView';
23
import url from '../../../helpers/getPageUrl';
34
import { createWidget } from '../../../helpers/createWidget';
45
import { getCardFieldCaptions } from '../helpers/cardUtils';
56

7+
const COLUMN_CHOOSER_DND_TIMEOUT = 3000;
8+
const SORTABLE_DRAGGING_SELECTOR = '.dx-sortable-dragging';
9+
610
fixture`CardView - ColumnChooser.Functional`
711
.page(url(__dirname, '../../container.html'));
812

13+
const waitForDragEnd = async (t: TestController, cardView: CardView): Promise<void> => {
14+
await t
15+
.expect(Selector(SORTABLE_DRAGGING_SELECTOR).exists)
16+
.notOk({ timeout: COLUMN_CHOOSER_DND_TIMEOUT })
17+
.expect(cardView.isReady())
18+
.ok({ timeout: COLUMN_CHOOSER_DND_TIMEOUT });
19+
};
20+
21+
const dragHeaderColumnToColumnChooser = async (
22+
t: TestController,
23+
cardView: CardView,
24+
columnIndex: number,
25+
): Promise<void> => {
26+
await t.dragToElement(
27+
cardView.getHeaderPanel().getHeaderItem(columnIndex).element,
28+
cardView.getColumnChooser().content,
29+
{
30+
speed: 0.5,
31+
},
32+
);
33+
await waitForDragEnd(t, cardView);
34+
};
35+
36+
const dragColumnChooserColumnToHeaderPanel = async (
37+
t: TestController,
38+
cardView: CardView,
39+
columnIndex: number,
40+
): Promise<void> => {
41+
await t.dragToElement(
42+
cardView.getColumnChooser().getColumn(columnIndex),
43+
cardView.getHeaderPanel().element,
44+
{
45+
speed: 0.5,
46+
},
47+
);
48+
await waitForDragEnd(t, cardView);
49+
};
50+
951
function testsFactory(testModel: {
1052
name: string;
1153
hideFirstColumn: (t: TestController, cardView: CardView) => Promise<void>;
@@ -99,16 +141,10 @@ testsFactory({
99141
},
100142
},
101143
async hideFirstColumn(t: TestController, cardView: CardView) {
102-
await t.dragToElement(
103-
cardView.getHeaderPanel().getHeaderItem(0).element,
104-
cardView.getColumnChooser().content,
105-
);
144+
await dragHeaderColumnToColumnChooser(t, cardView, 0);
106145
},
107146
async showFirstColumn(t: TestController, cardView: CardView) {
108-
await t.dragToElement(
109-
cardView.getColumnChooser().getColumn(0),
110-
cardView.getHeaderPanel().element,
111-
);
147+
await dragColumnChooserColumnToHeaderPanel(t, cardView, 0);
112148
},
113149
async assertFirstColumnVisible(t: TestController, cardView: CardView) {
114150
await t.expect(
@@ -222,18 +258,12 @@ test('cards should update when column is hidden via column chooser (dragAndDrop
222258

223259
await cardView.apiShowColumnChooser();
224260

225-
await t.dragToElement(
226-
cardView.getHeaderPanel().getHeaderItem(0).element,
227-
cardView.getColumnChooser().content,
228-
);
261+
await dragHeaderColumnToColumnChooser(t, cardView, 0);
229262

230263
const captionsAfterHide = await getCardFieldCaptions(t, cardView, 2);
231264
await t.expect(captionsAfterHide).eql(['B', 'C']);
232265

233-
await t.dragToElement(
234-
cardView.getColumnChooser().getColumn(0),
235-
cardView.getHeaderPanel().element,
236-
);
266+
await dragColumnChooserColumnToHeaderPanel(t, cardView, 0);
237267

238268
const captionsAfterShow = await getCardFieldCaptions(t, cardView, 3);
239269
await t.expect(captionsAfterShow).eql(['A', 'B', 'C']);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@ test('cards should update when columns are reordered (T1324855)', async (t) => {
318318

319319
await dragToHeaderPanel(t, cardView, firstHeader, 2);
320320

321-
await t.expect(cardView.getHeaders().getHeaderItemNth(0).element.innerText).notEql('A');
321+
await t
322+
.expect(cardView.getHeaders().getHeaderItemNth(0).element.innerText)
323+
.notEql('A', { timeout: 3000 });
322324

323325
const headerCaptions: string[] = [];
324326
const headersCount = await cardView.getHeaders().getHeaderItemsElements().count;

e2e/testcafe-devextreme/tests/cardView/columnSortable/utils.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import { ClientFunction } from 'testcafe';
1+
import { ClientFunction, Selector } from 'testcafe';
22
import CardView from 'devextreme-testcafe-models/cardView';
33
import TreeView from 'devextreme-testcafe-models/treeView';
44

5+
const DRAG_ASSERTION_TIMEOUT = 3000;
6+
const HEADER_DROP_OFFSET_Y = 5;
7+
58
export const SELECTORS = {
69
dragging: '.dx-sortable-dragging',
710
treeView: '.dx-cardview-column-chooser .dx-treeview',
@@ -80,19 +83,31 @@ export const dragToHeaderPanel = async (
8083
await t.dragToElement(
8184
columnElement,
8285
insertBeforeColumn,
83-
{ destinationOffsetX: +5, destinationOffsetY: -20, speed: 0.5 },
86+
{
87+
destinationOffsetX: 5,
88+
destinationOffsetY: HEADER_DROP_OFFSET_Y,
89+
speed: 0.5,
90+
},
8491
);
8592
} else {
8693
const insertAfterColumn = headers.getHeaderItemNth(columnsNum - 1).element;
8794

8895
await t.dragToElement(
8996
columnElement,
9097
insertAfterColumn,
91-
{ destinationOffsetX: -5, destinationOffsetY: -20, speed: 0.5 },
98+
{
99+
destinationOffsetX: -5,
100+
destinationOffsetY: HEADER_DROP_OFFSET_Y,
101+
speed: 0.5,
102+
},
92103
);
93104
}
94105

95-
await t.wait(300);
106+
await t
107+
.expect(Selector(SELECTORS.dragging).exists)
108+
.notOk({ timeout: DRAG_ASSERTION_TIMEOUT })
109+
.expect(cardView.isReady())
110+
.ok({ timeout: DRAG_ASSERTION_TIMEOUT });
96111
};
97112

98113
export const dragToColumnChooser = async (
@@ -139,8 +154,8 @@ export const expectColumns = async (
139154

140155
await t
141156
.expect(column.exists)
142-
.ok()
157+
.ok({ timeout: DRAG_ASSERTION_TIMEOUT })
143158
.expect(column.innerText)
144-
.eql(adjustedExpectedColumns[i]);
159+
.eql(adjustedExpectedColumns[i], { timeout: DRAG_ASSERTION_TIMEOUT });
145160
}
146161
};

e2e/testcafe-devextreme/tests/cardView/helpers/cardUtils.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
import CardView from 'devextreme-testcafe-models/cardView';
22

3+
const FIELD_CAPTION_SELECTOR = '.dx-cardview-field-caption';
4+
const CARD_FIELD_CAPTION_TIMEOUT = 3000;
5+
36
const getCardFieldCaptions = async (
47
t: TestController,
58
cardView: CardView,
69
expectedCount: number,
710
cardIndex = 0,
811
): Promise<string[]> => {
912
const card = cardView.getCard(cardIndex);
10-
const captions = await card.getCaptions();
1113

12-
await t.expect(captions.length).eql(expectedCount);
14+
await t
15+
.expect(card.element.find(FIELD_CAPTION_SELECTOR).count)
16+
.eql(expectedCount, { timeout: CARD_FIELD_CAPTION_TIMEOUT });
17+
18+
const captions = await card.getCaptions();
1319

1420
return captions;
1521
};

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

Lines changed: 72 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
22
import DataGrid from 'devextreme-testcafe-models/dataGrid';
3+
import { ClientFunction } from 'testcafe';
34
import { createWidget } from '../../../../helpers/createWidget';
45
import url from '../../../../helpers/getPageUrl';
56
import { getData } from '../../helpers/generateDataSourceData';
@@ -8,6 +9,47 @@ import { testScreenshot } from '../../../../helpers/themeUtils';
89
fixture`Keyboard Navigation.Visual`
910
.page(url(__dirname, '../../../container.html'));
1011

12+
const KEYBOARD_NAVIGATION_TIMEOUT = 3000;
13+
14+
const isKeyboardNavigationInProgress = ClientFunction(() => {
15+
const dataGrid = ($('#container') as any).dxDataGrid('instance');
16+
17+
return dataGrid
18+
.getController('keyboardNavigation')
19+
.navigationToCellInProgress();
20+
});
21+
22+
const focusDataCell = async (
23+
t: TestController,
24+
dataGrid: DataGrid,
25+
rowIndex: number,
26+
columnIndex: number,
27+
): Promise<void> => {
28+
const cell = dataGrid.getDataCell(rowIndex, columnIndex);
29+
30+
await dataGrid.apiFocus(cell.element);
31+
await t
32+
.expect(cell.element.focused)
33+
.ok({ timeout: KEYBOARD_NAVIGATION_TIMEOUT });
34+
};
35+
36+
const expectDataCellFocusState = async (
37+
t: TestController,
38+
dataGrid: DataGrid,
39+
rowIndex: number,
40+
columnIndex: number,
41+
): Promise<void> => {
42+
await t
43+
.expect(dataGrid.getDataCell(rowIndex, columnIndex).isFocused)
44+
.ok({ timeout: KEYBOARD_NAVIGATION_TIMEOUT });
45+
};
46+
47+
const waitForKeyboardNavigation = async (t: TestController): Promise<void> => {
48+
await t
49+
.expect(isKeyboardNavigationInProgress())
50+
.notOk({ timeout: KEYBOARD_NAVIGATION_TIMEOUT });
51+
};
52+
1153
// Quick navigation through grid cells via Home and End keys
1254
test('Focus the last cell in the row that contains focus when pressing the End key', async (t) => {
1355
// arrange
@@ -522,12 +564,11 @@ test('Navigate to last cell in the last row when virtual scrolling is enabled',
522564
.ok();
523565

524566
// act
525-
await t
526-
.click(dataGrid.getDataCell(0, 0).element)
527-
.pressKey('ctrl+end')
528-
.wait(100);
567+
await focusDataCell(t, dataGrid, 0, 0);
568+
await t.pressKey('ctrl+end');
569+
await waitForKeyboardNavigation(t);
529570

530-
await t.expect(dataGrid.getDataCell(199, 14).element.focused).ok();
571+
await expectDataCellFocusState(t, dataGrid, 199, 14);
531572
await testScreenshot(t, takeScreenshot, 'navigate_to_last_cell_in_last_row_when_virtual_scrolling_is_enabled.png', { element: dataGrid.element });
532573

533574
// assert
@@ -566,12 +607,11 @@ test('Navigate to first cell in the first row when virtual scrolling is enabled'
566607
await testScreenshot(t, takeScreenshot, 'navigate_to_first_cell_in_first_row_when_virtual_scrolling_is_enabled_1.png', { element: dataGrid.element });
567608

568609
// act
569-
await t
570-
.click(dataGrid.getDataCell(199, 14).element)
571-
.pressKey('ctrl+home')
572-
.wait(1000);
610+
await focusDataCell(t, dataGrid, 199, 14);
611+
await t.pressKey('ctrl+home');
612+
await waitForKeyboardNavigation(t);
573613

574-
await t.expect(dataGrid.getDataCell(0, 0).element.focused).ok();
614+
await expectDataCellFocusState(t, dataGrid, 0, 0);
575615
await testScreenshot(t, takeScreenshot, 'navigate_to_first_cell_in_first_row_when_virtual_scrolling_is_enabled_2.png', { element: dataGrid.element });
576616

577617
// assert
@@ -600,15 +640,12 @@ test('Navigate to last cell in the last row when virtual scrolling and columns a
600640
.ok();
601641

602642
// act
603-
await t
604-
.click(dataGrid.getDataCell(0, 0).element)
605-
.pressKey('ctrl+end')
606-
.wait(1000);
643+
await focusDataCell(t, dataGrid, 0, 0);
644+
await t.pressKey('ctrl+end');
645+
await waitForKeyboardNavigation(t);
607646

608647
// assert
609-
await t
610-
.expect(dataGrid.getDataCell(199, 34).element.focused)
611-
.ok();
648+
await expectDataCellFocusState(t, dataGrid, 199, 34);
612649

613650
await testScreenshot(t, takeScreenshot, 'navigate_to_last_cell_in_last_row_when_virtual_scrolling_and_columns_are_enabled.png', { element: dataGrid.element });
614651

@@ -645,15 +682,12 @@ test('Navigate to first cell in the first row when virtual scrolling and columns
645682
await testScreenshot(t, takeScreenshot, 'navigate_to_first_cell_in_first_row_when_virtual_scrolling_and_columns_are_enabled_1.png', { element: dataGrid.element });
646683

647684
// act
648-
await t
649-
.click(dataGrid.getDataCell(199, 34).element)
650-
.pressKey('ctrl+home')
651-
.wait(300);
685+
await focusDataCell(t, dataGrid, 199, 34);
686+
await t.pressKey('ctrl+home');
687+
await waitForKeyboardNavigation(t);
652688

653689
// assert
654-
await t
655-
.expect(dataGrid.getDataCell(0, 0).element.focused)
656-
.ok();
690+
await expectDataCellFocusState(t, dataGrid, 0, 0);
657691

658692
await testScreenshot(t, takeScreenshot, 'navigate_to_first_cell_in_first_row_when_virtual_scrolling_and_columns_are_enabled_2.png', { element: dataGrid.element });
659693

@@ -682,28 +716,25 @@ test('Navigate to first cell in the first row when virtual scrolling and columns
682716
.ok();
683717

684718
// act
685-
await t
686-
.click(dataGrid.getDataCell(0, 1).element)
687-
.pressKey('ctrl+end')
688-
.wait(1000);
719+
await focusDataCell(t, dataGrid, 0, 1);
720+
await t.pressKey('ctrl+end');
721+
await waitForKeyboardNavigation(t);
689722

690723
// assert
691-
await t
692-
.expect(dataGrid.getDataCell(199, 35).isFocused)
693-
.ok();
724+
await expectDataCellFocusState(t, dataGrid, 199, 35);
694725

695726
// act
696-
await t
697-
.click(dataGrid.getDataCell(199, 35).element)
698-
.pressKey('ctrl+home')
699-
.wait(1000);
727+
await focusDataCell(t, dataGrid, 199, 35);
728+
await t.pressKey('ctrl+home');
729+
await waitForKeyboardNavigation(t);
730+
731+
// assert
732+
await expectDataCellFocusState(t, dataGrid, 0, 1);
700733

701734
await testScreenshot(t, takeScreenshot, `${useNative ? 'native' : 'simulated'}_scrolling_-_navigate_to_first_cell_row_dragging__virtual_scrolling__virtual_columns.png`, { element: dataGrid.element });
702735

703736
// assert
704737
await t
705-
.expect(dataGrid.getDataCell(0, 1).isFocused)
706-
.ok()
707738
.expect(compareResults.isValid())
708739
.ok(compareResults.errorMessages());
709740
}).before(async () => createWidget('dxDataGrid', {
@@ -731,12 +762,11 @@ test('Navigate to first cell in the first row when virtual scrolling and columns
731762
.ok();
732763

733764
// act
734-
await t
735-
.click(dataGrid.getDataCell(0, 0).element)
736-
.pressKey('ctrl+end')
737-
.wait(1000);
765+
await focusDataCell(t, dataGrid, 0, 1);
766+
await t.pressKey('ctrl+end');
767+
await waitForKeyboardNavigation(t);
738768

739-
await t.expect(dataGrid.getDataCell(199, 35).isFocused).ok();
769+
await expectDataCellFocusState(t, dataGrid, 199, 34);
740770
await testScreenshot(t, takeScreenshot, `${useNative ? 'native' : 'simulated'}_scrolling_-_navigate_to_last_cell_row_dragging__virtual_scrolling__virtual_columns.png`, { element: dataGrid.element });
741771

742772
// assert

0 commit comments

Comments
 (0)