|
| 1 | +import {Page} from '@playwright/test' |
| 2 | +import {UserAccountInformation} from '../utils/accountInformation' |
| 3 | +import {AuthPage} from './authPage' |
| 4 | +import {ComatibilityPage} from './compatibilityPage' |
| 5 | +import {HomePage} from './homePage' |
| 6 | +import {OnboardingPage} from './onboardingPage' |
| 7 | +import {OrganizationPage} from './organizationPage' |
| 8 | +import {ProfilePage} from './profilePage' |
| 9 | +import {SettingsPage} from './settingsPage' |
| 10 | +import {SignUpPage} from './signUpPage' |
| 11 | +import {SocialPage} from './socialPage' |
| 12 | + |
| 13 | +export class App { |
| 14 | + readonly auth: AuthPage |
| 15 | + readonly compatibility: ComatibilityPage |
| 16 | + readonly home: HomePage |
| 17 | + readonly onboarding: OnboardingPage |
| 18 | + readonly organization: OrganizationPage |
| 19 | + readonly profile: ProfilePage |
| 20 | + readonly settings: SettingsPage |
| 21 | + readonly signUp: SignUpPage |
| 22 | + readonly social: SocialPage |
| 23 | + |
| 24 | + constructor(public readonly page: Page) { |
| 25 | + this.auth = new AuthPage(page) |
| 26 | + this.compatibility = new ComatibilityPage(page) |
| 27 | + this.home = new HomePage(page) |
| 28 | + this.onboarding = new OnboardingPage(page) |
| 29 | + this.organization = new OrganizationPage(page) |
| 30 | + this.profile = new ProfilePage(page) |
| 31 | + this.settings = new SettingsPage(page) |
| 32 | + this.signUp = new SignUpPage(page) |
| 33 | + this.social = new SocialPage(page) |
| 34 | + } |
| 35 | + |
| 36 | + async deleteProfileFromSettings() { |
| 37 | + await this.home.clickSettingsLink() |
| 38 | + await this.settings.clickDeleteAccountButton() |
| 39 | + await this.settings.fillDeleteAccountSurvey('Delete me') |
| 40 | + await this.settings.clickDeleteAccountButton() |
| 41 | + await this.home.verifyHomePageLinks() |
| 42 | + } |
| 43 | + |
| 44 | + async skipOnboardingHeadToProfile(account: UserAccountInformation) { |
| 45 | + await this.onboarding.clickSkipOnboardingButton() |
| 46 | + await this.signUp.fillDisplayName(account.display_name) |
| 47 | + await this.signUp.fillUsername(account.username) |
| 48 | + await this.signUp.clickNextButton() |
| 49 | + await this.signUp.clickNextButton() |
| 50 | + await this.profile.clickCloseButton() |
| 51 | + await this.onboarding.clickRefineProfileButton() |
| 52 | + } |
| 53 | + |
| 54 | + async registerWithEmail(account: UserAccountInformation) { |
| 55 | + await this.home.goToRegisterPage() |
| 56 | + await this.auth.fillEmailField(account.email) |
| 57 | + await this.auth.fillPasswordField(account.password) |
| 58 | + await this.auth.clickSignUpWithEmailButton() |
| 59 | + } |
| 60 | + |
| 61 | + async signinWithEmail(accountOrEmail: UserAccountInformation | string, password?: string) { |
| 62 | + const email = typeof accountOrEmail === 'string' ? accountOrEmail : accountOrEmail.email |
| 63 | + |
| 64 | + const resolvedPassword = typeof accountOrEmail === 'string' ? password : accountOrEmail.password |
| 65 | + |
| 66 | + if (!email || !resolvedPassword) { |
| 67 | + throw new Error('Provide either an `account` or `email` and `password`.') |
| 68 | + } |
| 69 | + |
| 70 | + await this.home.goToSigninPage() |
| 71 | + await this.auth.fillEmailField(email) |
| 72 | + await this.auth.fillPasswordField(resolvedPassword) |
| 73 | + await this.auth.clickSignInWithEmailButton() |
| 74 | + } |
| 75 | +} |
0 commit comments