|
1 | 1 | import { expect, Locator, Page } from '@playwright/test'; |
2 | 2 |
|
3 | 3 | //sets up of all the functions that signin tests will use. |
4 | | -export class AuthPage{ |
5 | | -private readonly signInLink: Locator; |
6 | | -private readonly signUpButton: Locator; |
7 | | -private readonly emailField: Locator; |
8 | | -private readonly passwordField: Locator; |
9 | | -private readonly signInWithEmailButton: Locator; |
10 | | -private readonly signInWithGoogleButton: Locator; |
11 | | -private readonly signUpWithEmailButton: Locator; |
12 | | - |
13 | | -constructor(public readonly page: Page) { |
14 | | - this.signInLink=page.getByRole('link', { name: 'Sign in' }); |
15 | | - this.signUpButton=page.getByRole('button', {name: 'Sign up'}); |
16 | | - this.emailField=page.getByLabel('Email'); |
17 | | - this.passwordField=page.getByLabel('Password'); |
18 | | - this.signInWithEmailButton=page.getByRole('button', {name: 'Sign in with Email'}); |
19 | | - this.signInWithGoogleButton=page.getByRole('button', {name: 'Google'}); |
20 | | - this.signUpWithEmailButton=page.getByRole('button', {name: 'Sign up with Email'}); |
21 | | -} |
22 | | - |
23 | | -async clickSignInLink() { |
24 | | - await this.signInLink.click(); |
25 | | -} |
26 | | - |
27 | | -async clickSignUpButton() { |
28 | | - await this.signUpButton.click(); |
29 | | -} |
30 | | - |
31 | | -async clickSignInWithEmailButton() { |
32 | | - await this.signInWithEmailButton.click(); |
33 | | -} |
34 | | - |
35 | | -async clickSignInWithGoogleButton() { |
36 | | - await this.signInWithGoogleButton.click(); |
37 | | -} |
38 | | - |
39 | | -async clickSignUpWithEmailButton() { |
40 | | - await this.signUpWithEmailButton.click(); |
41 | | -} |
42 | | - |
43 | | -async fillEmailField(email: string) { |
44 | | - await expect(this.emailField).toBeVisible(); |
45 | | - await this.emailField.fill(email); |
46 | | -} |
47 | | - |
48 | | -async fillPasswordField(password: string) { |
49 | | - await expect(this.passwordField).toBeVisible(); |
50 | | - await this.passwordField.fill(password); |
51 | | -} |
52 | | - |
53 | | -} |
| 4 | +export class AuthPage { |
| 5 | + private readonly signInLink: Locator; |
| 6 | + private readonly signUpButton: Locator; |
| 7 | + private readonly emailField: Locator; |
| 8 | + private readonly passwordField: Locator; |
| 9 | + private readonly signInWithEmailButton: Locator; |
| 10 | + private readonly signInWithGoogleButton: Locator; |
| 11 | + private readonly signUpWithEmailButton: Locator; |
| 12 | + |
| 13 | + constructor(public readonly page: Page) { |
| 14 | + this.signInLink = page.getByRole('link', { name: 'Sign in' }); |
| 15 | + this.signUpButton = page.getByRole('button', { name: 'Sign up' }); |
| 16 | + this.emailField = page.getByLabel('Email'); |
| 17 | + this.passwordField = page.getByLabel('Password'); |
| 18 | + this.signInWithEmailButton = page.getByRole('button', { name: 'Sign in with Email' }); |
| 19 | + this.signInWithGoogleButton = page.getByRole('button', { name: 'Google' }); |
| 20 | + this.signUpWithEmailButton = page.getByRole('button', { name: 'Sign up with Email' }); |
| 21 | + } |
| 22 | + |
| 23 | + async clickSignInLink() { |
| 24 | + await this.signInLink.click(); |
| 25 | + } |
| 26 | + |
| 27 | + async clickSignUpButton() { |
| 28 | + await this.signUpButton.click(); |
| 29 | + } |
| 30 | + |
| 31 | + async clickSignInWithEmailButton() { |
| 32 | + await this.signInWithEmailButton.click(); |
| 33 | + } |
| 34 | + |
| 35 | + async clickSignInWithGoogleButton() { |
| 36 | + await this.signInWithGoogleButton.click(); |
| 37 | + } |
| 38 | + |
| 39 | + async clickSignUpWithEmailButton() { |
| 40 | + await this.signUpWithEmailButton.click(); |
| 41 | + } |
| 42 | + |
| 43 | + async fillEmailField(email: string) { |
| 44 | + await expect(this.emailField).toBeVisible(); |
| 45 | + await this.emailField.fill(email); |
| 46 | + } |
| 47 | + |
| 48 | + async fillPasswordField(password: string) { |
| 49 | + await expect(this.passwordField).toBeVisible(); |
| 50 | + await this.passwordField.fill(password); |
| 51 | + } |
| 52 | + |
| 53 | +}; |
54 | 54 |
|
0 commit comments