|
| 1 | +importtype{Page,Locator}from'@playwright/test'; |
| 2 | + |
| 3 | +exportclassLoginPage{ |
| 4 | +privatereadonlyemailInput:Locator; |
| 5 | +privatereadonlypasswordInput:Locator; |
| 6 | +privatereadonlyconfirmPasswordInput:Locator; |
| 7 | +privatereadonlysignInButton:Locator; |
| 8 | +privatereadonlysignUpButton:Locator; |
| 9 | +privatereadonlysignInLink:Locator; |
| 10 | +privatereadonlysignUpLink:Locator; |
| 11 | + |
| 12 | +constructor(publicreadonlypage:Page){ |
| 13 | +this.emailInput=this.page.getByPlaceholder(/^Pleaseenteryouremail$/); |
| 14 | +this.passwordInput=this.page.getByPlaceholder(/^Pleaseenteryourpassword$/); |
| 15 | +this.confirmPasswordInput=this.page.getByPlaceholder(/^PleaseConfirmPassword$/); |
| 16 | +this.signInButton=this.page.getByRole('button',{name:'Sign In'}); |
| 17 | +this.signUpButton=this.page.getByRole('button',{name:'Sign Up'}); |
| 18 | +this.signUpLink=this.page.getByRole('link',{name:'Sign In'}); |
| 19 | +this.signUpLink=this.page.getByRole('link',{name:'Sign Up'}); |
| 20 | +} |
| 21 | + |
| 22 | +asyncloadPage(){ |
| 23 | +awaitthis.page.goto('/user/auth/login'); |
| 24 | +} |
| 25 | + |
| 26 | +asyncfillEmail(text:string){ |
| 27 | +awaitthis.emailInput.click(); |
| 28 | +awaitthis.emailInput.fill(text); |
| 29 | +} |
| 30 | + |
| 31 | +asyncfillPassword(text:string){ |
| 32 | +awaitthis.passwordInput.click(); |
| 33 | +awaitthis.passwordInput.fill(text); |
| 34 | +} |
| 35 | + |
| 36 | +asyncfillConfirmPassword(text:string){ |
| 37 | +awaitthis.confirmPasswordInput.click(); |
| 38 | +awaitthis.confirmPasswordInput.fill(text); |
| 39 | +} |
| 40 | + |
| 41 | +asyncclickSignIn(){ |
| 42 | +awaitthis.signInButton.click(); |
| 43 | +} |
| 44 | + |
| 45 | +asyncclickSignUp(){ |
| 46 | +awaitthis.signUpButton.click(); |
| 47 | +} |
| 48 | + |
| 49 | +asyncclickSignUpLink(){ |
| 50 | +awaitthis.signUpLink.click(); |
| 51 | +} |
| 52 | + |
| 53 | +asyncsignUp(username:string,password:string,repeatPassword:string){ |
| 54 | +if(awaitthis.signUpLink.isVisible()){ |
| 55 | +awaitthis.clickSignUpLink(); |
| 56 | +} |
| 57 | + |
| 58 | +awaitthis.fillEmail(username); |
| 59 | + |
| 60 | +/* disabled because the placeholder is different between sign in and sign up */ |
| 61 | +//await this.fillPassword(password); |
| 62 | +awaitthis.page.getByPlaceholder(/^PleaseEnterPassword$/).click(); |
| 63 | +awaitthis.page.getByPlaceholder(/^PleaseEnterPassword$/).fill(password); |
| 64 | + |
| 65 | +awaitthis.fillConfirmPassword(repeatPassword); |
| 66 | +awaitthis.clickSignUp(); |
| 67 | +} |
| 68 | + |
| 69 | +asynclogIn(username:string,password:string){ |
| 70 | +awaitthis.loadPage(); |
| 71 | +awaitthis.fillEmail(username); |
| 72 | +awaitthis.fillPassword(password); |
| 73 | +awaitthis.clickSignIn(); |
| 74 | +} |
| 75 | + |
| 76 | +asynclogOut(username:string){ |
| 77 | +awaitthis.page.getByTitle(username,{exact:true}).click(); |
| 78 | +awaitthis.page.getByText('Log Out').click({delay:1000}); |
| 79 | +} |
| 80 | + |
| 81 | +} |