From 734646dfa965e1effafcd5459a6b64d63d001a47 Mon Sep 17 00:00:00 2001 From: Vincent Shuali Date: Wed, 30 Aug 2023 20:31:26 -0700 Subject: [PATCH 1/9] Initial login to both EMS and ER simultaneously --- e2e/tests/ringdown.spec.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 e2e/tests/ringdown.spec.js diff --git a/e2e/tests/ringdown.spec.js b/e2e/tests/ringdown.spec.js new file mode 100644 index 00000000..2498d0f5 --- /dev/null +++ b/e2e/tests/ringdown.spec.js @@ -0,0 +1,24 @@ +const { test, expect } = require('@playwright/test'); +test.describe('Initializing ringdowns', () => { + test('redirects to EMS interface after EMS user login', async ({ browser }) => { + const emsContext = await browser.newContext(); + const erContext = await browser.newContext(); + + const emsPage = await emsContext.newPage(); + const erPage = await erContext.newPage(); + + await emsPage.goto('/'); + await emsPage.getByLabel('Email').fill(process.env.EMS_USER); + const emsPassword = emsPage.getByLabel('Password'); + await emsPassword.fill(process.env.EMS_PASS); + await emsPassword.press('Enter'); + await expect(emsPage).toHaveURL('/ems'); + + await erPage.goto('/'); + await erPage.getByLabel('Email').fill(process.env.HOSPITAL_USER); + const erPassword = erPage.getByLabel('Password'); + await erPassword.fill(process.env.HOSPITAL_PASS); + await erPassword.press('Enter'); + await expect(erPage).toHaveURL('/er'); + }); +}); From 2e3fe8fe6843a9741915a514c6c71028e9f392a1 Mon Sep 17 00:00:00 2001 From: Vincent Shuali Date: Wed, 30 Aug 2023 21:13:40 -0700 Subject: [PATCH 2/9] WIP: trying to get the E2E to click through a ringdown --- e2e/tests/ringdown.spec.js | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/e2e/tests/ringdown.spec.js b/e2e/tests/ringdown.spec.js index 2498d0f5..14b97fa7 100644 --- a/e2e/tests/ringdown.spec.js +++ b/e2e/tests/ringdown.spec.js @@ -1,11 +1,14 @@ const { test, expect } = require('@playwright/test'); + +let emsContext, erContext; +let erPage, emsPage; test.describe('Initializing ringdowns', () => { - test('redirects to EMS interface after EMS user login', async ({ browser }) => { - const emsContext = await browser.newContext(); - const erContext = await browser.newContext(); + test.beforeEach(async ({ browser }) => { + emsContext = await browser.newContext(); + erContext = await browser.newContext(); - const emsPage = await emsContext.newPage(); - const erPage = await erContext.newPage(); + emsPage = await emsContext.newPage(); + erPage = await erContext.newPage(); await emsPage.goto('/'); await emsPage.getByLabel('Email').fill(process.env.EMS_USER); @@ -21,4 +24,25 @@ test.describe('Initializing ringdowns', () => { await erPassword.press('Enter'); await expect(erPage).toHaveURL('/er'); }); + + test('Submits a ringdown', async ({ browser }) => { + // TODO: move this into beforeEach once this works + + const unitDropdown = emsPage.locator('id=ambulanceIdentifier-label'); + // this isn't working yet (WIP) + + await unitDropdown.getByLabel(/Toggle the dropdown/).click(); + + await expect(unitDropdown.getByText('SFFD-2')).toBeVisible(); + + await emsPage.getByLabel('Unit #').selectOption('SFFD-2'); + }); + + test.afterEach(async ({ browser }) => { + erPage.close(); + emsPage.close(); + erContext.close(); + emsContext.close(); + browser.close(); + }); }); From d4b1da46ef751f7ee77169231bb03d2460b65499 Mon Sep 17 00:00:00 2001 From: Vincent Shuali Date: Wed, 23 Aug 2023 20:27:00 -0700 Subject: [PATCH 3/9] Start battery of ER and EMS E2E tests --- e2e/tests/ems.spec.js | 11 +++++++++++ e2e/tests/er.spec.js | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100644 e2e/tests/ems.spec.js create mode 100644 e2e/tests/er.spec.js diff --git a/e2e/tests/ems.spec.js b/e2e/tests/ems.spec.js new file mode 100644 index 00000000..6c281a81 --- /dev/null +++ b/e2e/tests/ems.spec.js @@ -0,0 +1,11 @@ +const { test, expect } = require('@playwright/test'); +test.describe('Without 2FA', () => { + test('redirects to EMS interface after EMS user login', async ({ page }) => { + await page.goto('/'); + await page.getByLabel('Email').fill(process.env.EMS_USER); + const password = page.getByLabel('Password'); + await password.fill(process.env.EMS_PASS); + await password.press('Enter'); + await expect(page).toHaveURL('/ems'); + }); +}); diff --git a/e2e/tests/er.spec.js b/e2e/tests/er.spec.js new file mode 100644 index 00000000..11203d31 --- /dev/null +++ b/e2e/tests/er.spec.js @@ -0,0 +1,11 @@ +const { test, expect } = require('@playwright/test'); +test.describe('Without 2FA,', () => { + test('redirects to ER interface after Hospital user login', async ({ page }) => { + await page.goto('/'); + await page.getByLabel('Email').fill(process.env.HOSPITAL_USER); + const password = page.getByLabel('Password'); + await password.fill(process.env.HOSPITAL_PASS); + await password.press('Enter'); + await expect(page).toHaveURL('/er'); + }); +}); From 9eef2f54ad62114983da6b371aefd0c65edb7e1a Mon Sep 17 00:00:00 2001 From: Vincent Shuali Date: Wed, 20 Sep 2023 21:29:21 -0700 Subject: [PATCH 4/9] Halfway down filling first page of EMS form --- e2e/tests/ringdown.spec.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/e2e/tests/ringdown.spec.js b/e2e/tests/ringdown.spec.js index 14b97fa7..ec879680 100644 --- a/e2e/tests/ringdown.spec.js +++ b/e2e/tests/ringdown.spec.js @@ -23,19 +23,31 @@ test.describe('Initializing ringdowns', () => { await erPassword.fill(process.env.HOSPITAL_PASS); await erPassword.press('Enter'); await expect(erPage).toHaveURL('/er'); + }); test('Submits a ringdown', async ({ browser }) => { // TODO: move this into beforeEach once this works - const unitDropdown = emsPage.locator('id=ambulanceIdentifier-label'); - // this isn't working yet (WIP) + const unitComboBox = emsPage.locator('#ambulanceIdentifier'); + + await unitComboBox.click(); + + const ambulanceIdentifierList = emsPage.locator('#ambulanceIdentifier--list'); + + await ambulanceIdentifierList.getByText('SFFD-2').click(); + + const incidentComboBox = emsPage.locator('#dispatchCallNumber'); + + await incidentComboBox.fill("2"); + + await incidentComboBox.press('Enter'); - await unitDropdown.getByLabel(/Toggle the dropdown/).click(); + await expect(emsPage.locator('[name=dispatchCallNumber]')).toHaveValue('2'); - await expect(unitDropdown.getByText('SFFD-2')).toBeVisible(); + await emsPage.getByText('Code 2').click(); - await emsPage.getByLabel('Unit #').selectOption('SFFD-2'); + await expect(emsPage.locator('[value="CODE 2"]')).toBeChecked(); }); test.afterEach(async ({ browser }) => { From f8b02cfba986b9e4743b265a5d4baf7270538295 Mon Sep 17 00:00:00 2001 From: Vincent Shuali Date: Wed, 27 Sep 2023 21:46:55 -0700 Subject: [PATCH 5/9] Finish ringdown submission, but need to add conditional test to clear previous ringdown if one exists --- e2e/tests/ringdown.spec.js | 95 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/e2e/tests/ringdown.spec.js b/e2e/tests/ringdown.spec.js index ec879680..f8423d82 100644 --- a/e2e/tests/ringdown.spec.js +++ b/e2e/tests/ringdown.spec.js @@ -48,6 +48,101 @@ test.describe('Initializing ringdowns', () => { await emsPage.getByText('Code 2').click(); await expect(emsPage.locator('[value="CODE 2"]')).toBeChecked(); + + const ageBox = emsPage.locator('#age'); + + await ageBox.fill("25"); + await expect(ageBox).toHaveValue('25'); + + await emsPage.getByText('Non-binary').click(); + + await expect(emsPage.locator('[value="NON-BINARY"]')).toBeChecked(); + + const chiefComplaintBox = emsPage.locator('#chiefComplaintDescription'); + + const complaintText = "Patient ate too many skittles. They are experiencing severe regretitis"; + + await chiefComplaintBox.fill(complaintText); + + await expect(chiefComplaintBox).toHaveValue(complaintText); + + await emsPage.getByText('Vitals stable').click(); + + await expect(emsPage.locator('#stableIndicator-true')).toBeChecked(); + + const systolicBox = emsPage.locator("#systolicBloodPressure"); + + await systolicBox.fill("130"); + await expect(systolicBox).toHaveValue("130"); + + const diastolicBox = emsPage.locator("#diastolicBloodPressure"); + + await diastolicBox.fill("80"); + await expect(diastolicBox).toHaveValue("80"); + + const pulseBox = emsPage.locator("#heartRateBpm"); + + await pulseBox.fill("85"); + await expect(pulseBox).toHaveValue("85"); + + const respiratoryBox = emsPage.locator("#respiratoryRate"); + + await respiratoryBox.fill("20"); + await expect(respiratoryBox).toHaveValue("20"); + + const oxygenBox = emsPage.locator("#oxygenSaturation"); + + await oxygenBox.fill("40"); + await expect(oxygenBox).toHaveValue("40"); + + await emsPage.getByText('Room Air').click(); + + await expect(emsPage.locator('[value="ROOM AIR"]')).toBeChecked(); + + const temperatureBox = emsPage.locator("#temperature"); + + await temperatureBox.fill("98"); + await expect(temperatureBox).toHaveValue("98"); + + const treatmentNotesBox = emsPage.locator("#treatmentNotes"); + + const treatmentNoteText = "N/A"; + + await treatmentNotesBox.fill(treatmentNoteText); + await expect(treatmentNotesBox).toHaveText(treatmentNoteText); + + await emsPage.getByText("COVID-19 suspected").click(); + + await expect(emsPage.locator("#covid19SuspectedIndicator-true")).toBeChecked(); + + const otherObservationsBox = emsPage.locator("#otherObservationNotes"); + + const otherText = "Patient is a fan of 90s grunge music"; + + await otherObservationsBox.fill(otherText); + await expect(otherObservationsBox).toHaveText(otherText); + + await emsPage.getByText("Select Hospital").click(); + + await expect(emsPage.getByText('Hospital Selection')).toBeVisible(); + + await emsPage.locator('label').filter({ hasText: 'CPMC Van Ness' }).click(); + + await expect(emsPage.locator('label').filter({ hasText: 'CPMC Van Ness' })).toBeChecked(); + + const etaBox = emsPage.locator("#etaMinutes"); + + await etaBox.fill("10"); + await expect(etaBox).toHaveText("10"); + + + await emsPage.getByText("Send Ringdown").click(); + + // Unfortunately, if a test fails at this point, the ringdown must be removed. Right now the state is saved + + await expect(emsPage.getByText('Ringdown sent')).toBeVisible(); + + }); test.afterEach(async ({ browser }) => { From 0b53a93caa1298652caaf3ca5ad7a910962241b1 Mon Sep 17 00:00:00 2001 From: Vincent Shuali Date: Tue, 3 Oct 2023 17:03:09 -0700 Subject: [PATCH 6/9] Submit a ringdown --- e2e/playwright.config.js | 4 ++-- e2e/tests/ringdown.spec.js | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/e2e/playwright.config.js b/e2e/playwright.config.js index 6e06e648..ca20a7de 100644 --- a/e2e/playwright.config.js +++ b/e2e/playwright.config.js @@ -14,13 +14,13 @@ require('dotenv').config({ path: '../.env' }); const config = { testDir: './tests', /* Maximum time one test can run for. */ - timeout: 30 * 1000, + timeout: 10 * 1000, expect: { /** * Maximum time expect() should wait for the condition to be met. * For example in `await expect(locator).toHaveText();` */ - timeout: 5000, + timeout: 2000, }, /* Run tests in files in parallel */ fullyParallel: true, diff --git a/e2e/tests/ringdown.spec.js b/e2e/tests/ringdown.spec.js index f8423d82..f771712b 100644 --- a/e2e/tests/ringdown.spec.js +++ b/e2e/tests/ringdown.spec.js @@ -1,9 +1,22 @@ const { test, expect } = require('@playwright/test'); +const cancelRingdown = async (page) => { + await page.getByText("Cancel delivery").click(); + + await expect(page.getByText('hospital will be notified')).toBeVisible(); + + await page.getByText("Yes, cancel delivery").click(); + + await expect(page.getByText('Delivery canceled')).toBeVisible(); + + await page.getByText("Start new form").click(); +} + let emsContext, erContext; let erPage, emsPage; test.describe('Initializing ringdowns', () => { test.beforeEach(async ({ browser }) => { + emsContext = await browser.newContext(); erContext = await browser.newContext(); @@ -17,6 +30,11 @@ test.describe('Initializing ringdowns', () => { await emsPassword.press('Enter'); await expect(emsPage).toHaveURL('/ems'); + const ringdownPresent = await emsPage.getByText("Ringdown sent"); + if(await ringdownPresent.count() > 0) { + await cancelRingdown(emsPage); + } + await erPage.goto('/'); await erPage.getByLabel('Email').fill(process.env.HOSPITAL_USER); const erPassword = erPage.getByLabel('Password'); @@ -133,7 +151,7 @@ test.describe('Initializing ringdowns', () => { const etaBox = emsPage.locator("#etaMinutes"); await etaBox.fill("10"); - await expect(etaBox).toHaveText("10"); + await expect(etaBox).toHaveValue("10"); await emsPage.getByText("Send Ringdown").click(); From 251771f71e50cbd4f986197f1a53cfb0dbf7a1f3 Mon Sep 17 00:00:00 2001 From: Vincent Shuali Date: Tue, 3 Oct 2023 17:22:38 -0700 Subject: [PATCH 7/9] Restore default playwright settings --- e2e/playwright.config.js | 4 ++-- e2e/tests/ringdown.spec.js | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/e2e/playwright.config.js b/e2e/playwright.config.js index ca20a7de..6e06e648 100644 --- a/e2e/playwright.config.js +++ b/e2e/playwright.config.js @@ -14,13 +14,13 @@ require('dotenv').config({ path: '../.env' }); const config = { testDir: './tests', /* Maximum time one test can run for. */ - timeout: 10 * 1000, + timeout: 30 * 1000, expect: { /** * Maximum time expect() should wait for the condition to be met. * For example in `await expect(locator).toHaveText();` */ - timeout: 2000, + timeout: 5000, }, /* Run tests in files in parallel */ fullyParallel: true, diff --git a/e2e/tests/ringdown.spec.js b/e2e/tests/ringdown.spec.js index f771712b..ce3a9a74 100644 --- a/e2e/tests/ringdown.spec.js +++ b/e2e/tests/ringdown.spec.js @@ -156,11 +156,8 @@ test.describe('Initializing ringdowns', () => { await emsPage.getByText("Send Ringdown").click(); - // Unfortunately, if a test fails at this point, the ringdown must be removed. Right now the state is saved - await expect(emsPage.getByText('Ringdown sent')).toBeVisible(); - }); test.afterEach(async ({ browser }) => { From 09d31b260004bd2fa59d930d68a1c8f4a4d45403 Mon Sep 17 00:00:00 2001 From: Vincent Shuali Date: Wed, 4 Oct 2023 01:16:41 +0000 Subject: [PATCH 8/9] Run prettier --- e2e/tests/ringdown.spec.js | 80 ++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/e2e/tests/ringdown.spec.js b/e2e/tests/ringdown.spec.js index ce3a9a74..07fe06e1 100644 --- a/e2e/tests/ringdown.spec.js +++ b/e2e/tests/ringdown.spec.js @@ -1,22 +1,21 @@ const { test, expect } = require('@playwright/test'); const cancelRingdown = async (page) => { - await page.getByText("Cancel delivery").click(); + await page.getByText('Cancel delivery').click(); await expect(page.getByText('hospital will be notified')).toBeVisible(); - await page.getByText("Yes, cancel delivery").click(); + await page.getByText('Yes, cancel delivery').click(); await expect(page.getByText('Delivery canceled')).toBeVisible(); - await page.getByText("Start new form").click(); -} + await page.getByText('Start new form').click(); +}; let emsContext, erContext; let erPage, emsPage; test.describe('Initializing ringdowns', () => { test.beforeEach(async ({ browser }) => { - emsContext = await browser.newContext(); erContext = await browser.newContext(); @@ -30,8 +29,8 @@ test.describe('Initializing ringdowns', () => { await emsPassword.press('Enter'); await expect(emsPage).toHaveURL('/ems'); - const ringdownPresent = await emsPage.getByText("Ringdown sent"); - if(await ringdownPresent.count() > 0) { + const ringdownPresent = await emsPage.getByText('Ringdown sent'); + if ((await ringdownPresent.count()) > 0) { await cancelRingdown(emsPage); } @@ -41,7 +40,6 @@ test.describe('Initializing ringdowns', () => { await erPassword.fill(process.env.HOSPITAL_PASS); await erPassword.press('Enter'); await expect(erPage).toHaveURL('/er'); - }); test('Submits a ringdown', async ({ browser }) => { @@ -57,7 +55,7 @@ test.describe('Initializing ringdowns', () => { const incidentComboBox = emsPage.locator('#dispatchCallNumber'); - await incidentComboBox.fill("2"); + await incidentComboBox.fill('2'); await incidentComboBox.press('Enter'); @@ -69,7 +67,7 @@ test.describe('Initializing ringdowns', () => { const ageBox = emsPage.locator('#age'); - await ageBox.fill("25"); + await ageBox.fill('25'); await expect(ageBox).toHaveValue('25'); await emsPage.getByText('Non-binary').click(); @@ -78,7 +76,7 @@ test.describe('Initializing ringdowns', () => { const chiefComplaintBox = emsPage.locator('#chiefComplaintDescription'); - const complaintText = "Patient ate too many skittles. They are experiencing severe regretitis"; + const complaintText = 'Patient ate too many skittles. They are experiencing severe regretitis'; await chiefComplaintBox.fill(complaintText); @@ -88,59 +86,59 @@ test.describe('Initializing ringdowns', () => { await expect(emsPage.locator('#stableIndicator-true')).toBeChecked(); - const systolicBox = emsPage.locator("#systolicBloodPressure"); + const systolicBox = emsPage.locator('#systolicBloodPressure'); - await systolicBox.fill("130"); - await expect(systolicBox).toHaveValue("130"); + await systolicBox.fill('130'); + await expect(systolicBox).toHaveValue('130'); - const diastolicBox = emsPage.locator("#diastolicBloodPressure"); + const diastolicBox = emsPage.locator('#diastolicBloodPressure'); - await diastolicBox.fill("80"); - await expect(diastolicBox).toHaveValue("80"); + await diastolicBox.fill('80'); + await expect(diastolicBox).toHaveValue('80'); - const pulseBox = emsPage.locator("#heartRateBpm"); + const pulseBox = emsPage.locator('#heartRateBpm'); - await pulseBox.fill("85"); - await expect(pulseBox).toHaveValue("85"); + await pulseBox.fill('85'); + await expect(pulseBox).toHaveValue('85'); - const respiratoryBox = emsPage.locator("#respiratoryRate"); + const respiratoryBox = emsPage.locator('#respiratoryRate'); - await respiratoryBox.fill("20"); - await expect(respiratoryBox).toHaveValue("20"); + await respiratoryBox.fill('20'); + await expect(respiratoryBox).toHaveValue('20'); - const oxygenBox = emsPage.locator("#oxygenSaturation"); + const oxygenBox = emsPage.locator('#oxygenSaturation'); - await oxygenBox.fill("40"); - await expect(oxygenBox).toHaveValue("40"); + await oxygenBox.fill('40'); + await expect(oxygenBox).toHaveValue('40'); await emsPage.getByText('Room Air').click(); await expect(emsPage.locator('[value="ROOM AIR"]')).toBeChecked(); - const temperatureBox = emsPage.locator("#temperature"); + const temperatureBox = emsPage.locator('#temperature'); - await temperatureBox.fill("98"); - await expect(temperatureBox).toHaveValue("98"); + await temperatureBox.fill('98'); + await expect(temperatureBox).toHaveValue('98'); - const treatmentNotesBox = emsPage.locator("#treatmentNotes"); + const treatmentNotesBox = emsPage.locator('#treatmentNotes'); - const treatmentNoteText = "N/A"; + const treatmentNoteText = 'N/A'; await treatmentNotesBox.fill(treatmentNoteText); await expect(treatmentNotesBox).toHaveText(treatmentNoteText); - await emsPage.getByText("COVID-19 suspected").click(); + await emsPage.getByText('COVID-19 suspected').click(); - await expect(emsPage.locator("#covid19SuspectedIndicator-true")).toBeChecked(); + await expect(emsPage.locator('#covid19SuspectedIndicator-true')).toBeChecked(); - const otherObservationsBox = emsPage.locator("#otherObservationNotes"); + const otherObservationsBox = emsPage.locator('#otherObservationNotes'); - const otherText = "Patient is a fan of 90s grunge music"; + const otherText = 'Patient is a fan of 90s grunge music'; await otherObservationsBox.fill(otherText); await expect(otherObservationsBox).toHaveText(otherText); - await emsPage.getByText("Select Hospital").click(); + await emsPage.getByText('Select Hospital').click(); await expect(emsPage.getByText('Hospital Selection')).toBeVisible(); @@ -148,16 +146,14 @@ test.describe('Initializing ringdowns', () => { await expect(emsPage.locator('label').filter({ hasText: 'CPMC Van Ness' })).toBeChecked(); - const etaBox = emsPage.locator("#etaMinutes"); + const etaBox = emsPage.locator('#etaMinutes'); - await etaBox.fill("10"); - await expect(etaBox).toHaveValue("10"); + await etaBox.fill('10'); + await expect(etaBox).toHaveValue('10'); - - await emsPage.getByText("Send Ringdown").click(); + await emsPage.getByText('Send Ringdown').click(); await expect(emsPage.getByText('Ringdown sent')).toBeVisible(); - }); test.afterEach(async ({ browser }) => { From 9f23b987638579a1503600653b73762463d3af03 Mon Sep 17 00:00:00 2001 From: Vincent Shuali Date: Tue, 3 Oct 2023 18:20:40 -0700 Subject: [PATCH 9/9] remove browser from jest argument --- e2e/tests/ringdown.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/tests/ringdown.spec.js b/e2e/tests/ringdown.spec.js index 07fe06e1..8c276292 100644 --- a/e2e/tests/ringdown.spec.js +++ b/e2e/tests/ringdown.spec.js @@ -42,7 +42,7 @@ test.describe('Initializing ringdowns', () => { await expect(erPage).toHaveURL('/er'); }); - test('Submits a ringdown', async ({ browser }) => { + test('Submits a ringdown', async () => { // TODO: move this into beforeEach once this works const unitComboBox = emsPage.locator('#ambulanceIdentifier');