-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
10 changed files
with
291 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import {getEndpointDefinition} from '../utils'; | ||
import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; | ||
|
||
test("Aetna Login Flow", async ({page}) => { | ||
|
||
//get the Cerner Sandbox endpoint definition | ||
let endpointDefinition = await getEndpointDefinition('ac8308d1-90de-4994-bb3d-fe404832714c') | ||
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("text=Welcome to Aetna"); | ||
// await expect(page).toHaveTitle("Cerner Health - Sign In"); | ||
await page.click("label[for='username']", { force: true }); | ||
await page.keyboard.type("aetnaTestUser3 "); | ||
await page.click("label[for='password']", { force: true }); | ||
await page.keyboard.type("FHIRdemo2020"); | ||
await page.click("#loginButton"); | ||
|
||
// If successful, Fasten Lighthouse page should now be visible | ||
await page.waitForSelector("text=Your account has been securely connected to FASTEN."); | ||
}); |
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,40 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import {getEndpointDefinition} from '../utils'; | ||
import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; | ||
|
||
test("Cerner Login Flow", async ({page}) => { | ||
test.skip() | ||
//get the Cerner Sandbox endpoint definition | ||
let endpointDefinition = await getEndpointDefinition('3290e5d7-978e-42ad-b661-1cf8a01a989c') | ||
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("text=FhirPlay Non-Prod"); | ||
await expect(page).toHaveTitle("Cerner Health - Sign In"); | ||
await page.click("label[for='id_login_username']", { force: true }); | ||
await page.keyboard.type("nancysmart"); | ||
await page.click("label[for='id_login_password']", { force: true }); | ||
await page.keyboard.type("Cerner01"); | ||
await page.click("#signin"); | ||
|
||
// We have logged in | ||
await page.waitForSelector("text=Warning: Unknown app"); | ||
await expect(page).toHaveTitle("Authorization Needed"); | ||
await page.click('#proceedButton'); | ||
|
||
// We are on the Select Patient page. | ||
await page.waitForSelector("text=SMART II, NANCY (Self, 33)"); | ||
await expect(page).toHaveTitle("Authorization Needed"); | ||
await page.click("label[for='12724066']", { force: true, delay: 500 }); | ||
await page.click("#allowButton"); | ||
|
||
|
||
// If successful, Fasten Lighthouse page should now be visible | ||
await page.waitForSelector("text=Your account has been securely connected to FASTEN."); | ||
}); |
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,124 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import {getEndpointDefinition} from '../utils'; | ||
import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; | ||
|
||
test("Epic OAuth2 Legacy Login Flow", async ({page}) => { | ||
test.skip() | ||
|
||
//get the Epic Sandbox endpoint definition | ||
let endpointDefinition = await getEndpointDefinition('fc94bfc7-684d-4e4d-aa6e-ceec01c21c81') | ||
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 MyChart login page | ||
await page.waitForSelector("text=MyChart Username"); | ||
await expect(page).toHaveTitle("MyChart - Login Page"); | ||
await page.click("label[for='Login']", { force: true }); | ||
await page.keyboard.type("fhirderrick"); | ||
await page.click("label[for='Password']", { force: true }); | ||
await page.keyboard.type("epicepic1"); | ||
await page.click("text=Sign In"); | ||
|
||
// We have logged in to MyChart | ||
await page.waitForSelector("text=Fasten Health has said that it:"); | ||
await page.locator('text=Continue') //wait for continue button | ||
await expect(page).toHaveTitle("MyChart - Are you sure?"); | ||
await page.getByTitle("Continue to next page").click(); | ||
|
||
|
||
// We are on the MyChart authorize page. Authorize our app for 1 hour. | ||
await page.waitForSelector("text=What would you like to share?"); | ||
await expect(page).toHaveTitle("MyChart - Are you sure?"); | ||
// await page.click('text=3 months', { force: true, delay: 1000 }); | ||
await page.click("text=Allow access", { force: true, delay: 500 }); | ||
|
||
// MyChart has granted access, redirecting back to app from MyChart | ||
await page.waitForSelector("text=Epic FHIR Dynamic Registration Redirect"); | ||
|
||
// Should auto redirect if successful, but playwright Chrome seems to have issues so we'll manually click if needed | ||
try { | ||
await page.click("text=Back to main page", { force: true, delay: 5000 }); | ||
} catch (e) {} | ||
|
||
// If successful, Dynamic Client Registration Data should now be visible | ||
await page.waitForSelector("text=Dynamic Client Registration Data"); | ||
|
||
|
||
|
||
// await expect(page).toHaveTitle("MyChart - Are you sure?"); | ||
// await page.getByTitle("Continue to next page").click({ | ||
// force: true, | ||
// delay: 1000, | ||
// }); | ||
// | ||
// // We are on the MyChart authorize page. Authorize our app for 1 hour. | ||
// await page.waitForSelector("text=What would you like to share?"); | ||
// await expect(page).toHaveTitle("MyChart - Are you sure?"); | ||
// // await page.click('text=3 months', { force: true, delay: 1000 }); | ||
// await page.click("text=Allow access", { force: true, delay: 500 }); | ||
// | ||
// // Should auto redirect if successful, but playwright Chrome seems to have issues so we'll manually click if needed | ||
// try { | ||
// await page.click("text=Back to main page", { force: true, delay: 5000 }); | ||
// } catch (e) {} | ||
// | ||
// // MyChart has granted access, redirecting back to app from MyChart | ||
// await page.waitForSelector("text=Your account has been securely connected to FASTEN.") | ||
// await expect((new URL(page.url())).searchParams.get("code")).toBeTruthy() | ||
}); | ||
// | ||
// const expirationOptions = ["1 hour", "1 day", "1 week", "1 month", "3 months"]; | ||
// for (const timeOption of expirationOptions) { | ||
// test(`Epic OAuth2 Login Flow with Dynamic Registration Works with '${timeOption}' Expiration Option Selected`, async ({ | ||
// page, | ||
// }) => { | ||
// await page.goto("http:https://localhost:5173/"); | ||
// | ||
// // Before we log in, there should be no dynamic client data | ||
// await page.waitForSelector( | ||
// "text=After you log in, your dynamic client data will show here" | ||
// ); | ||
// | ||
// // Start login flow by clicking on button with text "Login to MyChart" | ||
// await page.click("text=Login to MyChart"); | ||
// | ||
// // We are on MyChart login page | ||
// await page.waitForSelector("text=MyChart Username"); | ||
// await expect(page).toHaveTitle("MyChart - Login Page"); | ||
// await page.click("label[for='Login']", { force: true }); | ||
// await page.keyboard.type("fhirderrick"); | ||
// await page.click("label[for='Password']", { force: true }); | ||
// await page.keyboard.type("epicepic1"); | ||
// await page.click("text=Sign In"); | ||
// | ||
// // We have logged in to MyChart | ||
// await page.waitForSelector("text=Not a Company at all has said that it:"); | ||
// await expect(page).toHaveTitle("MyChart - Are you sure?"); | ||
// await page.getByTitle("Continue to next page").click({ | ||
// force: true, | ||
// delay: 1000, | ||
// }); | ||
// | ||
// // We are on the MyChart authorize page. Authorize our app for 1 hour. | ||
// await page.waitForSelector("text=What would you like to share?"); | ||
// await expect(page).toHaveTitle("MyChart - Are you sure?"); | ||
// await page.click(`text=${timeOption}`, { force: true, delay: 1000 }); | ||
// await page.click("text=Allow access", { force: true, delay: 500 }); | ||
// | ||
// // MyChart has granted access, redirecting back to app from MyChart | ||
// await page.waitForSelector("text=Epic FHIR Dynamic Registration Redirect"); | ||
// | ||
// // Should auto redirect if successful, but playwright Chrome seems to have issues so we'll manually click if needed | ||
// try { | ||
// await page.click("text=Back to main page", { force: true, delay: 5000 }); | ||
// } catch (e) {} | ||
// | ||
// // If successful, Dynamic Client Registration Data should now be visible | ||
// await page.waitForSelector("text=Dynamic Client Registration Data"); | ||
// }); | ||
// } |
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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
// @ts-check | ||
import { test, expect } from'@playwright/test'; | ||
|
||
test('Local Testing', async ({ page },testInfo) => { | ||
|
||
try{ | ||
|
||
await page.evaluate(_ => {},`browserstack_executor: ${JSON.stringify({action: "setSessionName", arguments: {name:testInfo.project.name}})}`); | ||
|
||
await page.waitForTimeout(5000); | ||
|
||
await page.goto('https://www.example.com/'); | ||
|
||
await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'passed',reason: 'Local success'}})}`); | ||
|
||
} catch (e) { | ||
console.log(e); | ||
await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'failed',reason: 'Local fail'}})}`); | ||
|
||
} | ||
|
||
}); | ||
// test('Local Testing', async ({ page },testInfo) => { | ||
// | ||
// try{ | ||
// | ||
// await page.evaluate(_ => {},`browserstack_executor: ${JSON.stringify({action: "setSessionName", arguments: {name:testInfo.project.name}})}`); | ||
// | ||
// await page.waitForTimeout(5000); | ||
// | ||
// await page.goto('https://www.example.com/'); | ||
// | ||
// await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'passed',reason: 'Local success'}})}`); | ||
// | ||
// } catch (e) { | ||
// console.log(e); | ||
// await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'failed',reason: 'Local fail'}})}`); | ||
// | ||
// } | ||
// | ||
// }); |
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 |
---|---|---|
@@ -1,40 +1,40 @@ | ||
// @ts-check | ||
import { test, expect } from'@playwright/test'; | ||
|
||
test('BstackDemo Add to cart', async ({ page },testInfo) => { | ||
|
||
try{ | ||
|
||
await page.evaluate(_ => {},`browserstack_executor: ${JSON.stringify({action: "setSessionName", arguments: {name:testInfo.project.name}})}`); | ||
await page.waitForTimeout(5000); | ||
|
||
await page.goto('https://www.bstackdemo.com/',{ waitUntil: 'networkidle' }); | ||
await page.locator('[id="\\32 "]').getByText('Add to cart').click(); | ||
await page.getByText('Checkout').click(); | ||
await page.locator('#username svg').click(); | ||
await page.locator('#react-select-2-option-0-0').click(); | ||
await page.locator('#password svg').click(); | ||
await page.locator('#react-select-3-option-0-0').click(); | ||
await page.getByRole('button', { name: 'Log In' }).click(); | ||
await page.getByLabel('First Name').click(); | ||
await page.getByLabel('First Name').fill('SampleFirst'); | ||
await page.getByLabel('Last Name').click(); | ||
await page.getByLabel('Last Name').fill('sampleLast'); | ||
await page.getByLabel('Address').click(); | ||
await page.getByLabel('Address').fill('sampleAddress'); | ||
await page.getByLabel('State/Province').click(); | ||
await page.getByLabel('State/Province').fill('SampleState'); | ||
await page.getByLabel('Postal Code').click(); | ||
await page.getByLabel('Postal Code').fill('123456'); | ||
await page.getByRole('button', { name: 'Submit' }).click(); | ||
await page.getByRole('button', { name: 'Continue Shopping »' }).click(); | ||
|
||
await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'passed',reason: 'Product added to cart'}})}`); | ||
|
||
} catch (e) { | ||
console.log(e); | ||
await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'failed',reason: 'Test failed'}})}`); | ||
|
||
} | ||
|
||
}); | ||
// test('BstackDemo Add to cart', async ({ page },testInfo) => { | ||
// | ||
// try{ | ||
// | ||
// await page.evaluate(_ => {},`browserstack_executor: ${JSON.stringify({action: "setSessionName", arguments: {name:testInfo.project.name}})}`); | ||
// await page.waitForTimeout(5000); | ||
// | ||
// await page.goto('https://www.bstackdemo.com/',{ waitUntil: 'networkidle' }); | ||
// await page.locator('[id="\\32 "]').getByText('Add to cart').click(); | ||
// await page.getByText('Checkout').click(); | ||
// await page.locator('#username svg').click(); | ||
// await page.locator('#react-select-2-option-0-0').click(); | ||
// await page.locator('#password svg').click(); | ||
// await page.locator('#react-select-3-option-0-0').click(); | ||
// await page.getByRole('button', { name: 'Log In' }).click(); | ||
// await page.getByLabel('First Name').click(); | ||
// await page.getByLabel('First Name').fill('SampleFirst'); | ||
// await page.getByLabel('Last Name').click(); | ||
// await page.getByLabel('Last Name').fill('sampleLast'); | ||
// await page.getByLabel('Address').click(); | ||
// await page.getByLabel('Address').fill('sampleAddress'); | ||
// await page.getByLabel('State/Province').click(); | ||
// await page.getByLabel('State/Province').fill('SampleState'); | ||
// await page.getByLabel('Postal Code').click(); | ||
// await page.getByLabel('Postal Code').fill('123456'); | ||
// await page.getByRole('button', { name: 'Submit' }).click(); | ||
// await page.getByRole('button', { name: 'Continue Shopping »' }).click(); | ||
// | ||
// await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'passed',reason: 'Product added to cart'}})}`); | ||
// | ||
// } catch (e) { | ||
// console.log(e); | ||
// await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'failed',reason: 'Test failed'}})}`); | ||
// | ||
// } | ||
// | ||
// }); |
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,18 @@ | ||
import {LighthouseEndpointDefinition} from '../src'; | ||
|
||
export const lighthouseEndpointLookup = { | ||
'sandbox': 'https://lighthouse.fastenhealth.com/sandbox/', | ||
'prod': 'https://lighthouse.fastenhealth.com/v1/' | ||
} | ||
|
||
export async function getEndpointDefinition(endpoint_id: string): Promise<LighthouseEndpointDefinition> { | ||
|
||
let lighthouseEndpoint = lighthouseEndpointLookup['sandbox'] | ||
|
||
return await fetch( lighthouseEndpoint + 'connect/' + endpoint_id) | ||
.then(resp => resp.json()) | ||
.then(response => { | ||
console.log(response) | ||
return response.data as LighthouseEndpointDefinition | ||
}) | ||
} |
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 |
---|---|---|
|
@@ -6,12 +6,14 @@ | |
"types": "index.d.ts", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"e2e": "npx playwright test" | ||
"e2e": "npx playwright test --headed", | ||
"e2e-debug": "npx playwright test --headed --debug" | ||
}, | ||
"author": "Jason Kulatunga <[email protected]>", | ||
"dependencies": { | ||
"@panva/oauth4webapi": "1.2.0" | ||
}, | ||
"type": "module", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
|
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
Oops, something went wrong.