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
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ function testsFactory(testModel: {
await testModel.assertFirstColumnHidden(t, cardView);

await testModel.showFirstColumn(t, cardView);

await testModel.assertFirstColumnVisible(t, cardView);

await testModel.hideFirstColumn(t, cardView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
expectColumns,
getColumnItem,
triggerDragStart,
triggerDragEnd,
SELECTORS,
} from './utils';

Expand All @@ -29,12 +30,16 @@ fixture.disablePageReloads`CardView - ColumnSortable.Functional`

await triggerDragStart(columnElement);

const draggingElement = Selector(SELECTORS.dragging);
try {
const draggingElement = Selector(SELECTORS.dragging);

if (result) {
await t.expect(draggingElement.exists).ok();
} else {
await t.expect(draggingElement.exists).notOk();
if (result) {
await t.expect(draggingElement.exists).ok();
} else {
await t.expect(draggingElement.exists).notOk();
}
} finally {
await triggerDragEnd(columnElement);
}
}).before(async () => createWidget('dxCardView', {
allowColumnReordering,
Expand All @@ -59,12 +64,16 @@ fixture.disablePageReloads`CardView - ColumnSortable.Functional`

await triggerDragStart(columnElement);

const draggingElement = Selector(SELECTORS.dragging);
try {
const draggingElement = Selector(SELECTORS.dragging);

if (result) {
await t.expect(draggingElement.exists).ok();
} else {
await t.expect(draggingElement.exists).notOk();
if (result) {
await t.expect(draggingElement.exists).ok();
} else {
await t.expect(draggingElement.exists).notOk();
}
} finally {
await triggerDragEnd(columnElement);
}
}).before(async () => createWidget('dxCardView', {
allowColumnReordering: true,
Expand Down Expand Up @@ -102,18 +111,18 @@ fixture.disablePageReloads`CardView - ColumnSortable.Functional`

[0, 1].forEach((columnIndex) => {
[0, 1, 2].forEach((gapIndex) => {
test.meta({ unstable: true })(`drag from columnChooser to headerPanel: from index ${columnIndex} to index ${gapIndex}`, async (t) => {
test(`drag from columnChooser to headerPanel: from index ${columnIndex} to index ${gapIndex}`, async (t) => {
const cardView = new CardView('#container');
await cardView.apiShowColumnChooser();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we check isReady here? Also, shouldn't we verify that the Column Chooser exists before accessing it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isReady won't help here, because it indicates whether dataController finished loading data:

In this test we don't care whether the data was loaded or not. Explicit wait for column chooser is also not needed, because there's an implement check:

const columnElement = getColumnItem(cardView, columnIndex, 'columnChooser');. Column element is a testcafe Selector, so testcafe will wait for the element to appear before doing anything with it


const columnElement = getColumnItem(cardView, columnIndex, 'columnChooser');

await dragToHeaderPanel(t, cardView, columnElement, gapIndex);

const headerPanelColumns = [2, 3, 4];
const headerPanelColumns = [2, 3];
headerPanelColumns.splice(gapIndex, 0, columnIndex);

const chooserColumns = [0, 1, 2, 3, 4].filter((c) => !headerPanelColumns.includes(c));
const chooserColumns = [0, 1].filter((c) => c !== columnIndex);

await expectColumns(t, cardView, headerPanelColumns);
await expectColumns(t, cardView, chooserColumns, 'columnChooser');
Expand All @@ -124,7 +133,6 @@ fixture.disablePageReloads`CardView - ColumnSortable.Functional`
{ dataField: 'Column 1', visible: false },
{ dataField: 'Column 2' },
{ dataField: 'Column 3' },
{ dataField: 'Column 4' },

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matrix tests iterates through [0, 1, 2] for gapIndex. With 4 columns, testcases for gapIndex==1 and gapIndex==2 basically test the same thing: drag from column chooser to the middle of header panel.

With 3 columns, gapIndex==2 now checks the case when column is dragged to the end of header panel

],
}));
});
Expand Down
41 changes: 23 additions & 18 deletions e2e/testcafe-devextreme/tests/cardView/columnSortable/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,26 @@ export const dragToHeaderPanel = async (

if (gapIndex < columnsNum) {
const insertBeforeColumn = headers.getHeaderItemNth(gapIndex).element;
const { width } = await insertBeforeColumn.boundingClientRect;

await t.dragToElement(
columnElement,
insertBeforeColumn,
{
destinationOffsetX: 5,
destinationOffsetX: -(Math.floor(width) + 3), // 3px left of the left edge
destinationOffsetY: HEADER_DROP_OFFSET_Y,
speed: 0.5,
},
);
} else {
const insertAfterColumn = headers.getHeaderItemNth(columnsNum - 1).element;
const { width } = await insertAfterColumn.boundingClientRect;

await t.dragToElement(
columnElement,
insertAfterColumn,
{
destinationOffsetX: -5,
destinationOffsetX: (Math.floor(width) + 3), // 3px right of the right edge
destinationOffsetY: HEADER_DROP_OFFSET_Y,
speed: 0.5,
},
Expand All @@ -119,6 +121,12 @@ export const dragToColumnChooser = async (
const treeView = columnChooser.element.find(SELECTORS.treeView);

await t.dragToElement(columnElement, treeView);

await t
.expect(Selector(SELECTORS.dragging).exists)
.notOk({ timeout: DRAG_ASSERTION_TIMEOUT })
.expect(cardView.isReady())
.ok({ timeout: DRAG_ASSERTION_TIMEOUT });
};

export const arrayMoveToGap = (arr: number[], index: number, gapIndex: number): number[] => {
Expand All @@ -139,23 +147,20 @@ export const expectColumns = async (
expectedColumns: number[],
source: 'headerPanel' | 'columnChooser' = 'headerPanel',
): Promise<void> => {
const actualColumns: string[] = [];
const adjustedExpectedColumns = expectedColumns.map((columnIndex) => `Column ${columnIndex}`);

for (let i = 0; i < expectedColumns.length; i += 1) {
// eslint-disable-next-line @typescript-eslint/init-declarations
let column: Selector;

if (source === 'headerPanel') {
column = cardView.getHeaders().getHeaderItemNth(i)?.element;
} else {
const treeView = new TreeView(cardView.getColumnChooser().element.find(SELECTORS.treeView));
column = treeView.getNodeItem(i);
}

await t
.expect(column.exists)
.ok({ timeout: DRAG_ASSERTION_TIMEOUT })
.expect(column.innerText)
.eql(adjustedExpectedColumns[i], { timeout: DRAG_ASSERTION_TIMEOUT });
const actualColumnsCount = source === 'headerPanel'
? await cardView.getHeaders().getHeaderItemsElements().count
: await cardView.getColumnChooser().getColumns().count;

for (let i = 0; i < actualColumnsCount; i += 1) {
const column = source === 'headerPanel'
? cardView.getHeaders().getHeaderItemNth(i).element
: cardView.getColumnChooser().getColumn(i);

actualColumns.push(await column.innerText);
}

await t.expect(actualColumns).eql(adjustedExpectedColumns, 'Columns order should match');
};
34 changes: 31 additions & 3 deletions e2e/testcafe-devextreme/tests/common/treeList/toast.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
import TreeList from 'devextreme-testcafe-models/treeList';
import { ClientFunction } from 'testcafe';
import url from '../../../helpers/getPageUrl';
import { createWidget } from '../../../helpers/createWidget';
import { testScreenshot } from '../../../helpers/themeUtils';

fixture.disablePageReloads`Toasts in TreeList`
fixture`Toasts in TreeList`
.page(url(__dirname, '../../container.html'));

test('Toast should be visible after calling and should be not visible after default display time', async (t) => {
const setToastDisplayTime = (displayTime: number) => ClientFunction(() => {
(window as any).DevExpress.ui.dxToast.defaultOptions({
options: {
displayTime,
},
});
}, { dependencies: { displayTime } })();

test('Toast should be visible after calling', async (t) => {
const treeList = new TreeList('#container');
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
await t
.expect(treeList.isReady())
.ok();

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

Expand All @@ -22,7 +32,25 @@ test('Toast should be visible after calling and should be not visible after defa
await t
.expect(compareResults.isValid())
.ok(compareResults.errorMessages());
await t.expect(treeList.getToast().exists).notOk();
}).before(async () => {
await createWidget('dxTreeList', {});
});

test('Toast should hide after the display time', async (t) => {
const treeList = new TreeList('#container');

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

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

await t
.wait(150)
.expect(treeList.getToast().exists).notOk();
}).before(async () => {
await createWidget('dxTreeList', {});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const checkAIColumnTexts = async (
}
};

const isAIRequestPending = ClientFunction(() => !!(window as any).aiResolve);

const resolveAIRequest = ClientFunction((): void => {
const { aiResponseData } = (window as any);
const { aiResolve } = (window as any);
Expand All @@ -41,12 +43,14 @@ const deleteGlobalVariables = ClientFunction((): void => {
delete (window as any).aiResolve;
});

test.meta({ unstable: true })('DataGrid should send an AI request for rendered rows after scrolling without changing the page index', async (t) => {
test('DataGrid should send an AI request for rendered rows after scrolling without changing the page index', async (t) => {
// arrange
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);

// assert
await t
.expect(isAIRequestPending())
.ok()
.expect(dataGrid.getLoadPanel().isVisible())
.ok();

Expand All @@ -72,6 +76,8 @@ test.meta({ unstable: true })('DataGrid should send an AI request for rendered r
.eql(0)
.expect(dataGrid.getDataCell(20, 0).element.textContent)
.eql('21')
.expect(isAIRequestPending())
.ok()
.expect(dataGrid.getLoadPanel().isVisible())
.ok();

Expand Down Expand Up @@ -144,13 +150,15 @@ test.meta({ unstable: true })('DataGrid should send an AI request for rendered r
await deleteGlobalVariables();
});

test.meta({ unstable: true })('DataGrid should send an AI request for rendered rows after scrolling with changing the page index', async (t) => {
test('DataGrid should send an AI request for rendered rows after scrolling with changing the page index', async (t) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same questions apply as in the previous test (see above).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

// arrange
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);

// assert
await t
.expect(dataGrid.getLoadPanel().isVisible())
.ok()
.expect(isAIRequestPending())
.ok();

// act
Expand All @@ -175,6 +183,8 @@ test.meta({ unstable: true })('DataGrid should send an AI request for rendered r
.eql(1)
.expect(dataGrid.getDataCell(20, 0).element.textContent)
.eql('21')
.expect(isAIRequestPending())
.ok()
.expect(dataGrid.getLoadPanel().isVisible())
.ok();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ editingModes.forEach((mode) => {

await clickCellEditor(t, mode, columnInfo, form, cell, editor);
await setEditorValue(t, mode, columnInfo, editor, false, useMask);
await t.expect(dataGrid.isReady()).ok();
}

const saveButton = getSaveButton(mode, form);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,18 @@ test('DataGrid - The "Cannot read properties of undefined error" occurs when usi
await t
.click(dataGrid.getDataCell(0, 0).element)
.typeText(dataGrid.getDataCell(0, 0).element, 'new_value')
.pressKey('enter tab tab');
.pressKey('enter')
.expect(dataGrid.isReady())
.ok()
.pressKey('tab tab')
.expect(dataGrid.getDataCell(2, 0).isFocused)
.ok();

await resolveOnSavingDeferred();
await t.expect(dataGrid.getDataCell(2, 0).isFocused).ok();

await t
.expect(dataGrid.isReady()).ok()
.expect(dataGrid.getDataCell(2, 0).isFocused).ok();
}).before(async () => {
await ClientFunction(() => {
(window as any).deferred = $.Deferred();
Expand All @@ -94,6 +103,10 @@ test('DataGrid - The "Cannot read properties of undefined error" occurs when usi
e.promise = (window as any).deferred;
},
});
}).after(async () => {
await ClientFunction(() => {
delete (window as any).deferred;
})();
});

test('Tab key on editor should focus next cell if editing mode is cell', async (t) => {
Expand Down Expand Up @@ -2318,7 +2331,9 @@ test('Cells should be focused correctly on click when cell editing mode is used
.typeText(dataGrid.getDataCell(0, 0).getEditor().element, '1')
.click(dataGrid.getDataCell(1, 0).getEditor().element);

await t.expect(getStoredName(1)).eql('Name 11');
await t
.expect(dataGrid.isReady()).ok()
.expect(getStoredName(1)).eql('Name 11');

// assert
await t
Expand All @@ -2334,7 +2349,9 @@ test('Cells should be focused correctly on click when cell editing mode is used
.typeText(dataGrid.getDataCell(1, 0).getEditor().element, '2')
.click(dataGrid.getDataCell(2, 0).getEditor().element);

await t.expect(getStoredName(2)).eql('Name 22');
await t
.expect(dataGrid.isReady()).ok()
.expect(getStoredName(2)).eql('Name 22');

// assert
await t
Expand All @@ -2343,14 +2360,18 @@ test('Cells should be focused correctly on click when cell editing mode is used
.expect(dataGrid.getDataCell(2, 0).isFocused)
.ok()
.expect(dataGrid.getDataCell(2, 0).getEditor().element.focused)
.ok()
.expect(dataGrid.isReady())
.ok();

// act
await t
.typeText(dataGrid.getDataCell(2, 0).getEditor().element, '3')
.click(dataGrid.getDataCell(1, 0).getEditor().element);

await t.expect(getStoredName(3)).eql('Name 33');
await t
.expect(dataGrid.isReady()).ok()
.expect(getStoredName(3)).eql('Name 33');

// assert
await t
Expand All @@ -2366,7 +2387,9 @@ test('Cells should be focused correctly on click when cell editing mode is used
.typeText(dataGrid.getDataCell(1, 0).getEditor().element, '2')
.click(dataGrid.getDataCell(0, 0).getEditor().element);

await t.expect(getStoredName(2)).eql('Name 222');
await t
.expect(dataGrid.isReady()).ok()
.expect(getStoredName(2)).eql('Name 222');

// assert
await t
Expand Down
Loading
Loading