From 31e1f119e790d57d0e5033b0892c17d4ba7c4c75 Mon Sep 17 00:00:00 2001 From: Kira Date: Mon, 18 Sep 2023 11:16:50 -0700 Subject: [PATCH] Using token to inject into dom, logs in --- page-objects/MyAccountPage.js | 5 +++++ tests/my_account.spec.js | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/page-objects/MyAccountPage.js b/page-objects/MyAccountPage.js index 0671fd1..d729722 100644 --- a/page-objects/MyAccountPage.js +++ b/page-objects/MyAccountPage.js @@ -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() + } } \ No newline at end of file diff --git a/tests/my_account.spec.js b/tests/my_account.spec.js index 37b6bb7..ef86421 100644 --- a/tests/my_account.spec.js +++ b/tests/my_account.spec.js @@ -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() }) \ No newline at end of file