From 0a9a58f407b521083dd01485ea4e96a92557c192 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Thu, 23 Mar 2023 12:21:09 +0530 Subject: [PATCH] test: fix project operations flaky test Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- tests/playwright/pages/ProjectsPage/index.ts | 3 +++ .../tests/projectOperations.spec.ts | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tests/playwright/pages/ProjectsPage/index.ts b/tests/playwright/pages/ProjectsPage/index.ts index 224f75cd28..1a03f263d3 100644 --- a/tests/playwright/pages/ProjectsPage/index.ts +++ b/tests/playwright/pages/ProjectsPage/index.ts @@ -147,6 +147,9 @@ export class ProjectsPage extends BasePage { }); await projRow.locator('.nc-action-btn').nth(0).click(); + // there is a flicker; add delay to avoid flakiness + await this.rootPage.waitForTimeout(1000); + await project.locator('input.nc-metadb-project-name').fill(newTitle); // press enter to save const submitAction = () => project.locator('input.nc-metadb-project-name').press('Enter'); diff --git a/tests/playwright/tests/projectOperations.spec.ts b/tests/playwright/tests/projectOperations.spec.ts index 19a572288e..2684b90ac9 100644 --- a/tests/playwright/tests/projectOperations.spec.ts +++ b/tests/playwright/tests/projectOperations.spec.ts @@ -3,11 +3,13 @@ import { DashboardPage } from '../pages/Dashboard'; import setup from '../setup'; import { ToolbarPage } from '../pages/Dashboard/common/Toolbar'; import { ProjectsPage } from '../pages/ProjectsPage'; +import { Api } from 'nocodb-sdk'; test.describe('Project operations', () => { let dashboard: DashboardPage; let toolbar: ToolbarPage; let context: any; + let api: Api; let projectPage: ProjectsPage; test.beforeEach(async ({ page }) => { @@ -15,9 +17,28 @@ test.describe('Project operations', () => { dashboard = new DashboardPage(page, context.project); projectPage = new ProjectsPage(page); toolbar = dashboard.grid.toolbar; + + api = new Api({ + baseURL: `http://localhost:8080/`, + headers: { + 'xc-auth': context.token, + }, + }); }); test('rename, delete', async () => { + // if project already exists, delete it + try { + const projectList = await api.project.list(); + const project = projectList.list.find((p: any) => p.title === 'project-firstName'); + if (project) { + await api.project.delete(project.id); + console.log('deleted project: ', project.id); + } + } catch (e) { + console.log('Error: ', e); + } + await dashboard.clickHome(); await projectPage.createProject({ name: 'project-firstName', withoutPrefix: true }); await dashboard.clickHome();