Using token to inject into dom, logs in

This commit is contained in:
Kira 2023-09-18 11:16:50 -07:00
parent 8edcdd925d
commit 31e1f119e7
2 changed files with 11 additions and 1 deletions

View File

@ -1,9 +1,14 @@
export class MyAccountPage {
constructor(page) {
this.page = page
this.myAccountHeader = page.getByRole('heading', { name: 'My Account' })
}
visit = async () => {
await this.page.goto("/my-account")
}
checkForLogin = async () => {
await this.myAccountHeader.waitFor()
}
}

View File

@ -10,5 +10,10 @@ test.only("My Account using cookie injection", async ({page}) => {
const myAccount = new MyAccountPage(page)
await myAccount.visit()
await page.pause()
await page.evaluate(([loginTokenInjected]) => {
document.cookie = "token=" + loginTokenInjected
}, [loginToken])
await myAccount.visit()
await myAccount.checkForLogin()
})