Browse Source

Nc test/flaky fix (#8349)

* fix: flaky test

* Update index.ts

* fix: flaky with addNewRow- replace with APIs

* fix: groupby flaky

* test: retry attempt for calendar sidebar card count

* test: use x button instead of escape to close expand modal

* test: fix selected cell count retry

* test: fix flaky for cmd K

* fix: increase wait time after form submission
pull/8352/head
Raju Udava 2 months ago committed by GitHub
parent
commit
994a0d7905
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      tests/playwright/pages/Dashboard/Calendar/CalendarSideMenu.ts
  2. 2
      tests/playwright/pages/Dashboard/ExpandedForm/index.ts
  3. 8
      tests/playwright/pages/Dashboard/Grid/index.ts
  4. 13
      tests/playwright/pages/Dashboard/common/Toolbar/Groupby.ts
  5. 2
      tests/playwright/pages/SharedForm/index.ts
  6. 35
      tests/playwright/tests/db/columns/columnMultiSelect.spec.ts
  7. 2
      tests/playwright/tests/db/features/command.spec.ts
  8. 16
      tests/playwright/tests/db/general/cellSelection.spec.ts

14
tests/playwright/pages/Dashboard/Calendar/CalendarSideMenu.ts

@ -30,10 +30,16 @@ export class CalendarSideMenuPage extends BasePage {
}
async verifySideBarRecords({ records }: { records: string[] }) {
const sideBar = this.get().getByTestId('nc-calendar-side-menu-list');
const sideBarRecords = await sideBar.getByTestId('nc-sidebar-record-card');
let attempts = 0;
let sideBarRecords: Locator;
while (attempts++ < 5) {
const sideBar = this.get().getByTestId('nc-calendar-side-menu-list');
sideBarRecords = sideBar.getByTestId('nc-sidebar-record-card');
if ((await sideBarRecords.count()) === records.length) break;
// wait for records to load
await this.rootPage.waitForTimeout(200 * attempts);
}
await expect(sideBarRecords).toHaveCount(records.length);
for (let i = 0; i < records.length; i++) {

2
tests/playwright/pages/Dashboard/ExpandedForm/index.ts

@ -129,7 +129,7 @@ export class ExpandedFormPage extends BasePage {
await this.rootPage.locator('[data-testid="grid-load-spinner"]').waitFor({ state: 'hidden' });
// removing focus from toast
await this.rootPage.locator('.nc-modal').click();
await this.get().press('Escape');
await this.get().locator('.nc-expanded-form-header').locator('.nc-expand-form-close-btn').click();
await this.get().waitFor({ state: 'hidden' });
}

8
tests/playwright/pages/Dashboard/Grid/index.ts

@ -441,6 +441,14 @@ export class GridPage extends BasePage {
return this.get().locator('.cell.active').count();
}
async getActiveCell() {
return this.get().locator('.cell.active');
}
async verifySelectedCellCount({ count }: { count: number }) {
await expect(this.get().locator('.cell.active')).toHaveCount(count);
}
async copyWithKeyboard() {
// retry to avoid flakiness, until text is copied to clipboard
//

13
tests/playwright/pages/Dashboard/common/Toolbar/Groupby.ts

@ -49,8 +49,12 @@ export class ToolbarGroupByPage extends BasePage {
.locator(`div[label="${title}"]`)
.last()
.click();
//kludge: wait for rendering to stabilize
await this.rootPage.waitForTimeout(1000);
await this.rootPage.locator('.nc-sort-dir-select').nth(index).waitFor({ state: 'visible' });
await this.rootPage.locator('.nc-sort-dir-select').nth(index).click();
await this.rootPage.locator('.nc-sort-dir-select').nth(index).click({ force: true });
await this.rootPage
.locator('.nc-dropdown-sort-dir')
.last()
@ -139,7 +143,12 @@ export class ToolbarGroupByPage extends BasePage {
async remove({ index }: { index: number }) {
// open group-by menu
await this.toolbar.clickGroupBy();
await this.rootPage.locator('.nc-group-by-item-remove-btn').nth(index).click();
await this.waitForResponse({
uiAction: () => this.rootPage.locator('.nc-group-by-item-remove-btn').nth(index).click(),
requestUrlPathToMatch: '/api/v1/db/data/noco',
httpMethodsToMatch: ['GET'],
});
// close group-by menu
await this.toolbar.clickGroupBy();

2
tests/playwright/pages/SharedForm/index.ts

@ -25,7 +25,7 @@ export class SharedFormPage extends BasePage {
}
async verifySuccessMessage() {
await this.rootPage.locator('.nc-shared-form-success-msg').waitFor({ state: 'visible' });
await this.rootPage.locator('.nc-shared-form-success-msg').waitFor({ state: 'visible', timeout: 10000 });
await expect(
this.get().locator('.ant-alert-success', {
hasText: 'Successfully submitted form data',

35
tests/playwright/tests/db/columns/columnMultiSelect.spec.ts

@ -3,6 +3,8 @@ import { DashboardPage } from '../../../pages/Dashboard';
import { GridPage } from '../../../pages/Dashboard/Grid';
import setup, { unsetup } from '../../../setup';
import { ToolbarPage } from '../../../pages/Dashboard/common/Toolbar';
import { Api } from 'nocodb-sdk';
let api: Api<any>;
test.describe('Multi select', () => {
let dashboard: DashboardPage, grid: GridPage;
@ -206,6 +208,13 @@ test.describe('Multi select - filters', () => {
toolbar = dashboard.grid.toolbar;
grid = dashboard.grid;
api = new Api({
baseURL: `http://localhost:8080/`,
headers: {
'xc-auth': context.token,
},
});
await dashboard.treeView.createTable({ title: 'sheet1', baseTitle: context.base.title });
await grid.column.create({ title: 'MultiSelect', type: 'MultiSelect' });
@ -213,12 +222,26 @@ test.describe('Multi select - filters', () => {
columnTitle: 'MultiSelect',
options: ['foo', 'bar', 'baz'],
});
await grid.addNewRow({ index: 0, value: '1' });
await grid.addNewRow({ index: 1, value: '2' });
await grid.addNewRow({ index: 2, value: '3' });
await grid.addNewRow({ index: 3, value: '4' });
await grid.addNewRow({ index: 4, value: '5' });
await grid.addNewRow({ index: 5, value: '6' });
try {
const tables = await api.dbTable.list(context.base.id);
const rowAttributes = [];
for (let i = 0; i < 6; i++) {
const row = {
Id: i + 1,
Title: `${i + 1}`,
};
rowAttributes.push(row);
}
const tableId = tables.list.find((table: any) => table.table_name === 'sheet1').id;
await api.dbTableRow.bulkCreate('noco', context.base.id, tableId, rowAttributes);
} catch (e) {
console.error(e);
}
// page reload
await page.reload();
await grid.cell.selectOption.select({ index: 1, columnHeader: 'MultiSelect', option: 'foo', multiSelect: true });
await grid.cell.selectOption.select({ index: 2, columnHeader: 'MultiSelect', option: 'bar', multiSelect: true });

2
tests/playwright/tests/db/features/command.spec.ts

@ -46,6 +46,8 @@ test.describe('Command Shortcuts', () => {
await dashboard.cmdK.searchText('CustomerList');
await page.waitForTimeout(1000);
await dashboard.get().locator('.nc-active-view-title').waitFor({ state: 'visible' });
await expect(dashboard.get().locator('.nc-active-view-title')).toContainText('Default View');
await dashboard.signOut();

16
tests/playwright/tests/db/general/cellSelection.spec.ts

@ -77,9 +77,9 @@ test.describe('Verify cell selection', () => {
start: { index: 0, columnHeader: 'Country' },
end: { index: 2, columnHeader: 'Cities' },
});
expect(await grid.selectedCount()).toBe(9);
await grid.verifySelectedCellCount({ count: 9 });
await grid.cell.get({ index: 0, columnHeader: 'Country' }).click();
expect(await grid.selectedCount()).toBe(1);
await grid.verifySelectedCellCount({ count: 1 });
expect(await grid.cell.verifyCellActiveSelected({ index: 0, columnHeader: 'Country' }));
await dashboard.closeAllTabs();
@ -89,9 +89,9 @@ test.describe('Verify cell selection', () => {
start: { index: 0, columnHeader: 'Country' },
end: { index: 2, columnHeader: 'Cities' },
});
expect(await grid.selectedCount()).toBe(9);
await grid.verifySelectedCellCount({ count: 9 });
await grid.cell.get({ index: 5, columnHeader: 'Country' }).click();
expect(await grid.selectedCount()).toBe(1);
await grid.verifySelectedCellCount({ count: 1 });
expect(await grid.cell.verifyCellActiveSelected({ index: 5, columnHeader: 'Country' }));
await dashboard.closeAllTabs();
@ -102,9 +102,9 @@ test.describe('Verify cell selection', () => {
start: { index: 2, columnHeader: 'Cities' },
end: { index: 0, columnHeader: 'Country' },
});
expect(await grid.selectedCount()).toBe(12);
await grid.verifySelectedCellCount({ count: 12 });
await grid.cell.get({ index: 1, columnHeader: 'Country' }).click();
expect(await grid.selectedCount()).toBe(1);
await grid.verifySelectedCellCount({ count: 1 });
expect(await grid.cell.verifyCellActiveSelected({ index: 1, columnHeader: 'Country' }));
await dashboard.grid.toolbar.fields.toggleShowSystemFields();
await dashboard.closeAllTabs();
@ -115,8 +115,10 @@ test.describe('Verify cell selection', () => {
start: { index: 0, columnHeader: 'Country' },
end: { index: 2, columnHeader: 'Cities' },
});
await grid.verifySelectedCellCount({ count: 9 });
await grid.rootPage.waitForTimeout(100);
await page.keyboard.press('ArrowRight');
expect(await grid.selectedCount()).toBe(1);
await grid.verifySelectedCellCount({ count: 1 });
expect(await grid.cell.verifyCellActiveSelected({ index: 0, columnHeader: 'LastUpdate' }));
await dashboard.closeAllTabs();
});

Loading…
Cancel
Save