diff --git a/scripts/playwright/pages/Dashboard/index.ts b/scripts/playwright/pages/Dashboard/index.ts index 55df602104..05a51d2087 100644 --- a/scripts/playwright/pages/Dashboard/index.ts +++ b/scripts/playwright/pages/Dashboard/index.ts @@ -11,7 +11,6 @@ import { SettingsPage } from "./Settings"; import { ViewSidebarPage } from "./ViewSidebar"; import { GalleryPage } from "./Gallery"; import { KanbanPage } from "./Kanban"; -import { ToolbarPage } from "./common/Toolbar"; import { ImportAirtablePage } from "./Import/Airtable"; import { ImportTemplatePage } from "./Import/ImportTemplate"; import { WebhookFormPage } from "./WebhookForm"; @@ -90,6 +89,8 @@ export class DashboardPage extends BasePage { await projectsPage.waitToBeRendered(); } + // When a tab is opened, it is not always immediately visible. + // Hence will wait till contents are visible async waitForTabRender({ title, mode = "standard", @@ -135,11 +136,6 @@ export class DashboardPage extends BasePage { } } - // Project page language menu - async openLanguageMenu() { - await this.rootPage.locator(".nc-menu-translate").click(); - } - async openPasswordChangeModal() { // open change password portal await this.rootPage.locator(".nc-menu-accounts").click(); @@ -180,27 +176,6 @@ export class DashboardPage extends BasePage { .click(); } - async selectLanguage({ index }: { index: number }) { - let modal = await this.rootPage.locator(".nc-dropdown-menu-translate"); - await modal.locator(`.ant-dropdown-menu-item`).nth(index).click(); - - // fix me! - // allow time for language to change - await this.rootPage.waitForTimeout(1000); - } - - async verifyLanguage(param: { json: any }) { - const title = await this.rootPage - .locator(`.nc-project-page-title`); - const menu = this.rootPage - .locator(`.nc-new-project-menu`); - await expect(title).toHaveText(param.json.title.myProject); - await expect(menu).toHaveText(param.json.title.newProj); - await this.rootPage - .locator(`[placeholder="${param.json.activity.searchProject}"]`) - .waitFor(); - } - async signOut() { await this.rootPage.locator('[pw-data="nc-project-menu"]').click(); let projMenu = await this.rootPage.locator(".nc-dropdown-project-menu"); diff --git a/scripts/playwright/pages/ProjectsPage/index.ts b/scripts/playwright/pages/ProjectsPage/index.ts index 9c61da8d7f..9f199890cb 100644 --- a/scripts/playwright/pages/ProjectsPage/index.ts +++ b/scripts/playwright/pages/ProjectsPage/index.ts @@ -167,4 +167,25 @@ export class ProjectsPage extends BasePage { // todo: vue navigation breaks if page changes very quickly await this.rootPage.waitForTimeout(1000); } + + async openLanguageMenu() { + await this.rootPage.locator(".nc-menu-translate").click(); + } + + async selectLanguage({ index }: { index: number }) { + let modal = await this.rootPage.locator(".nc-dropdown-menu-translate"); + await modal.locator(`.ant-dropdown-menu-item`).nth(index).click(); + } + + async verifyLanguage(param: { json: any }) { + const title = await this.rootPage + .locator(`.nc-project-page-title`); + const menu = this.rootPage + .locator(`.nc-new-project-menu`); + await expect(title).toHaveText(param.json.title.myProject); + await expect(menu).toHaveText(param.json.title.newProj); + await this.rootPage + .locator(`[placeholder="${param.json.activity.searchProject}"]`) + .waitFor(); + } } diff --git a/scripts/playwright/tests/language.spec.ts b/scripts/playwright/tests/language.spec.ts index 3c506b4ba3..46318c72fc 100644 --- a/scripts/playwright/tests/language.spec.ts +++ b/scripts/playwright/tests/language.spec.ts @@ -1,5 +1,6 @@ import { test } from "@playwright/test"; import { DashboardPage } from "../pages/Dashboard"; +import { ProjectsPage } from "../pages/ProjectsPage"; import setup from "../setup"; const langMenu = [ @@ -38,12 +39,14 @@ const langMenu = [ ]; test.describe("Common", () => { - let dashboard: DashboardPage; let context: any; + let dashboard: DashboardPage; + let projectsPage: ProjectsPage; test.beforeEach(async ({ page }) => { context = await setup({ page }); dashboard = new DashboardPage(page, context.project); + projectsPage = new ProjectsPage(page); }); test("Language", async () => { @@ -53,9 +56,9 @@ test.describe("Common", () => { for (let i = 1; i < langMenu.length; i++) { // scripts/playwright/tests/language.spec.ts let json = require(`../../../packages/nc-gui/lang/${langMenu[i]}`); - await dashboard.openLanguageMenu(); - await dashboard.selectLanguage({ index: i }); - await dashboard.verifyLanguage({ json }); + await projectsPage.openLanguageMenu(); + await projectsPage.selectLanguage({ index: i }); + await projectsPage.verifyLanguage({ json }); } }); });