From 0234b950c745ac9ab2543b771f701f3028f33355 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Fri, 3 May 2024 06:45:39 +0000 Subject: [PATCH] test: replace addRecord call using API --- tests/playwright/pages/Dashboard/TreeView.ts | 4 -- .../db/columns/columnMultiSelect.spec.ts | 37 ++++++++++++++++++- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/tests/playwright/pages/Dashboard/TreeView.ts b/tests/playwright/pages/Dashboard/TreeView.ts index 6bcc1429ff..cc226a0537 100644 --- a/tests/playwright/pages/Dashboard/TreeView.ts +++ b/tests/playwright/pages/Dashboard/TreeView.ts @@ -162,10 +162,6 @@ export class TreeViewPage extends BasePage { // Tab render is slow for playwright await this.dashboard.waitForTabRender({ title, mode }); - - // Some of the tests are flaky due to immediate operations on the table - // Tab render above is no more valid - await this.rootPage.waitForTimeout(1000); } async verifyTable({ title, index, exists = true }: { title: string; index?: number; exists?: boolean }) { diff --git a/tests/playwright/tests/db/columns/columnMultiSelect.spec.ts b/tests/playwright/tests/db/columns/columnMultiSelect.spec.ts index e4fc5ba98e..bb9c764bd7 100644 --- a/tests/playwright/tests/db/columns/columnMultiSelect.spec.ts +++ b/tests/playwright/tests/db/columns/columnMultiSelect.spec.ts @@ -5,10 +5,18 @@ import setup, { unsetup } from '../../../setup'; import { ToolbarPage } from '../../../pages/Dashboard/common/Toolbar'; import { Api } from 'nocodb-sdk'; let api: Api; +const addRecordUsingAPI = async (context: any, tableId: string, rowAttributes: any) => { + try { + await api.dbTableRow.bulkCreate('noco', context.base.id, tableId, rowAttributes); + } catch (e) { + console.error(e); + } +}; test.describe('Multi select', () => { let dashboard: DashboardPage, grid: GridPage; let context: any; + let tableId: string; test.beforeEach(async ({ page }) => { context = await setup({ page, isEmptyProject: true }); @@ -22,7 +30,25 @@ test.describe('Multi select', () => { columnTitle: 'MultiSelect', options: ['Option 1', 'Option 2'], }); - await grid.addNewRow({ index: 0, value: 'Row 0' }); + + api = new Api({ + baseURL: `http://localhost:8080/`, + headers: { + 'xc-auth': context.token, + }, + }); + + const tables = await api.dbTable.list(context.base.id); + tableId = tables.list.find((table: any) => table.title === 'sheet1').id; + await addRecordUsingAPI(context, tableId, [ + { + Id: 1, + Title: `Row 0`, + }, + ]); + + // page reload + await page.reload(); }); test.afterEach(async () => { @@ -56,7 +82,14 @@ test.describe('Multi select', () => { multiSelect: true, }); - await grid.addNewRow({ index: 1, value: 'Row 1' }); + await addRecordUsingAPI(context, tableId, [ + { + Id: 2, + Title: `Row 1`, + }, + ]); + await grid.rootPage.reload(); + await grid.cell.selectOption.select({ index: 1, columnHeader: 'MultiSelect',