Skip to content

Commit

Permalink
Test cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ddrosario committed Oct 19, 2023
1 parent 4323c9e commit d6604c4
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions e2e/tests/erStatus.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const { test, expect } = require('@playwright/test');

test.describe('ER status', () => {
test.describe.configure({ mode: 'serial' });
let erBeds = 0;
let behaviorBeds = 0;
let numberErBeds = 0;
let numberBehaviorBeds = 0;

test('Update ER status', async ({ context }) => {
const appPage = await context.newPage();
Expand All @@ -19,18 +19,18 @@ test.describe('ER status', () => {
await expect(appPage.getByText(/er conditions/i)).toBeVisible();
await appPage.getByRole('button', { name: /update hospital/i }).click();
const erBedsRow = appPage.getByTestId('counter_openEdBedCount');
erBeds = parseInt(await erBedsRow.getByRole('textbox').inputValue(), 10);
numberErBeds = parseInt(await erBedsRow.getByRole('textbox').inputValue(), 10);
for (let i = 0; i < 5; i++) {
await erBedsRow.getByRole('button', { name: '+' }).click();
erBeds += 1;
numberErBeds++;
}

const behaviorNode = appPage.getByLabel(/behavioral beds/i);
const behaviorBedsRow = appPage.getByTestId('counter_openPsychBedCount');
behaviorBeds = parseInt(await behaviorNode.inputValue(), 10);
numberBehaviorBeds = parseInt(await behaviorNode.inputValue(), 10);
for (let i = 0; i < 8; i++) {
await behaviorBedsRow.getByRole('button', { name: '+' }).click();
behaviorBeds += 1;
numberBehaviorBeds++;
}
await appPage.locator('#additionalNotes').fill('scanner broke');
await appPage.getByRole('button', { name: /confirm/i }).click();
Expand All @@ -46,8 +46,8 @@ test.describe('ER status', () => {
await expect(appPage).toHaveURL('/ems');
await appPage.getByRole('button', { name: /hospital info/i }).click();
const ucsfRow = appPage.locator('.hospitalstatusrow_container').filter({ hasText: /ucsf parnassus/i });
await expect(ucsfRow.locator('.hospitalstatusrow__data').filter({ hasText: `${erBeds}` })).toBeVisible();
await expect(ucsfRow.locator('.hospitalstatusrow__data').filter({ hasText: `${behaviorBeds}` })).toBeVisible();
await expect(ucsfRow.locator('.hospitalstatusrow__data').filter({ hasText: `${numberErBeds}` })).toBeVisible();
await expect(ucsfRow.locator('.hospitalstatusrow__data').filter({ hasText: `${numberBehaviorBeds}` })).toBeVisible();
await expect(ucsfRow.getByText('scanner broke')).toBeVisible();
await context.close();
});
Expand All @@ -66,19 +66,19 @@ test.describe('ER status', () => {
await expect(appPage.getByText(/er conditions/i)).toBeVisible();
await appPage.getByRole('button', { name: /update hospital/i }).click();
const erBedsRow = appPage.getByTestId('counter_openEdBedCount');
erBeds = parseInt(await erBedsRow.getByRole('textbox').inputValue(), 10);
while (erBeds >= 0) {
numberErBeds = parseInt(await erBedsRow.getByRole('textbox').inputValue(), 10);
while (numberErBeds >= 0) {
await erBedsRow.getByTestId('decrement').click();
erBeds--;
numberErBeds--;
}
const erBedValue = await appPage.getByRole('textbox', { name: /er beds/i }).inputValue();
expect(erBedValue).toBe('0');

const behaviorBedsRow = appPage.getByTestId('counter_openPsychBedCount');
behaviorBeds = parseInt(await behaviorBedsRow.getByRole('textbox').inputValue(), 10);
while (behaviorBeds >= 0) {
numberBehaviorBeds = parseInt(await behaviorBedsRow.getByRole('textbox').inputValue(), 10);
while (numberBehaviorBeds >= 0) {
await behaviorBedsRow.getByTestId('decrement').click();
behaviorBeds--;
numberBehaviorBeds--;
}
expect(await appPage.getByRole('textbox', { name: /behavioral beds/i }).inputValue()).toBe('0');
await appPage.locator('#additionalNotes').fill('');
Expand Down

0 comments on commit d6604c4

Please sign in to comment.