-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
careevolution_test.ts
41 lines (34 loc) · 2.02 KB
/
careevolution_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { test, expect } from "@playwright/test";
import {getEndpointDefinition} from '../utils';
import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url';
test("CareEvolution Login Flow", async ({page}, testInfo) => {
try {
await page.evaluate(_ => {},`browserstack_executor: ${JSON.stringify({action: "setSessionName", arguments: {name:testInfo.title}})}`);
await page.waitForTimeout(5000);
//get the CareEvolution Sandbox endpoint definition
let endpointDefinition = await getEndpointDefinition('8b47cf7b-330e-4ede-9967-4caa7be623aa')
let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition)
// authorizeData.sourceState
console.log(authorizeData.url.toString())
// Start login flow by clicking on button with text "Login to MyChart"
await page.goto(authorizeData.url.toString());
// We are on login page
await page.waitForSelector("#login-button");
await page.focus("#Username");
await page.keyboard.type("CEPatient");
await page.focus("#Password");
await page.keyboard.type("CEPatient2018");
await page.click("#login-button");
// We have logged in
await page.waitForSelector("text=Whose record do you want to allow access to?");
// await expect(page).toHaveText("Authorization Request");
await page.locator("text=Fran Demoski (28)").click();
await page.click('input[value="Agree"]');
// If successful, Fasten Lighthouse page should now be visible
await page.waitForSelector("text=Your account has been securely connected to FASTEN.");
await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'passed',reason: 'Authentication Successful'}})}`);
} catch (e) {
console.log(e);
await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'failed',reason: 'Test failed'}})}`);
}
});