-
Notifications
You must be signed in to change notification settings - Fork 385
/
LoginPage.ts
72 lines (58 loc) · 3.08 KB
/
LoginPage.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (C) 2023 Storj Labs, Inc.
// See LICENSE for copying information.
import { LoginPageObjects, LoginPageObjectsV2 } from '@objects/LoginPageObjects';
import type { Page } from '@playwright/test';
import { testConfig } from '../../testConfig';
import { expect } from '@playwright/test';
export class LoginPage {
constructor(readonly page: Page) {}
async navigateToURL(): Promise<void> {
await this.page.goto(`${testConfig.host}${testConfig.port}/login`);
}
async loginByCreds(email: string, password: string): Promise<void> {
await this.page.locator(LoginPageObjects.EMAIL_EDITBOX_ID).fill(email);
await this.page.locator(LoginPageObjects.PASSWORD_EDITBOX_ID).fill(password);
await this.page.locator('span').filter({ hasText: 'Sign In' }).click();
}
async loginToApplication(): Promise<void> {
await this.page.locator(LoginPageObjects.EMAIL_EDITBOX_ID).fill(testConfig.username);
await this.page.locator(LoginPageObjects.PASSWORD_EDITBOX_ID).fill(testConfig.password);
await this.page.locator('span').filter({ hasText: 'Sign In' }).click();
}
}
export class LoginPageV2 {
constructor(readonly page: Page) {}
async loginByCreds(email: string, password: string): Promise<void> {
await this.page.locator(LoginPageObjectsV2.EMAIL_EDITBOX_ID).fill(email);
await this.page.locator(LoginPageObjectsV2.PASSWORD_EDITBOX_ID).fill(password);
await this.page.locator(LoginPageObjectsV2.CONTINUE_BUTTON_XPATH).click();
}
async verifySetupAccountFirstStep(): Promise<void> {
const header = this.page.locator(LoginPageObjectsV2.FIRST_STEP_HEADER_XPATH);
await expect(header).toBeVisible();
}
async choosePersonalAccSetup(): Promise<void> {
await this.page.locator(LoginPageObjectsV2.PERSONAL_CARD_XPATH).click();
}
async chooseBusinessAccSetup(): Promise<void> {
await this.page.locator(LoginPageObjectsV2.BUSINESS_CARD_XPATH).click();
}
async fillPersonalSetupForm(name: string): Promise<void> {
await this.page.locator(LoginPageObjectsV2.NAME_EDITBOX_ID).fill(name);
await this.page.locator(LoginPageObjectsV2.CONTINUE_BUTTON_XPATH).click();
}
async fillBusinessSetupForm(firstName: string, lastName: string, companyName: string, jobRole: string): Promise<void> {
await this.page.locator(LoginPageObjectsV2.FIRST_NAME_EDITBOX_ID).fill(firstName);
await this.page.locator(LoginPageObjectsV2.LAST_NAME_EDITBOX_ID).fill(lastName);
await this.page.locator(LoginPageObjectsV2.COMPANY_NAME_EDITBOX_ID).fill(companyName);
await this.page.locator(LoginPageObjectsV2.JOB_ROLE_EDITBOX_ID).fill(jobRole);
await this.page.locator(LoginPageObjectsV2.CONTINUE_BUTTON_XPATH).click();
}
async ensureSetupSuccess(): Promise<void> {
const label = this.page.locator(LoginPageObjectsV2.SETUP_SUCCESS_LABEL_XPATH);
await expect(label).toBeVisible();
}
async finishSetup(): Promise<void> {
await this.page.locator(LoginPageObjectsV2.CONTINUE_BUTTON_XPATH).nth(1).click();
}
}