-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Amy Chen
committed
Nov 21, 2024
1 parent
7b7774c
commit 10d3ead
Showing
4 changed files
with
83 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const testPatientEmail = process.env.testPatientEmail; | ||
export const testPatientPassword = process.env.testPatientPassword; | ||
export const testStaffEmail = process.env.testStaffEmail; | ||
export const testStaffPassword = process.env.testStaffPassword; | ||
export const homePageURL = process.env.homePageURL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import "expect-puppeteer"; | ||
import puppeteer from "puppeteer"; | ||
import { testStaffEmail, testStaffPassword, homePageURL } from "./consts"; | ||
|
||
//test variables | ||
// const homePageURL = "https://eproms-test.cirg.washington.edu"; | ||
// const testPatientEmail = atob("YWNoZW4yNDAxK3Rlc3QxMTFAZ21haWwuY29t"); | ||
// const testPatientPassword = atob("RWxlYW5vcjI="); | ||
|
||
describe("Login in to Staff Home Page", () => { | ||
const TIMEOUT_DURATION = 30000; | ||
jest.setTimeout(TIMEOUT_DURATION); | ||
let browser, page; | ||
beforeAll(async () => { | ||
await jestPuppeteer.resetBrowser(); | ||
await jestPuppeteer.resetPage(); | ||
browser = await puppeteer.launch(); | ||
page = await browser.newPage(); | ||
const timeout = TIMEOUT_DURATION; | ||
page.setDefaultTimeout(timeout); | ||
await page.goto(homePageURL); | ||
await page.setViewport({ | ||
width: 1477, | ||
height: 890, | ||
}); | ||
}); | ||
|
||
afterAll(async () => { | ||
browser.close(); | ||
}); | ||
|
||
it('should display "Log in" text on page', async () => { | ||
await expect(page).toMatchTextContent(/Log in/); | ||
}); | ||
|
||
it("should fill in login form", async () => { | ||
await page.locator("#email").click({ | ||
offset: { | ||
x: 108.5, | ||
y: 17.21875, | ||
}, | ||
}); | ||
await page.locator("#email").fill(testStaffEmail); | ||
await page.keyboard.down("Tab"); | ||
await page.keyboard.up("Tab"); | ||
await page.locator("#password").fill(testStaffPassword); | ||
}); | ||
|
||
it("should set remember me cookie", async () => { | ||
let expirationDate = new Date(); | ||
expirationDate.setDate(expirationDate.getDate() + 17); | ||
await page.setCookie({ | ||
name: "Truenth2FA_REMEMBERME", | ||
value: encodeURIComponent(btoa(new Date().getTime())), | ||
path: "/", | ||
expires: expirationDate.valueOf(), | ||
}); | ||
}); | ||
|
||
it("should click submit button", async () => { | ||
await page.locator("#btnLogin").click(); | ||
}); | ||
|
||
// failed due to 2FA, skip it | ||
it.skip("should have staff list on page", async () => { | ||
await page.waitForSelector("#staffList"); | ||
await expect(page).toMatchElement("#staffList"); | ||
}); | ||
}); |