Browse Source

feat(testing): Moved language actions to ProjectsPage

pull/3848/head
Muhammed Mustafa 2 years ago
parent
commit
5600c58cbf
  1. 29
      scripts/playwright/pages/Dashboard/index.ts
  2. 21
      scripts/playwright/pages/ProjectsPage/index.ts
  3. 11
      scripts/playwright/tests/language.spec.ts

29
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");

21
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();
}
}

11
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 });
}
});
});

Loading…
Cancel
Save