-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace repeating code for user and root password in playwright tests
- Loading branch information
Showing
10 changed files
with
99 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { type Page } from '@playwright/test'; | ||
import { ConfigureRootPasswordPage } from '../pages/configure-root-password-page'; | ||
import { DefineUserPage } from '../pages/define-user-page'; | ||
import { UsersPage } from '../pages/users-page'; | ||
|
||
interface User { | ||
fullname: string, | ||
username: string, | ||
password: string | ||
} | ||
|
||
export class UserActor { | ||
readonly page: Page; | ||
readonly usersPage: UsersPage; | ||
readonly defineUserPage: DefineUserPage; | ||
readonly configureRootPasswordPage: ConfigureRootPasswordPage; | ||
|
||
static readonly user: User = { | ||
fullname: 'Bernhard M. Wiedemann', | ||
username: 'bernhard', | ||
password: 'nots3cr3t' | ||
}; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.usersPage = new UsersPage(page); | ||
this.defineUserPage = new DefineUserPage(page); | ||
this.configureRootPasswordPage = new ConfigureRootPasswordPage(page); | ||
} | ||
|
||
async handleUser() { | ||
await this.defineUser(UserActor.user); | ||
await this.setRootPassword(UserActor.user.password); | ||
await this.back(); | ||
} | ||
|
||
async defineUser(user: User) { | ||
await this.usersPage.expectNoUserDefined(); | ||
await this.usersPage.defineUser(); | ||
await this.defineUserPage.fillUserFullName(user.fullname); | ||
await this.defineUserPage.fillUserName(user.username); | ||
await this.defineUserPage.fillAndConfirmPassword(user.password); | ||
await this.defineUserPage.confirm(); | ||
} | ||
|
||
async setRootPassword(password: string) { | ||
await this.usersPage.expectRootPasswordNotSet(); | ||
await this.usersPage.configureRootPassword(); | ||
await this.configureRootPasswordPage.fillAndConfirmPassword(password); | ||
await this.configureRootPasswordPage.confirm(); | ||
} | ||
|
||
async back() { | ||
await this.usersPage.back(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters