From d97b49db6919780c1d9bc4b4f465a6e8720d18bb Mon Sep 17 00:00:00 2001 From: Sanny Nguyen Hung Date: Mon, 23 Oct 2023 11:08:57 +0200 Subject: [PATCH] Fix format --- tests/TestHelper/TroiPage.js | 88 +++++++++++++++++++++-------- tests/login.test.js | 8 +-- tests/timeEntriesOneProject.test.js | 10 +++- 3 files changed, 75 insertions(+), 31 deletions(-) diff --git a/tests/TestHelper/TroiPage.js b/tests/TestHelper/TroiPage.js index cd776c3a..ba02c1df 100644 --- a/tests/TestHelper/TroiPage.js +++ b/tests/TestHelper/TroiPage.js @@ -1,7 +1,5 @@ import { expect } from "@playwright/test"; -import { - TimeoutConfig -} from "./TestHelper/TestHelper"; +import { TimeoutConfig } from "./TestHelper/TestHelper"; export default class TroiPage { constructor(page) { @@ -45,41 +43,83 @@ export default class TroiPage { const hoursTestId = "hours-" + projectId; const descriptionTestId = "description-" + projectId; if (hidden) { - await expect(this.page.getByTestId(hoursTestId)).toBeHidden(TimeoutConfig); - await expect(this.page.getByTestId(descriptionTestId)).toBeHidden(TimeoutConfig); + await expect(this.page.getByTestId(hoursTestId)).toBeHidden( + TimeoutConfig + ); + await expect(this.page.getByTestId(descriptionTestId)).toBeHidden( + TimeoutConfig + ); } else { - await expect(this.page.getByTestId(hoursTestId)).toBeVisible(TimeoutConfig); - await expect(this.page.getByTestId(descriptionTestId)).toBeVisible(TimeoutConfig); + await expect(this.page.getByTestId(hoursTestId)).toBeVisible( + TimeoutConfig + ); + await expect(this.page.getByTestId(descriptionTestId)).toBeVisible( + TimeoutConfig + ); } } async _expectOnlyDeleteAndEditVisible(projectId) { - await expect(this.page.getByTestId(`delete-${projectId}`)).toBeVisible(TimeoutConfig); - await expect(this.page.getByTestId(`edit-${projectId}`)).toBeVisible(TimeoutConfig); - await expect(this.page.getByTestId(`add-${projectId}`)).toBeHidden(TimeoutConfig); - await expect(this.page.getByTestId(`cancel-${projectId}`)).toBeHidden(TimeoutConfig); - await expect(this.page.getByTestId(`save-${projectId}`)).toBeHidden(TimeoutConfig); + await expect(this.page.getByTestId(`delete-${projectId}`)).toBeVisible( + TimeoutConfig + ); + await expect(this.page.getByTestId(`edit-${projectId}`)).toBeVisible( + TimeoutConfig + ); + await expect(this.page.getByTestId(`add-${projectId}`)).toBeHidden( + TimeoutConfig + ); + await expect(this.page.getByTestId(`cancel-${projectId}`)).toBeHidden( + TimeoutConfig + ); + await expect(this.page.getByTestId(`save-${projectId}`)).toBeHidden( + TimeoutConfig + ); } async _expectOnlyAddVisible(projectId) { - await expect(this.page.getByTestId(`delete-${projectId}`)).toBeHidden(TimeoutConfig); - await expect(this.page.getByTestId(`edit-${projectId}`)).toBeHidden(TimeoutConfig); - await expect(this.page.getByTestId(`add-${projectId}`)).toBeVisible(TimeoutConfig); - await expect(this.page.getByTestId(`cancel-${projectId}`)).toBeHidden(TimeoutConfig); - await expect(this.page.getByTestId(`save-${projectId}`)).toBeHidden(TimeoutConfig); + await expect(this.page.getByTestId(`delete-${projectId}`)).toBeHidden( + TimeoutConfig + ); + await expect(this.page.getByTestId(`edit-${projectId}`)).toBeHidden( + TimeoutConfig + ); + await expect(this.page.getByTestId(`add-${projectId}`)).toBeVisible( + TimeoutConfig + ); + await expect(this.page.getByTestId(`cancel-${projectId}`)).toBeHidden( + TimeoutConfig + ); + await expect(this.page.getByTestId(`save-${projectId}`)).toBeHidden( + TimeoutConfig + ); } async expectOnlyCancelAndSaveVisible(projectId) { - await expect(this.page.getByTestId(`delete-${projectId}`)).toBeHidden(TimeoutConfig); - await expect(this.page.getByTestId(`edit-${projectId}`)).toBeHidden(TimeoutConfig); - await expect(this.page.getByTestId(`add-${projectId}`)).toBeHidden(TimeoutConfig); - await expect(this.page.getByTestId(`cancel-${projectId}`)).toBeVisible(TimeoutConfig); - await expect(this.page.getByTestId(`save-${projectId}`)).toBeVisible(TimeoutConfig); + await expect(this.page.getByTestId(`delete-${projectId}`)).toBeHidden( + TimeoutConfig + ); + await expect(this.page.getByTestId(`edit-${projectId}`)).toBeHidden( + TimeoutConfig + ); + await expect(this.page.getByTestId(`add-${projectId}`)).toBeHidden( + TimeoutConfig + ); + await expect(this.page.getByTestId(`cancel-${projectId}`)).toBeVisible( + TimeoutConfig + ); + await expect(this.page.getByTestId(`save-${projectId}`)).toBeVisible( + TimeoutConfig + ); } async expectLoading() { - await expect(this.page.getByTestId("loadingOverlay")).toBeVisible(TimeoutConfig); - await expect(this.page.getByTestId("loadingOverlay")).toBeHidden(TimeoutConfig); + await expect(this.page.getByTestId("loadingOverlay")).toBeVisible( + TimeoutConfig + ); + await expect(this.page.getByTestId("loadingOverlay")).toBeHidden( + TimeoutConfig + ); } async clickOnWeekDay(dayIndex) { diff --git a/tests/login.test.js b/tests/login.test.js index 3ebb3dc3..82e77a0a 100644 --- a/tests/login.test.js +++ b/tests/login.test.js @@ -2,9 +2,7 @@ import { expect, test } from "@playwright/test"; import LoginPage from "./TestHelper/LoginPage"; import TroiApiStub, { username, password } from "./TestHelper/TroiApiStub"; import { initializeTestSetup } from "./TestHelper/TestHelper"; -import { - TimeoutConfig -} from "./TestHelper/TestHelper"; +import { TimeoutConfig } from "./TestHelper/TestHelper"; test.beforeEach(async ({ context, page }) => { page.on("console", (msg) => console.log(msg.text())); @@ -26,6 +24,8 @@ test.describe("Auth", async () => { ).toBeVisible(); await page.locator("text=LOGOUT").click(); - await expect(page.locator("h2 >> text=Enter. Time.")).toBeVisible(TimeoutConfig); + await expect(page.locator("h2 >> text=Enter. Time.")).toBeVisible( + TimeoutConfig + ); }); }); diff --git a/tests/timeEntriesOneProject.test.js b/tests/timeEntriesOneProject.test.js index b5019c8e..f79d8a04 100644 --- a/tests/timeEntriesOneProject.test.js +++ b/tests/timeEntriesOneProject.test.js @@ -4,7 +4,7 @@ import { fixedCurrentDate, initializeTestSetup, setFixedCurrentDate, - TimeoutConfig + TimeoutConfig, } from "./TestHelper/TestHelper"; import TroiApiStub from "./TestHelper/TroiApiStub"; import { username, password } from "./TestHelper/TroiApiStub"; @@ -101,10 +101,14 @@ test("add entry with invalid data shows error", async ({ context, page }) => { await troiPage.expectLoading(); await troiPage.fillForm(entryToAdd); - await expect(page.getByTestId(`error-${entryToAdd.projectId}`)).toBeHidden(TimeoutConfig); + await expect(page.getByTestId(`error-${entryToAdd.projectId}`)).toBeHidden( + TimeoutConfig + ); await troiPage.submitForm(entryToAdd.projectId); await expect(page.getByTestId("loadingOverlay")).toBeHidden(TimeoutConfig); - await expect(page.getByTestId("error-" + entryToAdd.projectId)).toBeVisible(TimeoutConfig); + await expect(page.getByTestId("error-" + entryToAdd.projectId)).toBeVisible( + TimeoutConfig + ); }); test("delete existing entry works", async ({ context, page }) => {