From 1d52e8f2f13bac332204073e9f691e94a12543cb Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Thu, 30 May 2024 10:56:35 -0700 Subject: [PATCH 01/11] working tests. --- .gitignore | 4 + README.md | 7 ++ js/e2e/browserstack.config.ts | 52 ++++++++ js/e2e/global-setup.ts | 25 ++++ js/e2e/global-teardown.ts | 18 +++ js/e2e/protractor.conf.js | 32 +++++ js/e2e/src/local_test.ts | 22 ++++ js/e2e/src/sample_test.ts | 40 ++++++ js/e2e/tsconfig.json | 13 ++ js/package.json | 8 +- js/playwright.config.ts | 85 +++++++++++++ js/yarn.lock | 221 ++++++++++++++++++++++++++++++++++ 12 files changed, 526 insertions(+), 1 deletion(-) create mode 100644 js/e2e/browserstack.config.ts create mode 100644 js/e2e/global-setup.ts create mode 100644 js/e2e/global-teardown.ts create mode 100644 js/e2e/protractor.conf.js create mode 100644 js/e2e/src/local_test.ts create mode 100644 js/e2e/src/sample_test.ts create mode 100644 js/e2e/tsconfig.json create mode 100644 js/playwright.config.ts diff --git a/.gitignore b/.gitignore index dc9b0da7b..8cee4aa42 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,7 @@ js/dist js/node_modules + +js/local.log +js/playwright-report +js/test-results diff --git a/README.md b/README.md index 801fb30dc..5fb5070e3 100644 --- a/README.md +++ b/README.md @@ -57,3 +57,10 @@ ones that Fasten supports | [clients/internal/source](./clients/internal/source) | Automatically created OAuth clients for accessing production data from various healthcare institutions. Usually inherit from Platform clients | | [definitions](./definitions/) | Automatically created definition files. These files are generated from files created by `fasten-sources-gen` and are used by Fasten Lighthouse. | + + +# References + +## NPM Library +- https://www.tsmean.com/articles/learn-typescript/typescript-module-compiler-option/ +- diff --git a/js/e2e/browserstack.config.ts b/js/e2e/browserstack.config.ts new file mode 100644 index 000000000..3a81229cf --- /dev/null +++ b/js/e2e/browserstack.config.ts @@ -0,0 +1,52 @@ +import * as cp from 'child_process'; +const clientPlaywrightVersion = cp + .execSync('npx playwright --version') + .toString() + .trim() + .split(' ')[1]; +import * as BrowserStackLocal from'browserstack-local'; +import * as util from'util'; +import process from 'process'; + +// BrowserStack Specific Capabilities. +// Set 'browserstack.local:true For Local testing +const caps = { + browser: 'chrome', + os: 'osx', + os_version: 'catalina', + name: 'My first playwright test', + build: 'playwright-build', + 'browserstack.username': process.env.BROWSERSTACK_USERNAME || 'USERNAME', + 'browserstack.accessKey': process.env.BROWSERSTACK_ACCESS_KEY || 'ACCESSKEY', + 'browserstack.local': process.env.BROWSERSTACK_LOCAL || true, + 'client.playwrightVersion': clientPlaywrightVersion, +}; + +export const bsLocal = new BrowserStackLocal.Local(); + +// replace YOUR_ACCESS_KEY with your key. You can also set an environment variable - "BROWSERSTACK_ACCESS_KEY". +export const BS_LOCAL_ARGS = { + key: process.env.BROWSERSTACK_ACCESS_KEY || 'ACCESSKEY', +}; + +// Patching the capabilities dynamically according to the project name. +const patchCaps = (name, title) => { + let combination = name.split(/@browserstack/)[0]; + let [browerCaps, osCaps] = combination.split(/:/); + let [browser, browser_version] = browerCaps.split(/@/); + let osCapsSplit = osCaps.split(/ /); + let os = osCapsSplit.shift(); + let os_version = osCapsSplit.join(' '); + caps.browser = browser ? browser : 'chrome'; + caps.os_version = browser_version ? browser_version : 'latest'; + caps.os = os ? os : 'osx'; + caps.os_version = os_version ? os_version : 'catalina'; + caps.name = title; +}; + +export function getCdpEndpoint(name, title){ + patchCaps(name, title) + const cdpUrl = `wss://cdp.browserstack.com/playwright?caps=${encodeURIComponent(JSON.stringify(caps))}` + console.log(`--> ${cdpUrl}`) + return cdpUrl; +} diff --git a/js/e2e/global-setup.ts b/js/e2e/global-setup.ts new file mode 100644 index 000000000..b274a39b8 --- /dev/null +++ b/js/e2e/global-setup.ts @@ -0,0 +1,25 @@ +// global-setup.js +import { bsLocal, BS_LOCAL_ARGS } from './browserstack.config'; +import { promisify } from 'util'; +const sleep = promisify(setTimeout); +const redColour = '\x1b[31m'; +const whiteColour = '\x1b[0m'; + +export default async function setup() { + console.log('Starting BrowserStackLocal ...'); + // Starts the Local instance with the required arguments + let localResponseReceived = false; + bsLocal.start(BS_LOCAL_ARGS, (err) => { + if (err) { + console.error( + `${redColour}Error starting BrowserStackLocal${whiteColour}` + ); + } else { + console.log('BrowserStackLocal Started'); + } + localResponseReceived = true; + }); + while (!localResponseReceived) { + await sleep(1000); + } +}; diff --git a/js/e2e/global-teardown.ts b/js/e2e/global-teardown.ts new file mode 100644 index 000000000..5fdc17bd3 --- /dev/null +++ b/js/e2e/global-teardown.ts @@ -0,0 +1,18 @@ +// global-teardown.js +import { bsLocal } from './browserstack.config'; +import { promisify } from'util'; +const sleep = promisify(setTimeout); +export default async function teardown(){ + // Stop the Local instance after your test run is completed, i.e after driver.quit + let localStopped = false; + + if (bsLocal && bsLocal.isRunning()) { + bsLocal.stop(() => { + localStopped = true; + console.log('Stopped BrowserStackLocal'); + }); + while (!localStopped) { + await sleep(1000); + } + } +} diff --git a/js/e2e/protractor.conf.js b/js/e2e/protractor.conf.js new file mode 100644 index 000000000..7c798cfff --- /dev/null +++ b/js/e2e/protractor.conf.js @@ -0,0 +1,32 @@ +// @ts-check +// Protractor configuration file, see link for more information +// https://github.com/angular/protractor/blob/master/lib/config.ts + +const { SpecReporter } = require('jasmine-spec-reporter'); + +/** + * @type { import("protractor").Config } + */ +exports.config = { + allScriptsTimeout: 11000, + specs: [ + './src/**/*.e2e-spec.ts' + ], + capabilities: { + browserName: 'chrome' + }, + directConnect: true, + baseUrl: 'http://localhost:4200/', + framework: 'jasmine', + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} + }, + onPrepare() { + require('ts-node').register({ + project: require('path').join(__dirname, './tsconfig.json') + }); + jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); + } +}; \ No newline at end of file diff --git a/js/e2e/src/local_test.ts b/js/e2e/src/local_test.ts new file mode 100644 index 000000000..7d4fe0303 --- /dev/null +++ b/js/e2e/src/local_test.ts @@ -0,0 +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'}})}`); + +} + +}); diff --git a/js/e2e/src/sample_test.ts b/js/e2e/src/sample_test.ts new file mode 100644 index 000000000..057876519 --- /dev/null +++ b/js/e2e/src/sample_test.ts @@ -0,0 +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'}})}`); + +} + +}); diff --git a/js/e2e/tsconfig.json b/js/e2e/tsconfig.json new file mode 100644 index 000000000..f62c43789 --- /dev/null +++ b/js/e2e/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/e2e", + "module": "commonjs", + "target": "es2020", + "types": [ + "jasmine", + "jasminewd2", + "node" + ] + } +} diff --git a/js/package.json b/js/package.json index 7f4327dbb..92adbcd9b 100644 --- a/js/package.json +++ b/js/package.json @@ -5,7 +5,8 @@ "main": "index.js", "types": "index.d.ts", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "e2e": "npx playwright test" }, "author": "Jason Kulatunga ", "dependencies": { @@ -13,5 +14,10 @@ }, "publishConfig": { "access": "public" + }, + "devDependencies": { + "@playwright/test": "^1.44.1", + "browserstack-local": "^1.5.5", + "typescript": "^5.4.5" } } diff --git a/js/playwright.config.ts b/js/playwright.config.ts new file mode 100644 index 000000000..9c19c1d5d --- /dev/null +++ b/js/playwright.config.ts @@ -0,0 +1,85 @@ +// @ts-check +import { devices } from'@playwright/test'; +import { getCdpEndpoint } from './e2e/browserstack.config.ts' +import process from 'process'; +import * as path from 'path'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + + +/** + * @see https://playwright.dev/docs/test-configuration + * @type {import('@playwright/test').PlaywrightTestConfig} + */ +export default { + testDir: './e2e/src', + testMatch: '**/*.ts', + + globalSetup: path.join( path.dirname("."), 'e2e/global-setup.ts'), + globalTeardown: path.join( path.dirname("."),'./e2e/global-teardown.ts'), + + /* Maximum time one test can run for. */ + timeout: 90 * 1000, + expect: { + /** + * Maximum time expect() should wait for the condition to be met. + * For example in `await expect(locator).toHaveText();` + */ + timeout: 5000 + }, + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: 'html', + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ + actionTimeout: 0, + /* Base URL to use in actions like `await page.goto('/')`. */ + // baseURL: 'http://localhost:3000', + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'chrome@latest:Windows 11', + use: { + connectOptions: { wsEndpoint: getCdpEndpoint('chrome@latest:Windows 11','test1') }, + }, + } + // { + // name: 'playwright-webkit@latest:OSX Ventura', + // use: { + // connectOptions: { wsEndpoint: getCdpEndpoint('playwright-webkit@latest:OSX Ventura', 'test2') } + // }, + // }, + // { + // name: 'playwright-firefox:Windows 11', + // use: { + // connectOptions: { wsEndpoint: getCdpEndpoint('playwright-firefox:Windows 11', 'test3') } + // }, + // } + ], + + /* Folder for test artifacts such as screenshots, videos, traces, etc. */ + // outputDir: 'test-results/', + + /* Run your local dev server before starting the tests */ + // webServer: { + // command: 'npm run start', + // port: 3000, + // }, +}; diff --git a/js/yarn.lock b/js/yarn.lock index 6d414b42b..364b5f0fe 100644 --- a/js/yarn.lock +++ b/js/yarn.lock @@ -6,3 +6,224 @@ version "1.2.0" resolved "https://registry.npmjs.org/@panva/oauth4webapi/-/oauth4webapi-1.2.0.tgz#f0bce0da0953dd8f8c091af77d559fddf44f1b0f" integrity sha512-OmwAE3fzlSJsA0zzCWA/ob7Nwb7nwzku8vbAjgmnkkVYbpyokBsaVrrzog9cM0RMytXexpNNcbQbMF/UNa71mg== + +"@playwright/test@^1.44.1": + version "1.44.1" + resolved "https://registry.npmjs.org/@playwright/test/-/test-1.44.1.tgz#cc874ec31342479ad99838040e99b5f604299bcb" + integrity sha512-1hZ4TNvD5z9VuhNJ/walIjvMVvYkZKf71axoF/uiAqpntQJXpG64dlXhoDXE3OczPuTuvjf/M5KWFg5VAVUS3Q== + dependencies: + playwright "1.44.1" + +agent-base@6, agent-base@^6.0.2: + version "6.0.2" + resolved "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" + integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ== + dependencies: + debug "4" + +balanced-match@^1.0.0: + version "1.0.2" + resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +browserstack-local@^1.5.5: + version "1.5.5" + resolved "https://registry.npmjs.org/browserstack-local/-/browserstack-local-1.5.5.tgz#f36b625f3b8bfd053f673d85fd1082f2d0759693" + integrity sha512-jKne7yosrMcptj3hqxp36TP9k0ZW2sCqhyurX24rUL4G3eT7OLgv+CSQN8iq5dtkv5IK+g+v8fWvsiC/S9KxMg== + dependencies: + agent-base "^6.0.2" + https-proxy-agent "^5.0.1" + is-running "^2.1.0" + ps-tree "=1.2.0" + temp-fs "^0.9.9" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== + +debug@4: + version "4.3.4" + resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + +duplexer@~0.1.1: + version "0.1.2" + resolved "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6" + integrity sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg== + +event-stream@=3.3.4: + version "3.3.4" + resolved "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz#4ab4c9a0f5a54db9338b4c34d86bfce8f4b35571" + integrity sha512-QHpkERcGsR0T7Qm3HNJSyXKEEj8AHNxkY3PK8TS2KJvQ7NiSHe3DDpwVKKtoYprL/AreyzFBeIkBIWChAqn60g== + dependencies: + duplexer "~0.1.1" + from "~0" + map-stream "~0.1.0" + pause-stream "0.0.11" + split "0.3" + stream-combiner "~0.0.4" + through "~2.3.1" + +from@~0: + version "0.1.7" + resolved "https://registry.npmjs.org/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe" + integrity sha512-twe20eF1OxVxp/ML/kq2p1uc6KvFK/+vs8WjEbeKmV2He22MKm7YF2ANIt+EOqhJ5L3K/SuuPhk0hWQDjOM23g== + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== + +fsevents@2.3.2: + version "2.3.2" + resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + +glob@^7.0.5: + version "7.2.3" + resolved "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" + integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.1.1" + once "^1.3.0" + path-is-absolute "^1.0.0" + +https-proxy-agent@^5.0.1: + version "5.0.1" + resolved "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz#c59ef224a04fe8b754f3db0063a25ea30d0005d6" + integrity sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA== + dependencies: + agent-base "6" + debug "4" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2: + version "2.0.4" + resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +is-running@^2.1.0: + version "2.1.0" + resolved "https://registry.npmjs.org/is-running/-/is-running-2.1.0.tgz#30a73ff5cc3854e4fc25490809e9f5abf8de09e0" + integrity sha512-mjJd3PujZMl7j+D395WTIO5tU5RIDBfVSRtRR4VOJou3H66E38UjbjvDGh3slJzPuolsb+yQFqwHNNdyp5jg3w== + +map-stream@~0.1.0: + version "0.1.0" + resolved "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194" + integrity sha512-CkYQrPYZfWnu/DAmVCpTSX/xHpKZ80eKh2lAkyA6AJTef6bW+6JpbQZN5rofum7da+SyN1bi5ctTm+lTfcCW3g== + +minimatch@^3.1.1: + version "3.1.2" + resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + +ms@2.1.2: + version "2.1.2" + resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== + dependencies: + wrappy "1" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== + +pause-stream@0.0.11: + version "0.0.11" + resolved "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" + integrity sha512-e3FBlXLmN/D1S+zHzanP4E/4Z60oFAa3O051qt1pxa7DEJWKAyil6upYVXCWadEnuoqa4Pkc9oUx9zsxYeRv8A== + dependencies: + through "~2.3" + +playwright-core@1.44.1: + version "1.44.1" + resolved "https://registry.npmjs.org/playwright-core/-/playwright-core-1.44.1.tgz#53ec975503b763af6fc1a7aa995f34bc09ff447c" + integrity sha512-wh0JWtYTrhv1+OSsLPgFzGzt67Y7BE/ZS3jEqgGBlp2ppp1ZDj8c+9IARNW4dwf1poq5MgHreEM2KV/GuR4cFA== + +playwright@1.44.1: + version "1.44.1" + resolved "https://registry.npmjs.org/playwright/-/playwright-1.44.1.tgz#5634369d777111c1eea9180430b7a184028e7892" + integrity sha512-qr/0UJ5CFAtloI3avF95Y0L1xQo6r3LQArLIg/z/PoGJ6xa+EwzrwO5lpNr/09STxdHuUoP2mvuELJS+hLdtgg== + dependencies: + playwright-core "1.44.1" + optionalDependencies: + fsevents "2.3.2" + +ps-tree@=1.2.0: + version "1.2.0" + resolved "https://registry.npmjs.org/ps-tree/-/ps-tree-1.2.0.tgz#5e7425b89508736cdd4f2224d028f7bb3f722ebd" + integrity sha512-0VnamPPYHl4uaU/nSFeZZpR21QAWRz+sRv4iW9+v/GS/J5U5iZB5BNN6J0RMoOvdx2gWM2+ZFMIm58q24e4UYA== + dependencies: + event-stream "=3.3.4" + +rimraf@~2.5.2: + version "2.5.4" + resolved "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" + integrity sha512-Lw7SHMjssciQb/rRz7JyPIy9+bbUshEucPoLRvWqy09vC5zQixl8Uet+Zl+SROBB/JMWHJRdCk1qdxNWHNMvlQ== + dependencies: + glob "^7.0.5" + +split@0.3: + version "0.3.3" + resolved "https://registry.npmjs.org/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f" + integrity sha512-wD2AeVmxXRBoX44wAycgjVpMhvbwdI2aZjCkvfNcH1YqHQvJVa1duWc73OyVGJUc05fhFaTZeQ/PYsrmyH0JVA== + dependencies: + through "2" + +stream-combiner@~0.0.4: + version "0.0.4" + resolved "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz#4d5e433c185261dde623ca3f44c586bcf5c4ad14" + integrity sha512-rT00SPnTVyRsaSz5zgSPma/aHSOic5U1prhYdRy5HS2kTZviFpmDgzilbtsJsxiroqACmayynDN/9VzIbX5DOw== + dependencies: + duplexer "~0.1.1" + +temp-fs@^0.9.9: + version "0.9.9" + resolved "https://registry.npmjs.org/temp-fs/-/temp-fs-0.9.9.tgz#8071730437870720e9431532fe2814364f8803d7" + integrity sha512-WfecDCR1xC9b0nsrzSaxPf3ZuWeWLUWblW4vlDQAa1biQaKHiImHnJfeQocQe/hXKMcolRzgkcVX/7kK4zoWbw== + dependencies: + rimraf "~2.5.2" + +through@2, through@~2.3, through@~2.3.1: + version "2.3.8" + resolved "https://registry.npmjs.org/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg== + +typescript@^5.4.5: + version "5.4.5" + resolved "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz#42ccef2c571fdbd0f6718b1d1f5e6e5ef006f611" + integrity sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ== + +wrappy@1: + version "1.0.2" + resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== From 807818f14d82462f065b29657cff4f27b88302ec Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 1 Jun 2024 14:59:23 -0700 Subject: [PATCH 02/11] working cerner and aetna tests --- js/e2e/src/aetna_test.ts | 28 ++++++++ js/e2e/src/cerner_test.ts | 40 +++++++++++ js/e2e/src/epic_legacy_test.ts | 124 +++++++++++++++++++++++++++++++++ js/e2e/src/local_test.ts | 38 +++++----- js/e2e/src/sample_test.ts | 74 ++++++++++---------- js/e2e/utils.ts | 18 +++++ js/package.json | 4 +- js/playwright.config.ts | 40 +++++------ js/src/utils/uuid.ts | 4 +- js/tsconfig.json | 2 +- 10 files changed, 291 insertions(+), 81 deletions(-) create mode 100644 js/e2e/src/aetna_test.ts create mode 100644 js/e2e/src/cerner_test.ts create mode 100644 js/e2e/src/epic_legacy_test.ts create mode 100644 js/e2e/utils.ts diff --git a/js/e2e/src/aetna_test.ts b/js/e2e/src/aetna_test.ts new file mode 100644 index 000000000..6555be626 --- /dev/null +++ b/js/e2e/src/aetna_test.ts @@ -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."); +}); diff --git a/js/e2e/src/cerner_test.ts b/js/e2e/src/cerner_test.ts new file mode 100644 index 000000000..a2b134a06 --- /dev/null +++ b/js/e2e/src/cerner_test.ts @@ -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."); +}); diff --git a/js/e2e/src/epic_legacy_test.ts b/js/e2e/src/epic_legacy_test.ts new file mode 100644 index 000000000..66bea5e0b --- /dev/null +++ b/js/e2e/src/epic_legacy_test.ts @@ -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://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"); +// }); +// } diff --git a/js/e2e/src/local_test.ts b/js/e2e/src/local_test.ts index 7d4fe0303..6ddec52d9 100644 --- a/js/e2e/src/local_test.ts +++ b/js/e2e/src/local_test.ts @@ -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'}})}`); +// +// } +// +// }); diff --git a/js/e2e/src/sample_test.ts b/js/e2e/src/sample_test.ts index 057876519..2bb5b939e 100644 --- a/js/e2e/src/sample_test.ts +++ b/js/e2e/src/sample_test.ts @@ -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'}})}`); +// +// } +// +// }); diff --git a/js/e2e/utils.ts b/js/e2e/utils.ts new file mode 100644 index 000000000..ac81ecf9f --- /dev/null +++ b/js/e2e/utils.ts @@ -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 { + + 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 + }) +} diff --git a/js/package.json b/js/package.json index 92adbcd9b..479b1d720 100644 --- a/js/package.json +++ b/js/package.json @@ -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 ", "dependencies": { "@panva/oauth4webapi": "1.2.0" }, + "type": "module", "publishConfig": { "access": "public" }, diff --git a/js/playwright.config.ts b/js/playwright.config.ts index 9c19c1d5d..71856bac3 100644 --- a/js/playwright.config.ts +++ b/js/playwright.config.ts @@ -53,26 +53,26 @@ export default { }, /* Configure projects for major browsers */ - projects: [ - { - name: 'chrome@latest:Windows 11', - use: { - connectOptions: { wsEndpoint: getCdpEndpoint('chrome@latest:Windows 11','test1') }, - }, - } - // { - // name: 'playwright-webkit@latest:OSX Ventura', - // use: { - // connectOptions: { wsEndpoint: getCdpEndpoint('playwright-webkit@latest:OSX Ventura', 'test2') } - // }, - // }, - // { - // name: 'playwright-firefox:Windows 11', - // use: { - // connectOptions: { wsEndpoint: getCdpEndpoint('playwright-firefox:Windows 11', 'test3') } - // }, - // } - ], + // projects: [ + // // { + // // name: 'chrome@latest:Windows 11', + // // use: { + // // connectOptions: { wsEndpoint: getCdpEndpoint('chrome@latest:Windows 11','test1') }, + // // }, + // // } + // // { + // // name: 'playwright-webkit@latest:OSX Ventura', + // // use: { + // // connectOptions: { wsEndpoint: getCdpEndpoint('playwright-webkit@latest:OSX Ventura', 'test2') } + // // }, + // // }, + // { + // name: 'playwright-firefox:Windows 11', + // use: { + // connectOptions: { wsEndpoint: getCdpEndpoint('playwright-firefox:Windows 11', 'test3') } + // }, + // } + // ], /* Folder for test artifacts such as screenshots, videos, traces, etc. */ // outputDir: 'test-results/', diff --git a/js/src/utils/uuid.ts b/js/src/utils/uuid.ts index ff071a20e..ded67df38 100644 --- a/js/src/utils/uuid.ts +++ b/js/src/utils/uuid.ts @@ -1,6 +1,4 @@ - -export function uuidV4(){ - // @ts-ignore +export function uuidV4(): string { return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) ); diff --git a/js/tsconfig.json b/js/tsconfig.json index 0c0c10ec2..5fe5b4470 100644 --- a/js/tsconfig.json +++ b/js/tsconfig.json @@ -8,5 +8,5 @@ }, "include": [ "src/**/*" - ] + ], } From 8d6ee9d408df04fe1a68ff063e20d0995edbbbfb Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 1 Jun 2024 15:10:20 -0700 Subject: [PATCH 03/11] working allscripts test. --- js/e2e/src/aetna_test.ts | 2 +- js/e2e/src/allscripts_test.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 js/e2e/src/allscripts_test.ts diff --git a/js/e2e/src/aetna_test.ts b/js/e2e/src/aetna_test.ts index 6555be626..1fab7f819 100644 --- a/js/e2e/src/aetna_test.ts +++ b/js/e2e/src/aetna_test.ts @@ -3,7 +3,7 @@ import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; test("Aetna Login Flow", async ({page}) => { - + test.skip() //get the Cerner Sandbox endpoint definition let endpointDefinition = await getEndpointDefinition('ac8308d1-90de-4994-bb3d-fe404832714c') let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) diff --git a/js/e2e/src/allscripts_test.ts b/js/e2e/src/allscripts_test.ts new file mode 100644 index 000000000..3dc42aca6 --- /dev/null +++ b/js/e2e/src/allscripts_test.ts @@ -0,0 +1,32 @@ +import { test, expect } from "@playwright/test"; +import {getEndpointDefinition} from '../utils'; +import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; + +test("Allscripts Login Flow", async ({page}) => { + test.skip() + //get the Allscripts - Veradigm Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('7682675b-8247-4fda-b2cd-048bfeafc8af') + let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) + + // authorizeData.sourceState + console.log(authorizeData.url.toString()) + + await page.goto(authorizeData.url.toString()); + + // We are on login page + await page.waitForSelector("text=Allscripts Health Connect Core"); + await expect(page).toHaveTitle("Allscripts FHIR Authorization - "); + await page.focus("#username"); + await page.keyboard.type("allison.allscripts@tw181unityfhir.edu"); + await page.focus("#passwordEntered"); + await page.keyboard.type("Allscripts#1"); + await page.click("#local-login"); + + // We have logged in + await page.waitForSelector("text=Uncheck the permissions you do not wish to grant."); + await expect(page).toHaveTitle("Allscripts FHIR Authorization - "); + await page.click('button[value="yes"]'); + + // If successful, Fasten Lighthouse page should now be visible + await page.waitForSelector("text=Your account has been securely connected to FASTEN."); +}); From a55252fb8911df00965a8c21d0997c075a5fc1eb Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 1 Jun 2024 15:16:51 -0700 Subject: [PATCH 04/11] working athena test. --- js/e2e/src/athena_test.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 js/e2e/src/athena_test.ts diff --git a/js/e2e/src/athena_test.ts b/js/e2e/src/athena_test.ts new file mode 100644 index 000000000..a0364cb58 --- /dev/null +++ b/js/e2e/src/athena_test.ts @@ -0,0 +1,34 @@ +import { test, expect } from "@playwright/test"; +import {getEndpointDefinition} from '../utils'; +import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; + +test("Athena Login Flow", async ({page}) => { + test.skip() + + //get the Cerner Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('950e9092-8ce7-4926-ad87-64616f00cb4c') + 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=Fasten Health - preview"); + await expect(page).toHaveTitle("Login"); + await page.click("label[for='okta-signin-username']", { force: true }); + await page.keyboard.type("phrtest_preview@mailinator.com"); + await page.click("label[for='okta-signin-password']", { force: true }); + await page.keyboard.type("Password1"); + await page.click("#okta-signin-submit"); + + // We have logged in + await page.waitForSelector("text=Select a health record"); + await expect(page).toHaveTitle("Login"); + await page.locator("text=Jake Medlock (you)").click(); + + // If successful, Fasten Lighthouse page should now be visible + await page.waitForSelector("text=Your account has been securely connected to FASTEN."); +}); From a25caad58b7a3cd67663b1b71258e023c26d2c25 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 1 Jun 2024 15:30:06 -0700 Subject: [PATCH 05/11] working CareEvolution. --- js/e2e/src/careevolution_test.ts | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 js/e2e/src/careevolution_test.ts diff --git a/js/e2e/src/careevolution_test.ts b/js/e2e/src/careevolution_test.ts new file mode 100644 index 000000000..edc0325f0 --- /dev/null +++ b/js/e2e/src/careevolution_test.ts @@ -0,0 +1,34 @@ +import { test, expect } from "@playwright/test"; +import {getEndpointDefinition} from '../utils'; +import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; + +test("CareEvolution Login Flow", async ({page}) => { + test.skip() + + //get the Cerner 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."); +}); From af16bbdd9536d70c48813373b5f0834ec0a17698 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 1 Jun 2024 15:41:48 -0700 Subject: [PATCH 06/11] working cigna login. --- js/e2e/src/careevolution_test.ts | 2 +- js/e2e/src/cigna_test.ts | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 js/e2e/src/cigna_test.ts diff --git a/js/e2e/src/careevolution_test.ts b/js/e2e/src/careevolution_test.ts index edc0325f0..02e3596cc 100644 --- a/js/e2e/src/careevolution_test.ts +++ b/js/e2e/src/careevolution_test.ts @@ -5,7 +5,7 @@ import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; test("CareEvolution Login Flow", async ({page}) => { test.skip() - //get the Cerner Sandbox endpoint definition + //get the CareEvolution Sandbox endpoint definition let endpointDefinition = await getEndpointDefinition('8b47cf7b-330e-4ede-9967-4caa7be623aa') let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) diff --git a/js/e2e/src/cigna_test.ts b/js/e2e/src/cigna_test.ts new file mode 100644 index 000000000..3f63d4bf8 --- /dev/null +++ b/js/e2e/src/cigna_test.ts @@ -0,0 +1,35 @@ +import { test, expect } from "@playwright/test"; +import {getEndpointDefinition} from '../utils'; +import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; + +test("Cigna Login Flow", async ({page}) => { + test.skip() + + //get the Cerner Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('6c0454af-1631-4c4d-905d-5710439df983') + 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=Log in to share health information"); + await expect(page).toHaveTitle("myCigna - Auth Flow"); + await page.click("label[for='username']", { force: true }); + await page.keyboard.type("syntheticuser05"); + await page.click("label[for='password']", { force: true }); + await page.keyboard.type("5ynthU5er5"); + await page.click("button[type='submit']"); + + // We have logged in + await page.waitForSelector("label[for='termsAccept']"); + await expect(page).toHaveTitle("myCigna - Auth Flow"); + await page.click('label[for="termsAccept"]', { force: true }); + await page.click('button[type="submit"]'); + + // If successful, Fasten Lighthouse page should now be visible + await page.waitForSelector("text=Your account has been securely connected to FASTEN."); +}); From 01b04724a73e01fdfeb53b4f2ea2b367cc74780b Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 1 Jun 2024 16:27:28 -0700 Subject: [PATCH 07/11] working eclinicalworks test. --- js/e2e/src/eclinicalworks_test.ts | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 js/e2e/src/eclinicalworks_test.ts diff --git a/js/e2e/src/eclinicalworks_test.ts b/js/e2e/src/eclinicalworks_test.ts new file mode 100644 index 000000000..8bcdc3cd2 --- /dev/null +++ b/js/e2e/src/eclinicalworks_test.ts @@ -0,0 +1,40 @@ +import { test, expect } from "@playwright/test"; +import {getEndpointDefinition} from '../utils'; +import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; + +test("eClinicalWorks-Healow Login Flow", async ({page}) => { + + //get the eClinicalWorks Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('f0a8629a-076c-4f78-b41a-7fc6ae81fa4d') + 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=FHIR R4 Prodtest EMR"); + await expect(page).toHaveTitle("healow - Health and Online Wellness"); + await page.focus("#username"); + await page.keyboard.type("AdultFemaleFHIR"); + await page.focus("#pwd"); + await page.keyboard.type("e@CWFHIR1"); + await page.click("#btnLoginSubmit"); + + // We have logged in + await page.waitForSelector("text=What you need to know about Fasten Health"); + await expect(page).toHaveTitle("LoginUi"); + await page.click('button:text(" Continue ")'); + + + // We are on the agreement page + await page.waitForSelector("text=Personal Information Sharing"); + await expect(page).toHaveTitle("LoginUi"); + await page.click('button:text-is("Approve")'); + + + // If successful, Fasten Lighthouse page should now be visible + await page.waitForSelector("text=Your account has been securely connected to FASTEN."); +}); From 8e8601863edf4f607eba7180362e68f5b48d2bf6 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 1 Jun 2024 19:13:18 -0700 Subject: [PATCH 08/11] working eclinicalworks test. --- js/e2e/src/eclinicalworks_test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/js/e2e/src/eclinicalworks_test.ts b/js/e2e/src/eclinicalworks_test.ts index 8bcdc3cd2..f9f530bf4 100644 --- a/js/e2e/src/eclinicalworks_test.ts +++ b/js/e2e/src/eclinicalworks_test.ts @@ -32,6 +32,7 @@ test("eClinicalWorks-Healow Login Flow", async ({page}) => { // We are on the agreement page await page.waitForSelector("text=Personal Information Sharing"); await expect(page).toHaveTitle("LoginUi"); + //this is a case-sensitive, but not exact match. It may break in the future. await page.click('button:text-is("Approve")'); From 7794fa6176cf3ee3c0520cb31685e48d0878f8b3 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 1 Jun 2024 19:40:44 -0700 Subject: [PATCH 09/11] better test skipping. --- js/e2e/src/aetna_test.ts | 3 +-- js/e2e/src/allscripts_test.ts | 3 +-- js/e2e/src/athena_test.ts | 4 +--- js/e2e/src/careevolution_test.ts | 4 +--- js/e2e/src/cerner_test.ts | 3 +-- js/e2e/src/cigna_test.ts | 4 +--- js/e2e/src/eclinicalworks_test.ts | 3 +-- js/e2e/src/epic_legacy_test.ts | 4 +--- js/e2e/src/kaiser_test.ts | 35 +++++++++++++++++++++++++++++++ 9 files changed, 43 insertions(+), 20 deletions(-) create mode 100644 js/e2e/src/kaiser_test.ts diff --git a/js/e2e/src/aetna_test.ts b/js/e2e/src/aetna_test.ts index 1fab7f819..220d0f01f 100644 --- a/js/e2e/src/aetna_test.ts +++ b/js/e2e/src/aetna_test.ts @@ -2,8 +2,7 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test("Aetna Login Flow", async ({page}) => { - test.skip() +test.skip("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) diff --git a/js/e2e/src/allscripts_test.ts b/js/e2e/src/allscripts_test.ts index 3dc42aca6..18093a88a 100644 --- a/js/e2e/src/allscripts_test.ts +++ b/js/e2e/src/allscripts_test.ts @@ -2,8 +2,7 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test("Allscripts Login Flow", async ({page}) => { - test.skip() +test.skip("Allscripts Login Flow", async ({page}) => { //get the Allscripts - Veradigm Sandbox endpoint definition let endpointDefinition = await getEndpointDefinition('7682675b-8247-4fda-b2cd-048bfeafc8af') let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) diff --git a/js/e2e/src/athena_test.ts b/js/e2e/src/athena_test.ts index a0364cb58..b1e3ec823 100644 --- a/js/e2e/src/athena_test.ts +++ b/js/e2e/src/athena_test.ts @@ -2,9 +2,7 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test("Athena Login Flow", async ({page}) => { - test.skip() - +test.skip("Athena Login Flow", async ({page}) => { //get the Cerner Sandbox endpoint definition let endpointDefinition = await getEndpointDefinition('950e9092-8ce7-4926-ad87-64616f00cb4c') let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) diff --git a/js/e2e/src/careevolution_test.ts b/js/e2e/src/careevolution_test.ts index 02e3596cc..270e3aa80 100644 --- a/js/e2e/src/careevolution_test.ts +++ b/js/e2e/src/careevolution_test.ts @@ -2,9 +2,7 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test("CareEvolution Login Flow", async ({page}) => { - test.skip() - +test.skip("CareEvolution Login Flow", async ({page}) => { //get the CareEvolution Sandbox endpoint definition let endpointDefinition = await getEndpointDefinition('8b47cf7b-330e-4ede-9967-4caa7be623aa') let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) diff --git a/js/e2e/src/cerner_test.ts b/js/e2e/src/cerner_test.ts index a2b134a06..faf19b50e 100644 --- a/js/e2e/src/cerner_test.ts +++ b/js/e2e/src/cerner_test.ts @@ -2,8 +2,7 @@ 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() +test.skip("Cerner Login Flow", async ({page}) => { //get the Cerner Sandbox endpoint definition let endpointDefinition = await getEndpointDefinition('3290e5d7-978e-42ad-b661-1cf8a01a989c') let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) diff --git a/js/e2e/src/cigna_test.ts b/js/e2e/src/cigna_test.ts index 3f63d4bf8..ae6d789db 100644 --- a/js/e2e/src/cigna_test.ts +++ b/js/e2e/src/cigna_test.ts @@ -2,9 +2,7 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test("Cigna Login Flow", async ({page}) => { - test.skip() - +test.skip("Cigna Login Flow", async ({page}) => { //get the Cerner Sandbox endpoint definition let endpointDefinition = await getEndpointDefinition('6c0454af-1631-4c4d-905d-5710439df983') let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) diff --git a/js/e2e/src/eclinicalworks_test.ts b/js/e2e/src/eclinicalworks_test.ts index f9f530bf4..9c3746b68 100644 --- a/js/e2e/src/eclinicalworks_test.ts +++ b/js/e2e/src/eclinicalworks_test.ts @@ -2,8 +2,7 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test("eClinicalWorks-Healow Login Flow", async ({page}) => { - +test.skip("eClinicalWorks-Healow Login Flow", async ({page}) => { //get the eClinicalWorks Sandbox endpoint definition let endpointDefinition = await getEndpointDefinition('f0a8629a-076c-4f78-b41a-7fc6ae81fa4d') let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) diff --git a/js/e2e/src/epic_legacy_test.ts b/js/e2e/src/epic_legacy_test.ts index 66bea5e0b..32be8d558 100644 --- a/js/e2e/src/epic_legacy_test.ts +++ b/js/e2e/src/epic_legacy_test.ts @@ -2,9 +2,7 @@ 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() - +test.skip("Epic OAuth2 Legacy Login Flow", async ({page}) => { //get the Epic Sandbox endpoint definition let endpointDefinition = await getEndpointDefinition('fc94bfc7-684d-4e4d-aa6e-ceec01c21c81') let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) diff --git a/js/e2e/src/kaiser_test.ts b/js/e2e/src/kaiser_test.ts new file mode 100644 index 000000000..39919ca78 --- /dev/null +++ b/js/e2e/src/kaiser_test.ts @@ -0,0 +1,35 @@ +import { test, expect } from "@playwright/test"; +import {getEndpointDefinition} from '../utils'; +import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; + +test.skip("Kaiser Login Flow", async ({page}) => { + //get the Cerner Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('9d0fa28a-0c5b-4065-9ee6-284ec9577a57') + 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=Sign in"); + await expect(page).toHaveTitle("Sign in "); + await page.click("label[for='username']", { force: true }); + await page.keyboard.type("Pvaluser1"); + await page.click("label[for='password']", { force: true }); + await page.keyboard.type("V@lidation1"); + await page.click("button[type='submit']"); + + // We have logged in + await page.waitForSelector("text=Please Be Aware"); + await expect(page).toHaveTitle("Consent Management"); + await page.click("input[name='subject']"); + await page.click("label[for='agreement']"); + await page.locator('div.accept-btn').locator('button[type="button"]').click(); + + + // If successful, Fasten Lighthouse page should now be visible + await page.waitForSelector("text=Your account has been securely connected to FASTEN."); +}); From d3f3ddfe5ab7a9066f70146dc20efcdeb6cb4457 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 1 Jun 2024 20:22:05 -0700 Subject: [PATCH 10/11] adding vahealth, nextgen and medicare --- js/e2e/src/medicare_test.ts | 41 ++++++++++++++++++++++++++++++++++ js/e2e/src/nextgen_test.ts | 35 +++++++++++++++++++++++++++++ js/e2e/src/vahealth_test.ts | 44 +++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 js/e2e/src/medicare_test.ts create mode 100644 js/e2e/src/nextgen_test.ts create mode 100644 js/e2e/src/vahealth_test.ts diff --git a/js/e2e/src/medicare_test.ts b/js/e2e/src/medicare_test.ts new file mode 100644 index 000000000..c13af1489 --- /dev/null +++ b/js/e2e/src/medicare_test.ts @@ -0,0 +1,41 @@ +import { test, expect } from "@playwright/test"; +import {getEndpointDefinition} from '../utils'; +import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; + +test.skip("Medicare Login Flow", async ({page}) => { + //get the Cerner Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('6ae6c14e-b927-4ce0-862f-91123cb8d774') + 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=Log in"); + // await expect(page).toHaveTitle("Cerner Health - Sign In"); + await page.click("label[for='username-textbox']", { force: true }); + await page.keyboard.type("BBUser00000"); + await page.click("label[for='password-textbox']", { force: true }); + await page.keyboard.type("PW00000!"); + await page.click("#login-button"); + + //INCOMPLETE - Need to add more steps to complete the login flow + + // // 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."); +}); diff --git a/js/e2e/src/nextgen_test.ts b/js/e2e/src/nextgen_test.ts new file mode 100644 index 000000000..2893e8d52 --- /dev/null +++ b/js/e2e/src/nextgen_test.ts @@ -0,0 +1,35 @@ +import { test, expect } from "@playwright/test"; +import {getEndpointDefinition} from '../utils'; +import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; + +test.skip("Nextgen Login Flow", async ({page}) => { + //get the Cerner Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('843f5c82-b4e3-43c6-8657-eff1390d7e44') + 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=NextGen HealthCare"); + await page.focus("#Username"); + await page.keyboard.type("patientapitest"); + await page.focus("#Password"); + await page.keyboard.type("Password1!"); + await page.click('button:text("Next")'); + + // We have logged in + await page.waitForSelector("text=Connect to Fasten Health - Sandbox"); + await page.click('#btnAllow'); + + // Keep me signed in. + await page.waitForSelector("text=Connect to Fasten Health - Sandbox"); + await page.click('button:text("Next")'); + + + // If successful, Fasten Lighthouse page should now be visible + await page.waitForSelector("text=Your account has been securely connected to FASTEN."); +}); diff --git a/js/e2e/src/vahealth_test.ts b/js/e2e/src/vahealth_test.ts new file mode 100644 index 000000000..520245373 --- /dev/null +++ b/js/e2e/src/vahealth_test.ts @@ -0,0 +1,44 @@ +import { test, expect } from "@playwright/test"; +import {getEndpointDefinition} from '../utils'; +import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; + +test.skip("VAHealth Login Flow", async ({page}) => { + //get the Cerner Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('71fd52e3-b9fe-4e3d-b983-99711e798bd8') + 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 landing page + await page.waitForSelector("text=Sign in to VA.gov"); + await expect(page).toHaveTitle("Choose Login Provider"); + await page.click("a.idme-signin", { force: true }); + + // We are on the ID.me login page + await page.waitForSelector("text=Sign in to ID.me"); + await page.click("label[for='user_email']", { force: true }); + await page.keyboard.type("va.api.user+001-2024@gmail.com"); + await page.click("label[for='user_password']", { force: true }); + await page.keyboard.type("SandboxPassword2024!"); + await page.click("input[type='submit']"); + + // We are on the ID.me 2FA page + await page.waitForSelector("text=Complete your sign in"); + await page.click("button[type='submit']"); + + // We are on the ID.me 2FA Completion Page + await page.waitForSelector("text=Complete your sign in"); + await page.click("button[type='submit']"); + + // We are on the VA.gov login page + await page.waitForSelector("text=FastenHealthIncKulatunga-1696557147"); + await expect(page).toHaveTitle("Department of Veteran Affairs Evaluation - Sign In"); + await page.click('button[value="Allow Access"]'); + + // If successful, Fasten Lighthouse page should now be visible + await page.waitForSelector("text=Your account has been securely connected to FASTEN."); +}); From 8483d495b085eccfa4d6603729798a90bb28eb50 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 1 Jun 2024 21:24:19 -0700 Subject: [PATCH 11/11] fixing tests, sending to Browserstack. --- js/e2e/global-setup.ts | 2 +- js/e2e/src/aetna_test.ts | 46 +++++++----- js/e2e/src/allscripts_test.ts | 62 +++++++++------- js/e2e/src/athena_test.ts | 53 ++++++++------ js/e2e/src/careevolution_test.ts | 53 ++++++++------ js/e2e/src/cerner_test.ts | 78 +++++++++++--------- js/e2e/src/cigna_test.ts | 54 ++++++++------ js/e2e/src/eclinicalworks_test.ts | 78 +++++++++++--------- js/e2e/src/epic_legacy_test.ts | 117 ++++++++++++++++-------------- js/e2e/src/kaiser_test.ts | 56 ++++++++------ js/e2e/src/local_test.ts | 22 ------ js/e2e/src/medicare_test.ts | 70 ++++++++++-------- js/e2e/src/nextgen_test.ts | 68 +++++++++-------- js/e2e/src/sample_test.ts | 40 ---------- js/e2e/src/vahealth_test.ts | 86 ++++++++++++---------- js/playwright.config.ts | 40 +++++----- 16 files changed, 484 insertions(+), 441 deletions(-) delete mode 100644 js/e2e/src/local_test.ts delete mode 100644 js/e2e/src/sample_test.ts diff --git a/js/e2e/global-setup.ts b/js/e2e/global-setup.ts index b274a39b8..de4ee03cf 100644 --- a/js/e2e/global-setup.ts +++ b/js/e2e/global-setup.ts @@ -12,7 +12,7 @@ export default async function setup() { bsLocal.start(BS_LOCAL_ARGS, (err) => { if (err) { console.error( - `${redColour}Error starting BrowserStackLocal${whiteColour}` + `${redColour}Error starting BrowserStackLocal${whiteColour}`, err ); } else { console.log('BrowserStackLocal Started'); diff --git a/js/e2e/src/aetna_test.ts b/js/e2e/src/aetna_test.ts index 220d0f01f..c8d67ecf2 100644 --- a/js/e2e/src/aetna_test.ts +++ b/js/e2e/src/aetna_test.ts @@ -2,26 +2,36 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test.skip("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) +test("Aetna Login Flow", async ({page}, testInfo) => { + try { + await page.evaluate(_ => {},`browserstack_executor: ${JSON.stringify({action: "setSessionName", arguments: {name:testInfo.title}})}`); + await page.waitForTimeout(5000); - // authorizeData.sourceState - console.log(authorizeData.url.toString()) + //get the Cerner Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('ac8308d1-90de-4994-bb3d-fe404832714c') + let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) - // Start login flow by clicking on button with text "Login to MyChart" - await page.goto(authorizeData.url.toString()); + // authorizeData.sourceState + console.log(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"); + // Start login flow by clicking on button with text "Login to MyChart" + await page.goto(authorizeData.url.toString()); - // If successful, Fasten Lighthouse page should now be visible - await page.waitForSelector("text=Your account has been securely connected to FASTEN."); + // 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."); + + 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'}})}`); + } }); diff --git a/js/e2e/src/allscripts_test.ts b/js/e2e/src/allscripts_test.ts index 18093a88a..5e7a0bbbe 100644 --- a/js/e2e/src/allscripts_test.ts +++ b/js/e2e/src/allscripts_test.ts @@ -2,30 +2,40 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test.skip("Allscripts Login Flow", async ({page}) => { - //get the Allscripts - Veradigm Sandbox endpoint definition - let endpointDefinition = await getEndpointDefinition('7682675b-8247-4fda-b2cd-048bfeafc8af') - let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) - - // authorizeData.sourceState - console.log(authorizeData.url.toString()) - - await page.goto(authorizeData.url.toString()); - - // We are on login page - await page.waitForSelector("text=Allscripts Health Connect Core"); - await expect(page).toHaveTitle("Allscripts FHIR Authorization - "); - await page.focus("#username"); - await page.keyboard.type("allison.allscripts@tw181unityfhir.edu"); - await page.focus("#passwordEntered"); - await page.keyboard.type("Allscripts#1"); - await page.click("#local-login"); - - // We have logged in - await page.waitForSelector("text=Uncheck the permissions you do not wish to grant."); - await expect(page).toHaveTitle("Allscripts FHIR Authorization - "); - await page.click('button[value="yes"]'); - - // If successful, Fasten Lighthouse page should now be visible - await page.waitForSelector("text=Your account has been securely connected to FASTEN."); +test("Allscripts 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 Allscripts - Veradigm Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('7682675b-8247-4fda-b2cd-048bfeafc8af') + let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) + + // authorizeData.sourceState + console.log(authorizeData.url.toString()) + + await page.goto(authorizeData.url.toString()); + + // We are on login page + await page.waitForSelector("text=Allscripts Health Connect Core"); + await expect(page).toHaveTitle("Allscripts FHIR Authorization - "); + await page.focus("#username"); + await page.keyboard.type("allison.allscripts@tw181unityfhir.edu"); + await page.focus("#passwordEntered"); + await page.keyboard.type("Allscripts#1"); + await page.click("#local-login"); + + // We have logged in + await page.waitForSelector("text=Uncheck the permissions you do not wish to grant."); + await expect(page).toHaveTitle("Allscripts FHIR Authorization - "); + await page.click('button[value="yes"]'); + + // 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'}})}`); + } }); diff --git a/js/e2e/src/athena_test.ts b/js/e2e/src/athena_test.ts index b1e3ec823..d54381e20 100644 --- a/js/e2e/src/athena_test.ts +++ b/js/e2e/src/athena_test.ts @@ -2,31 +2,40 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test.skip("Athena Login Flow", async ({page}) => { - //get the Cerner Sandbox endpoint definition - let endpointDefinition = await getEndpointDefinition('950e9092-8ce7-4926-ad87-64616f00cb4c') - let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) +test("Athena 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 Cerner Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('950e9092-8ce7-4926-ad87-64616f00cb4c') + let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) - // authorizeData.sourceState - console.log(authorizeData.url.toString()) + // 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()); + // 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=Fasten Health - preview"); - await expect(page).toHaveTitle("Login"); - await page.click("label[for='okta-signin-username']", { force: true }); - await page.keyboard.type("phrtest_preview@mailinator.com"); - await page.click("label[for='okta-signin-password']", { force: true }); - await page.keyboard.type("Password1"); - await page.click("#okta-signin-submit"); + // We are on login page + await page.waitForSelector("text=Fasten Health - preview"); + await expect(page).toHaveTitle("Login"); + await page.click("label[for='okta-signin-username']", { force: true }); + await page.keyboard.type("phrtest_preview@mailinator.com"); + await page.click("label[for='okta-signin-password']", { force: true }); + await page.keyboard.type("Password1"); + await page.click("#okta-signin-submit"); - // We have logged in - await page.waitForSelector("text=Select a health record"); - await expect(page).toHaveTitle("Login"); - await page.locator("text=Jake Medlock (you)").click(); + // We have logged in + await page.waitForSelector("text=Select a health record"); + await expect(page).toHaveTitle("Login"); + await page.locator("text=Jake Medlock (you)").click(); - // If successful, Fasten Lighthouse page should now be visible - await page.waitForSelector("text=Your account has been securely connected to FASTEN."); + // 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'}})}`); + } }); diff --git a/js/e2e/src/careevolution_test.ts b/js/e2e/src/careevolution_test.ts index 270e3aa80..aa96b9be5 100644 --- a/js/e2e/src/careevolution_test.ts +++ b/js/e2e/src/careevolution_test.ts @@ -2,31 +2,40 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test.skip("CareEvolution Login Flow", async ({page}) => { - //get the CareEvolution Sandbox endpoint definition - let endpointDefinition = await getEndpointDefinition('8b47cf7b-330e-4ede-9967-4caa7be623aa') - let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) +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); - // authorizeData.sourceState - console.log(authorizeData.url.toString()) + //get the CareEvolution Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('8b47cf7b-330e-4ede-9967-4caa7be623aa') + let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) - // Start login flow by clicking on button with text "Login to MyChart" - await page.goto(authorizeData.url.toString()); + // authorizeData.sourceState + console.log(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"); + // Start login flow by clicking on button with text "Login to MyChart" + await page.goto(authorizeData.url.toString()); - // 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"]'); + // 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"); - // If successful, Fasten Lighthouse page should now be visible - await page.waitForSelector("text=Your account has been securely connected to FASTEN."); + // 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'}})}`); + } }); diff --git a/js/e2e/src/cerner_test.ts b/js/e2e/src/cerner_test.ts index faf19b50e..59e8fd720 100644 --- a/js/e2e/src/cerner_test.ts +++ b/js/e2e/src/cerner_test.ts @@ -2,38 +2,48 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test.skip("Cerner Login Flow", async ({page}) => { - //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."); +test("Cerner 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 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."); + + 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'}})}`); + } }); diff --git a/js/e2e/src/cigna_test.ts b/js/e2e/src/cigna_test.ts index ae6d789db..2c3e4b859 100644 --- a/js/e2e/src/cigna_test.ts +++ b/js/e2e/src/cigna_test.ts @@ -2,32 +2,40 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test.skip("Cigna Login Flow", async ({page}) => { - //get the Cerner Sandbox endpoint definition - let endpointDefinition = await getEndpointDefinition('6c0454af-1631-4c4d-905d-5710439df983') - let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) +test("Cigna 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 Cerner Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('6c0454af-1631-4c4d-905d-5710439df983') + let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) - // authorizeData.sourceState - console.log(authorizeData.url.toString()) + // 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()); + // 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=Log in to share health information"); - await expect(page).toHaveTitle("myCigna - Auth Flow"); - await page.click("label[for='username']", { force: true }); - await page.keyboard.type("syntheticuser05"); - await page.click("label[for='password']", { force: true }); - await page.keyboard.type("5ynthU5er5"); - await page.click("button[type='submit']"); + // We are on login page + await page.waitForSelector("text=Log in to share health information"); + await expect(page).toHaveTitle("myCigna - Auth Flow"); + await page.click("label[for='username']", { force: true }); + await page.keyboard.type("syntheticuser05"); + await page.click("label[for='password']", { force: true }); + await page.keyboard.type("5ynthU5er5"); + await page.click("button[type='submit']"); - // We have logged in - await page.waitForSelector("label[for='termsAccept']"); - await expect(page).toHaveTitle("myCigna - Auth Flow"); - await page.click('label[for="termsAccept"]', { force: true }); - await page.click('button[type="submit"]'); + // We have logged in + await page.waitForSelector("label[for='termsAccept']"); + await expect(page).toHaveTitle("myCigna - Auth Flow"); + await page.click('label[for="termsAccept"]', { force: true }); + await page.click('button[type="submit"]'); - // If successful, Fasten Lighthouse page should now be visible - await page.waitForSelector("text=Your account has been securely connected to FASTEN."); + // 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'}})}`); + } }); diff --git a/js/e2e/src/eclinicalworks_test.ts b/js/e2e/src/eclinicalworks_test.ts index 9c3746b68..a9e10c825 100644 --- a/js/e2e/src/eclinicalworks_test.ts +++ b/js/e2e/src/eclinicalworks_test.ts @@ -2,39 +2,47 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test.skip("eClinicalWorks-Healow Login Flow", async ({page}) => { - //get the eClinicalWorks Sandbox endpoint definition - let endpointDefinition = await getEndpointDefinition('f0a8629a-076c-4f78-b41a-7fc6ae81fa4d') - 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=FHIR R4 Prodtest EMR"); - await expect(page).toHaveTitle("healow - Health and Online Wellness"); - await page.focus("#username"); - await page.keyboard.type("AdultFemaleFHIR"); - await page.focus("#pwd"); - await page.keyboard.type("e@CWFHIR1"); - await page.click("#btnLoginSubmit"); - - // We have logged in - await page.waitForSelector("text=What you need to know about Fasten Health"); - await expect(page).toHaveTitle("LoginUi"); - await page.click('button:text(" Continue ")'); - - - // We are on the agreement page - await page.waitForSelector("text=Personal Information Sharing"); - await expect(page).toHaveTitle("LoginUi"); - //this is a case-sensitive, but not exact match. It may break in the future. - await page.click('button:text-is("Approve")'); - - - // If successful, Fasten Lighthouse page should now be visible - await page.waitForSelector("text=Your account has been securely connected to FASTEN."); +test("eClinicalWorks-Healow 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 eClinicalWorks Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('f0a8629a-076c-4f78-b41a-7fc6ae81fa4d') + 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=FHIR R4 Prodtest EMR"); + await expect(page).toHaveTitle("healow - Health and Online Wellness"); + await page.focus("#username"); + await page.keyboard.type("AdultFemaleFHIR"); + await page.focus("#pwd"); + await page.keyboard.type("e@CWFHIR1"); + await page.click("#btnLoginSubmit"); + + // We have logged in + await page.waitForSelector("text=What you need to know about Fasten Health"); + await expect(page).toHaveTitle("LoginUi"); + await page.click('button:text(" Continue ")'); + + + // We are on the agreement page + await page.waitForSelector("text=Personal Information Sharing"); + await expect(page).toHaveTitle("LoginUi"); + //this is a case-sensitive, but not exact match. It may break in the future. + await page.click('button:text-is("Approve")'); + + + // 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'}})}`); + } }); diff --git a/js/e2e/src/epic_legacy_test.ts b/js/e2e/src/epic_legacy_test.ts index 32be8d558..87612894d 100644 --- a/js/e2e/src/epic_legacy_test.ts +++ b/js/e2e/src/epic_legacy_test.ts @@ -2,72 +2,81 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test.skip("Epic OAuth2 Legacy Login Flow", async ({page}) => { - //get the Epic Sandbox endpoint definition - let endpointDefinition = await getEndpointDefinition('fc94bfc7-684d-4e4d-aa6e-ceec01c21c81') - let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) +test.skip("Epic OAuth2 Legacy 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 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()) + // 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()); + // 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 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 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 }); + // 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"); + // 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) {} + // 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"); - // 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() - // 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() + 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'}})}`); + } }); // // const expirationOptions = ["1 hour", "1 day", "1 week", "1 month", "3 months"]; diff --git a/js/e2e/src/kaiser_test.ts b/js/e2e/src/kaiser_test.ts index 39919ca78..46e719f30 100644 --- a/js/e2e/src/kaiser_test.ts +++ b/js/e2e/src/kaiser_test.ts @@ -2,34 +2,42 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test.skip("Kaiser Login Flow", async ({page}) => { - //get the Cerner Sandbox endpoint definition - let endpointDefinition = await getEndpointDefinition('9d0fa28a-0c5b-4065-9ee6-284ec9577a57') - let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) +test("Kaiser 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 Kaiser Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('9d0fa28a-0c5b-4065-9ee6-284ec9577a57') + let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) - // authorizeData.sourceState - console.log(authorizeData.url.toString()) + // 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()); + // 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=Sign in"); - await expect(page).toHaveTitle("Sign in "); - await page.click("label[for='username']", { force: true }); - await page.keyboard.type("Pvaluser1"); - await page.click("label[for='password']", { force: true }); - await page.keyboard.type("V@lidation1"); - await page.click("button[type='submit']"); + // We are on login page + await page.waitForSelector("text=Sign in"); + await expect(page).toHaveTitle("Sign in "); + await page.click("label[for='username']", { force: true }); + await page.keyboard.type("Pvaluser1"); + await page.click("label[for='password']", { force: true }); + await page.keyboard.type("V@lidation1"); + await page.click("button[type='submit']"); - // We have logged in - await page.waitForSelector("text=Please Be Aware"); - await expect(page).toHaveTitle("Consent Management"); - await page.click("input[name='subject']"); - await page.click("label[for='agreement']"); - await page.locator('div.accept-btn').locator('button[type="button"]').click(); + // We have logged in + await page.waitForSelector("text=Please Be Aware"); + await expect(page).toHaveTitle("Consent Management"); + await page.click("input[name='subject']"); + await page.click("label[for='agreement']"); + await page.locator('div.accept-btn').locator('button[type="button"]').click(); - // If successful, Fasten Lighthouse page should now be visible - await page.waitForSelector("text=Your account has been securely connected to FASTEN."); + // 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'}})}`); + } }); diff --git a/js/e2e/src/local_test.ts b/js/e2e/src/local_test.ts deleted file mode 100644 index 6ddec52d9..000000000 --- a/js/e2e/src/local_test.ts +++ /dev/null @@ -1,22 +0,0 @@ -// @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'}})}`); -// -// } -// -// }); diff --git a/js/e2e/src/medicare_test.ts b/js/e2e/src/medicare_test.ts index c13af1489..eb55bc59d 100644 --- a/js/e2e/src/medicare_test.ts +++ b/js/e2e/src/medicare_test.ts @@ -2,40 +2,48 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test.skip("Medicare Login Flow", async ({page}) => { - //get the Cerner Sandbox endpoint definition - let endpointDefinition = await getEndpointDefinition('6ae6c14e-b927-4ce0-862f-91123cb8d774') - let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) +test.skip("Medicare 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 Medicare Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('6ae6c14e-b927-4ce0-862f-91123cb8d774') + let authorizeData = await generateSourceAuthorizeUrl(endpointDefinition) - // authorizeData.sourceState - console.log(authorizeData.url.toString()) + // 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()); + // 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=Log in"); - // await expect(page).toHaveTitle("Cerner Health - Sign In"); - await page.click("label[for='username-textbox']", { force: true }); - await page.keyboard.type("BBUser00000"); - await page.click("label[for='password-textbox']", { force: true }); - await page.keyboard.type("PW00000!"); - await page.click("#login-button"); + // We are on login page + await page.waitForSelector("text=Log in"); + // await expect(page).toHaveTitle("Cerner Health - Sign In"); + await page.click("label[for='username-textbox']", { force: true }); + await page.keyboard.type("BBUser00000"); + await page.click("label[for='password-textbox']", { force: true }); + await page.keyboard.type("PW00000!"); + await page.click("#login-button"); - //INCOMPLETE - Need to add more steps to complete the login flow + //INCOMPLETE - Need to add more steps to complete the login flow - // // 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."); + // // 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."); + 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'}})}`); + } }); diff --git a/js/e2e/src/nextgen_test.ts b/js/e2e/src/nextgen_test.ts index 2893e8d52..0d3af23c4 100644 --- a/js/e2e/src/nextgen_test.ts +++ b/js/e2e/src/nextgen_test.ts @@ -2,34 +2,42 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test.skip("Nextgen Login Flow", async ({page}) => { - //get the Cerner Sandbox endpoint definition - let endpointDefinition = await getEndpointDefinition('843f5c82-b4e3-43c6-8657-eff1390d7e44') - 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=NextGen HealthCare"); - await page.focus("#Username"); - await page.keyboard.type("patientapitest"); - await page.focus("#Password"); - await page.keyboard.type("Password1!"); - await page.click('button:text("Next")'); - - // We have logged in - await page.waitForSelector("text=Connect to Fasten Health - Sandbox"); - await page.click('#btnAllow'); - - // Keep me signed in. - await page.waitForSelector("text=Connect to Fasten Health - Sandbox"); - await page.click('button:text("Next")'); - - - // If successful, Fasten Lighthouse page should now be visible - await page.waitForSelector("text=Your account has been securely connected to FASTEN."); +test("Nextgen 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 NextGen Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('843f5c82-b4e3-43c6-8657-eff1390d7e44') + 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=NextGen HealthCare"); + await page.focus("#Username"); + await page.keyboard.type("patientapitest"); + await page.focus("#Password"); + await page.keyboard.type("Password1!"); + await page.click('button:text("Next")'); + + // We have logged in + await page.waitForSelector("text=Connect to Fasten Health - Sandbox"); + await page.click('#btnAllow'); + + // Keep me signed in. + await page.waitForSelector("text=Connect to Fasten Health - Sandbox"); + await page.click('button:text("Next")'); + + + // 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'}})}`); + } }); diff --git a/js/e2e/src/sample_test.ts b/js/e2e/src/sample_test.ts deleted file mode 100644 index 2bb5b939e..000000000 --- a/js/e2e/src/sample_test.ts +++ /dev/null @@ -1,40 +0,0 @@ -// @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'}})}`); -// -// } -// -// }); diff --git a/js/e2e/src/vahealth_test.ts b/js/e2e/src/vahealth_test.ts index 520245373..a79e70e30 100644 --- a/js/e2e/src/vahealth_test.ts +++ b/js/e2e/src/vahealth_test.ts @@ -2,43 +2,51 @@ import { test, expect } from "@playwright/test"; import {getEndpointDefinition} from '../utils'; import {generateSourceAuthorizeUrl} from '../../src/connect/authorization-url'; -test.skip("VAHealth Login Flow", async ({page}) => { - //get the Cerner Sandbox endpoint definition - let endpointDefinition = await getEndpointDefinition('71fd52e3-b9fe-4e3d-b983-99711e798bd8') - 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 landing page - await page.waitForSelector("text=Sign in to VA.gov"); - await expect(page).toHaveTitle("Choose Login Provider"); - await page.click("a.idme-signin", { force: true }); - - // We are on the ID.me login page - await page.waitForSelector("text=Sign in to ID.me"); - await page.click("label[for='user_email']", { force: true }); - await page.keyboard.type("va.api.user+001-2024@gmail.com"); - await page.click("label[for='user_password']", { force: true }); - await page.keyboard.type("SandboxPassword2024!"); - await page.click("input[type='submit']"); - - // We are on the ID.me 2FA page - await page.waitForSelector("text=Complete your sign in"); - await page.click("button[type='submit']"); - - // We are on the ID.me 2FA Completion Page - await page.waitForSelector("text=Complete your sign in"); - await page.click("button[type='submit']"); - - // We are on the VA.gov login page - await page.waitForSelector("text=FastenHealthIncKulatunga-1696557147"); - await expect(page).toHaveTitle("Department of Veteran Affairs Evaluation - Sign In"); - await page.click('button[value="Allow Access"]'); - - // If successful, Fasten Lighthouse page should now be visible - await page.waitForSelector("text=Your account has been securely connected to FASTEN."); +test.skip("VAHealth 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 VAHealth Sandbox endpoint definition + let endpointDefinition = await getEndpointDefinition('71fd52e3-b9fe-4e3d-b983-99711e798bd8') + 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 landing page + await page.waitForSelector("text=Sign in to VA.gov"); + await expect(page).toHaveTitle("Choose Login Provider"); + await page.click("a.idme-signin", { force: true }); + + // We are on the ID.me login page + await page.waitForSelector("text=Sign in to ID.me"); + await page.click("label[for='user_email']", { force: true }); + await page.keyboard.type("va.api.user+001-2024@gmail.com"); + await page.click("label[for='user_password']", { force: true }); + await page.keyboard.type("SandboxPassword2024!"); + await page.click("input[type='submit']"); + + // We are on the ID.me 2FA page + await page.waitForSelector("text=Complete your sign in"); + await page.click("button[type='submit']"); + + // We are on the ID.me 2FA Completion Page + await page.waitForSelector("text=Complete your sign in"); + await page.click("button[type='submit']"); + + // We are on the VA.gov login page + await page.waitForSelector("text=FastenHealthIncKulatunga-1696557147"); + await expect(page).toHaveTitle("Department of Veteran Affairs Evaluation - Sign In"); + await page.click('button[value="Allow Access"]'); + + // 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'}})}`); + } }); diff --git a/js/playwright.config.ts b/js/playwright.config.ts index 71856bac3..9c19c1d5d 100644 --- a/js/playwright.config.ts +++ b/js/playwright.config.ts @@ -53,26 +53,26 @@ export default { }, /* Configure projects for major browsers */ - // projects: [ - // // { - // // name: 'chrome@latest:Windows 11', - // // use: { - // // connectOptions: { wsEndpoint: getCdpEndpoint('chrome@latest:Windows 11','test1') }, - // // }, - // // } - // // { - // // name: 'playwright-webkit@latest:OSX Ventura', - // // use: { - // // connectOptions: { wsEndpoint: getCdpEndpoint('playwright-webkit@latest:OSX Ventura', 'test2') } - // // }, - // // }, - // { - // name: 'playwright-firefox:Windows 11', - // use: { - // connectOptions: { wsEndpoint: getCdpEndpoint('playwright-firefox:Windows 11', 'test3') } - // }, - // } - // ], + projects: [ + { + name: 'chrome@latest:Windows 11', + use: { + connectOptions: { wsEndpoint: getCdpEndpoint('chrome@latest:Windows 11','test1') }, + }, + } + // { + // name: 'playwright-webkit@latest:OSX Ventura', + // use: { + // connectOptions: { wsEndpoint: getCdpEndpoint('playwright-webkit@latest:OSX Ventura', 'test2') } + // }, + // }, + // { + // name: 'playwright-firefox:Windows 11', + // use: { + // connectOptions: { wsEndpoint: getCdpEndpoint('playwright-firefox:Windows 11', 'test3') } + // }, + // } + ], /* Folder for test artifacts such as screenshots, videos, traces, etc. */ // outputDir: 'test-results/',