From 98cca2d377eaeb2b4a2ecfdcf00b80790f83a5f7 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Wed, 28 Jun 2023 15:37:04 +0530 Subject: [PATCH] test: code realign (WIP) Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- .../tests/db/verticalFillHandle.spec.ts | 126 +++++------------- 1 file changed, 32 insertions(+), 94 deletions(-) diff --git a/tests/playwright/tests/db/verticalFillHandle.spec.ts b/tests/playwright/tests/db/verticalFillHandle.spec.ts index 9fdc1d9a9b..96d135bef1 100644 --- a/tests/playwright/tests/db/verticalFillHandle.spec.ts +++ b/tests/playwright/tests/db/verticalFillHandle.spec.ts @@ -6,6 +6,9 @@ import { createDemoTable } from '../../setup/demoTable'; import { BulkUpdatePage } from '../../pages/Dashboard/BulkUpdate'; let dashboard: DashboardPage; +let context: any; +let api: Api; +let table; async function dragDrop({ firstColumn, lastColumn }: { firstColumn: string; lastColumn: string }) { await dashboard.grid.cell.get({ index: 0, columnHeader: firstColumn }).click(); await dashboard.rootPage.keyboard.press( @@ -19,27 +22,26 @@ async function dragDrop({ firstColumn, lastColumn }: { firstColumn: string; last // drag and drop await src.dragTo(dst); } +async function beforeEachInit({ page, tableType }: { page: any; tableType: string }) { + context = await setup({ page, isEmptyProject: true }); + dashboard = new DashboardPage(page, context.project); + + api = new Api({ + baseURL: `http://localhost:8080/`, + headers: { + 'xc-auth': context.token, + }, + }); -test.describe.skip('Bulk update', () => { - let context: any; - let api: Api; - let table; - - test.beforeEach(async ({ page }) => { - context = await setup({ page, isEmptyProject: true }); - dashboard = new DashboardPage(page, context.project); - - api = new Api({ - baseURL: `http://localhost:8080/`, - headers: { - 'xc-auth': context.token, - }, - }); + table = await createDemoTable({ context, type: tableType, recordCnt: 10 }); + await page.reload(); - table = await createDemoTable({ context, type: 'textBased', recordCnt: 10 }); - await page.reload(); + await dashboard.treeView.openTable({ title: tableType }); +} - await dashboard.treeView.openTable({ title: 'textBased' }); +test.describe('Fill Handle', () => { + test.beforeEach(async ({ page }) => { + await beforeEachInit({ page, tableType: 'textBased' }); }); test('Text based', async () => { @@ -70,26 +72,9 @@ test.describe.skip('Bulk update', () => { }); }); -test.describe.skip('Bulk update', () => { - let context: any; - let api: Api; - let table; - +test.describe('Fill Handle', () => { test.beforeEach(async ({ page }) => { - context = await setup({ page, isEmptyProject: true }); - dashboard = new DashboardPage(page, context.project); - - api = new Api({ - baseURL: `http://localhost:8080/`, - headers: { - 'xc-auth': context.token, - }, - }); - - table = await createDemoTable({ context, type: 'numberBased', recordCnt: 10 }); - await page.reload(); - - await dashboard.treeView.openTable({ title: 'numberBased' }); + await beforeEachInit({ page, tableType: 'numberBased' }); }); test('Number based', async () => { @@ -144,26 +129,9 @@ test.describe.skip('Bulk update', () => { }); }); -test.describe.skip('Bulk update', () => { - let context: any; - let api: Api; - let table; - +test.describe('Fill Handle', () => { test.beforeEach(async ({ page }) => { - context = await setup({ page, isEmptyProject: true }); - dashboard = new DashboardPage(page, context.project); - - api = new Api({ - baseURL: `http://localhost:8080/`, - headers: { - 'xc-auth': context.token, - }, - }); - - table = await createDemoTable({ context, type: 'selectBased', recordCnt: 10 }); - await page.reload(); - - await dashboard.treeView.openTable({ title: 'selectBased' }); + await beforeEachInit({ page, tableType: 'selectBased' }); }); test('Select based', async () => { @@ -204,26 +172,9 @@ test.describe.skip('Bulk update', () => { }); }); -test.describe.skip('Bulk update', () => { - let context: any; - let api: Api; - let table; - +test.describe.only('Fill Handle', () => { test.beforeEach(async ({ page }) => { - context = await setup({ page, isEmptyProject: true }); - dashboard = new DashboardPage(page, context.project); - - api = new Api({ - baseURL: `http://localhost:8080/`, - headers: { - 'xc-auth': context.token, - }, - }); - - table = await createDemoTable({ context, type: 'miscellaneous', recordCnt: 50 }); - await page.reload(); - - await dashboard.treeView.openTable({ title: 'miscellaneous' }); + await beforeEachInit({ page, tableType: 'miscellaneous' }); }); test('Miscellaneous (Checkbox, attachment)', async () => { @@ -232,6 +183,8 @@ test.describe.skip('Bulk update', () => { { title: 'Attachment', value: `${process.cwd()}/fixtures/sampleFiles/1.json`, type: 'attachment' }, ]; + await dragDrop({ firstColumn: 'Checkbox', lastColumn: 'Attachment' }); + // verify data on grid for (let i = 0; i < fields.length; i++) { if (fields[i].type === 'checkbox') { @@ -260,31 +213,16 @@ test.describe.skip('Bulk update', () => { }); }); -test.describe.skip('Bulk update', () => { - let context: any; - let api: Api; - let table; - +test.describe('Fill Handle', () => { test.beforeEach(async ({ page }) => { - context = await setup({ page, isEmptyProject: true }); - dashboard = new DashboardPage(page, context.project); - - api = new Api({ - baseURL: `http://localhost:8080/`, - headers: { - 'xc-auth': context.token, - }, - }); - - table = await createDemoTable({ context, type: 'dateTimeBased', recordCnt: 50 }); - await page.reload(); - - await dashboard.treeView.openTable({ title: 'dateTimeBased' }); + await beforeEachInit({ page, tableType: 'dateTimeBased' }); }); test('Date Time Based', async () => { const fields = [{ title: 'Date', value: '2024-08-04', type: 'date' }]; + await dragDrop({ firstColumn: 'Date', lastColumn: 'Date' }); + // verify data on grid for (let i = 0; i < fields.length; i++) { await dashboard.grid.cell.date.verify({