From dc3f150c068bbed169e94c9af55b87f1d4d249bf Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Thu, 20 Oct 2022 16:01:20 +0530 Subject: [PATCH] test: language verification Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- scripts/playwright/pages/Dashboard/index.ts | 33 ++++++++++- scripts/playwright/tests/language.spec.ts | 61 +++++++++++++++++++++ 2 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 scripts/playwright/tests/language.spec.ts diff --git a/scripts/playwright/pages/Dashboard/index.ts b/scripts/playwright/pages/Dashboard/index.ts index b0b41a0f84..dab2f18164 100644 --- a/scripts/playwright/pages/Dashboard/index.ts +++ b/scripts/playwright/pages/Dashboard/index.ts @@ -75,12 +75,16 @@ export class DashboardPage extends BasePage { await this.rootPage.waitForTimeout(2000); } + async clickHome() { + await this.rootPage.locator('[data-cy="nc-noco-brand-icon"]').click(); + } + async waitForTabRender({ title }: { title: string }) { await this.get().locator('[pw-data="grid-id-column"]').waitFor(); await this.tabBar - .locator(`.ant-tabs-tab-active:has-text("${title}")`) - .waitFor(); + .locator(`.ant-tabs-tab-active:has-text("${title}")`) + .waitFor(); // wait active tab animation to finish await expect @@ -101,4 +105,29 @@ export class DashboardPage extends BasePage { `/#/nc/${this.project.id}/table/${title}` ); } + + // Project page language menu + 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 }) { + let title = await this.rootPage + .locator(`.nc-project-page-title`) + .textContent(); + let menu = await this.rootPage + .locator(`.nc-new-project-menu`) + .textContent(); + console.log(title, menu); + expect(title).toContain(param.json.title.myProject); + expect(menu).toContain(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 new file mode 100644 index 0000000000..3c506b4ba3 --- /dev/null +++ b/scripts/playwright/tests/language.spec.ts @@ -0,0 +1,61 @@ +import { test } from "@playwright/test"; +import { DashboardPage } from "../pages/Dashboard"; +import setup from "../setup"; + +const langMenu = [ + "help-translate", + "ar.json", + "bn_IN.json", + "da.json", + "de.json", + "en.json", + "es.json", + "fa.json", + "fi.json", + "fr.json", + "he.json", + "hi.json", + "hr.json", + "id.json", + "it.json", + "ja.json", + "ko.json", + "lv.json", + "nl.json", + "no.json", + "pl.json", + "pt.json", + "pt_BR.json", + "ru.json", + "sl.json", + "sv.json", + "th.json", + "tr.json", + "uk.json", + "vi.json", + "zh-Hans.json", + "zh-Hant.json", +]; + +test.describe("Common", () => { + let dashboard: DashboardPage; + let context: any; + + test.beforeEach(async ({ page }) => { + context = await setup({ page }); + dashboard = new DashboardPage(page, context.project); + }); + + test("Language", async () => { + await dashboard.clickHome(); + + // Index is the order in which menu options appear + 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 }); + } + }); +});