From 7a0465e80adfc02c77b4ef39b3ea527f89a32f83 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Fri, 3 May 2024 06:45:40 +0000 Subject: [PATCH] fix: replace UI record insert with API --- .../tests/db/columns/columnUserSelect.spec.ts | 49 +++++++++++++++++-- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/tests/playwright/tests/db/columns/columnUserSelect.spec.ts b/tests/playwright/tests/db/columns/columnUserSelect.spec.ts index 1dd6fc71d6..1bfa0b32b4 100644 --- a/tests/playwright/tests/db/columns/columnUserSelect.spec.ts +++ b/tests/playwright/tests/db/columns/columnUserSelect.spec.ts @@ -59,17 +59,20 @@ async function beforeEachInit({ page }: { page: any }) { } } - return { dashboard, context }; + return { dashboard, context, api }; } test.describe('User single select', () => { let dashboard: DashboardPage, grid: GridPage, topbar: TopbarPage; let context: any; + let api: Api; + let tableId: string; test.beforeEach(async ({ page }) => { const initRsp = await beforeEachInit({ page: page }); context = initRsp.context; dashboard = initRsp.dashboard; + api = initRsp.api; grid = dashboard.grid; topbar = dashboard.grid.topbar; @@ -77,7 +80,16 @@ test.describe('User single select', () => { await grid.column.create({ title: 'User', type: 'User' }); - await grid.addNewRow({ index: 0, value: 'Row 0' }); + // await grid.addNewRow({ index: 0, value: 'Row 0' }); + const tables = await api.dbTable.list(context.base.id); + tableId = tables.list.find((table: any) => table.title === 'sheet1').id; + await api.dbTableRow.bulkCreate('noco', context.base.id, tableId, [ + { + Id: 1, + Title: `Row 0`, + }, + ]); + await page.reload(); }); test.afterEach(async () => { @@ -102,7 +114,15 @@ test.describe('User single select', () => { }); // Add new row and verify default value is added in new cell - await grid.addNewRow({ index: 1, value: 'Row 1' }); + // await grid.addNewRow({ index: 1, value: 'Row 1' }); + await api.dbTableRow.bulkCreate('noco', context.base.id, tableId, [ + { + Id: 2, + Title: `Row 1`, + }, + ]); + await grid.rootPage.reload(); + await grid.cell.userOption.verify({ index: 1, columnHeader: 'User', @@ -130,9 +150,18 @@ test.describe('User single select', () => { }); test('Field operations - duplicate column, convert to SingleLineText', async () => { + await api.dbTableRow.bulkCreate('noco', context.base.id, tableId, [ + { Id: 2, Title: `Row 1` }, + { Id: 3, Title: `Row 2` }, + { Id: 4, Title: `Row 3` }, + { Id: 5, Title: `Row 4` }, + { Id: 6, Title: `Row 5` }, + ]); + await grid.rootPage.reload(); + for (let i = 0; i <= 4; i++) { await grid.cell.userOption.select({ index: i, columnHeader: 'User', option: users[i], multiSelect: false }); - await grid.addNewRow({ index: i + 1, value: `Row ${i + 1}` }); + // await grid.addNewRow({ index: i + 1, value: `Row ${i + 1}` }); } await grid.column.duplicateColumn({ @@ -164,10 +193,20 @@ test.describe('User single select', () => { multiSelect: false, }); + // add 5 rows + await api.dbTableRow.bulkCreate('noco', context.base.id, tableId, [ + { Id: 2, Title: `Row 1` }, + { Id: 3, Title: `Row 2` }, + { Id: 4, Title: `Row 3` }, + { Id: 5, Title: `Row 4` }, + { Id: 6, Title: `Row 5` }, + ]); + await grid.rootPage.reload(); + // Edit, refresh and verify for (let i = 0; i <= 4; i++) { await grid.cell.userOption.select({ index: i, columnHeader: 'User', option: users[i], multiSelect: false }); - await grid.addNewRow({ index: i + 1, value: `Row ${i + 1}` }); + // await grid.addNewRow({ index: i + 1, value: `Row ${i + 1}` }); } // refresh page