import { test } from "@playwright/test"

import { MyAccountPage } from "../page-objects/MyAccountPage.js"
import { getLoginToken } from "../api-calls/getLoginToken.js"

test.only("My Account using cookie injection", async ({page}) => {

    const loginToken = await getLoginToken()
    console.warn({loginToken})
    
    const myAccount = new MyAccountPage(page)
    await myAccount.visit()

    await page.evaluate(([loginTokenInjected]) => {
        document.cookie = "token=" + loginTokenInjected
    }, [loginToken])
    await myAccount.visit()
    await myAccount.checkForLogin()
})