Refactored to store user details elsewhere
This commit is contained in:
parent
31e1f119e7
commit
d70effc7a4
|
@ -1,9 +1,9 @@
|
|||
import * as nodeFetch from "node-fetch"
|
||||
|
||||
export const getLoginToken = async () => {
|
||||
export const getLoginToken = async (username, password) => {
|
||||
const response = await nodeFetch("http://localhost:2221/api/login", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ "username": "admin", "password":"Admin123" })
|
||||
body: JSON.stringify({ "username": username, "password":password })
|
||||
})
|
||||
|
||||
if(response.status !== 200) {
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
export const adminDetails = {
|
||||
username: "kira",
|
||||
password: "secret"
|
||||
}
|
|
@ -3,10 +3,11 @@ 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}) => {
|
||||
import { adminDetails } from "../data/userDetails.js"
|
||||
|
||||
const loginToken = await getLoginToken()
|
||||
console.warn({loginToken})
|
||||
test.only("My Account using cookie injection", async ({page}) => {
|
||||
const loginToken = await getLoginToken(adminDetails.username,
|
||||
adminDetails.password)
|
||||
|
||||
const myAccount = new MyAccountPage(page)
|
||||
await myAccount.visit()
|
||||
|
@ -16,4 +17,5 @@ test.only("My Account using cookie injection", async ({page}) => {
|
|||
}, [loginToken])
|
||||
await myAccount.visit()
|
||||
await myAccount.checkForLogin()
|
||||
await page.pause()
|
||||
})
|
Loading…
Reference in New Issue