Skip to content

Commit

Permalink
Clarify that this page is not using the nb/en.json files for language
Browse files Browse the repository at this point in the history
  • Loading branch information
framitdavid committed Jan 14, 2024
1 parent efbb8d7 commit f797050
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions frontend/testing/playwright/pages/LoginPage.ts
Original file line number Diff line number Diff line change
@@ -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<string, string> = {
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);
Expand All @@ -13,26 +20,26 @@ export class LoginPage extends BasePage {
}

public async goToGiteaLoginPage(): Promise<void> {
await this.page.getByRole('button', { name: 'Logg inn' }).click();
await this.page.getByRole('button', { name: loginPageTexts['login'] }).click();
}

public async writeUsername(username: string): Promise<void> {
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<void> {
return await this.page.getByLabel('Passord').fill(password);
return await this.page.getByLabel(loginPageTexts['password']).fill(password);
}

public async clickLoginButton(): Promise<void> {
return await this.page.getByRole('button', { name: 'Logg inn' }).click();
return await this.page.getByRole('button', { name: loginPageTexts['login'] }).click();
}

public async confirmSuccessfulLogin(): Promise<void> {
return this.page.waitForURL(this.getRoute('dashboard'));
}

public async addSessionToSharableStorage() {
return await this.page.context().storageState({ path: this._authStorageFile });
return await this.page.context().storageState({ path: this.authStorageFile });
}
}

0 comments on commit f797050

Please sign in to comment.