From f797050ea8a6ad6c6eb3e213e394c87f0f3e5a93 Mon Sep 17 00:00:00 2001 From: David Ovrelid Date: Sun, 14 Jan 2024 20:39:37 +0100 Subject: [PATCH] Clarify that this page is not using the nb/en.json files for language --- .../testing/playwright/pages/LoginPage.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/frontend/testing/playwright/pages/LoginPage.ts b/frontend/testing/playwright/pages/LoginPage.ts index dcb810a62b2..25d6546611c 100644 --- a/frontend/testing/playwright/pages/LoginPage.ts +++ b/frontend/testing/playwright/pages/LoginPage.ts @@ -1,8 +1,15 @@ import { Page } from '@playwright/test'; import { BasePage } from '../helpers/BasePage'; +// Since this page is a Razor page, it's not using the nb/en.json files, which are used in the frontend. +const loginPageTexts: Record = { + login: 'logg inn', + username: 'Brukernavn eller epost', + password: 'Passord', +}; + export class LoginPage extends BasePage { - private readonly _authStorageFile: string = '.playwright/auth/user.json'; + private readonly authStorageFile: string = '.playwright/auth/user.json'; constructor(page: Page) { super(page); @@ -13,19 +20,19 @@ export class LoginPage extends BasePage { } public async goToGiteaLoginPage(): Promise { - await this.page.getByRole('button', { name: 'Logg inn' }).click(); + await this.page.getByRole('button', { name: loginPageTexts['login'] }).click(); } public async writeUsername(username: string): Promise { - return await this.page.getByLabel('Brukernavn eller epost').fill(username); + return await this.page.getByLabel(loginPageTexts['username']).fill(username); } public async writePassword(password: string): Promise { - return await this.page.getByLabel('Passord').fill(password); + return await this.page.getByLabel(loginPageTexts['password']).fill(password); } public async clickLoginButton(): Promise { - return await this.page.getByRole('button', { name: 'Logg inn' }).click(); + return await this.page.getByRole('button', { name: loginPageTexts['login'] }).click(); } public async confirmSuccessfulLogin(): Promise { @@ -33,6 +40,6 @@ export class LoginPage extends BasePage { } public async addSessionToSharableStorage() { - return await this.page.context().storageState({ path: this._authStorageFile }); + return await this.page.context().storageState({ path: this.authStorageFile }); } }