Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e er status update #319

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions client/src/Components/Counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,24 @@ function Counter({ label, min, max, name, onChange, value, isEditing }) {
<label className="counter__label" htmlFor={name}>
{label}
</label>
<div className="counter__control">
<button type="button" className="usa-button counter__button counter__button--decrement" onClick={handleDecrement}>
<div className="counter__control" data-testid={`counter_${name}`}>
<button
data-testid="decrement"
type="button"
className="usa-button counter__button counter__button--decrement"
onClick={handleDecrement}
>
&minus;
</button>
{!Number.isNaN(value) && (
<input className="usa-input usa-input--small counter__input" type="text" readOnly id={name} name={name} value={value} />
)}
<button type="button" className="usa-button counter__button counter__button--increment" onClick={handleIncrement}>
<button
data-testid="increment"
type="button"
className="usa-button counter__button counter__button--increment"
onClick={handleIncrement}
>
+
</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/src/EMS/HospitalStatusRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import './HospitalStatusRow.scss';
function HospitalStatusRow({ hospitalStatus }) {
const disabled = window.env.REACT_APP_DISABLE_PILOT_HOSPITALS === 'true' && hospitalStatus.hospitalName !== 'SF General';
return (
<div className="grid-row">
<div className="grid-row hospitalstatusrow_container">
<div className="grid-col-4 hospitalstatusrow__name-container">
<h3 className="hospitalstatusrow__name">{hospitalStatus.hospitalName}</h3>
<div className="hospitalstatusrow__timestamp">
Expand Down
103 changes: 103 additions & 0 deletions e2e/tests/erStatus.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
const { test, expect } = require('@playwright/test');

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

test('Update ER status', async ({ context }) => {
const appPage = await context.newPage();
await appPage.goto('/');
await appPage.getByLabel('Email').fill('[email protected]');
const password = appPage.getByLabel('Password');
await password.fill('abcd1234');
await password.press('Enter');
await expect(appPage).toHaveURL('/er');
await appPage.reload();
await appPage.getByRole('button', { name: /hospital/i }).click();
await expect(appPage.getByText(/available beds/i)).toBeVisible();
await expect(appPage.getByText(/er conditions/i)).toBeVisible();
await appPage.getByRole('button', { name: /update hospital/i }).click();
const erBedsRow = appPage.getByTestId('counter_openEdBedCount');
numberErBeds = parseInt(await erBedsRow.getByRole('textbox').inputValue(), 10);
for (let i = 0; i < 5; i++) {
await erBedsRow.getByRole('button', { name: '+' }).click();
numberErBeds++;
}

const behaviorNode = appPage.getByLabel(/behavioral beds/i);
const behaviorBedsRow = appPage.getByTestId('counter_openPsychBedCount');
numberBehaviorBeds = parseInt(await behaviorNode.inputValue(), 10);
for (let i = 0; i < 8; i++) {
await behaviorBedsRow.getByRole('button', { name: '+' }).click();
numberBehaviorBeds++;
}
await appPage.locator('#additionalNotes').fill('scanner broke');
await appPage.getByRole('button', { name: /confirm/i }).click();
});

test('EMS checks hospital status', async ({ context }) => {
const appPage = await context.newPage();
await appPage.goto('/');
await appPage.getByLabel('Email').fill('[email protected]');
const password = appPage.getByLabel('Password');
await password.fill('abcd1234');
await password.press('Enter');
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: `${numberErBeds}` })).toBeVisible();
await expect(ucsfRow.locator('.hospitalstatusrow__data').filter({ hasText: `${numberBehaviorBeds}` })).toBeVisible();
await expect(ucsfRow.getByText('scanner broke')).toBeVisible();
await context.close();
});

test('Decrement beds in ER back to 0', async ({ context }) => {
const appPage = await context.newPage();
await appPage.goto('/');
await appPage.getByLabel('Email').fill('[email protected]');
const password = appPage.getByLabel('Password');
await password.fill('abcd1234');
await password.press('Enter');
await expect(appPage).toHaveURL('/er');
await appPage.reload();
await appPage.getByRole('button', { name: /hospital/i }).click();
await expect(appPage.getByText(/available beds/i)).toBeVisible();
await expect(appPage.getByText(/er conditions/i)).toBeVisible();
await appPage.getByRole('button', { name: /update hospital/i }).click();
const erBedsRow = appPage.getByTestId('counter_openEdBedCount');
numberErBeds = parseInt(await erBedsRow.getByRole('textbox').inputValue(), 10);
while (numberErBeds >= 0) {
await erBedsRow.getByTestId('decrement').click();
numberErBeds--;
}
const erBedValue = await appPage.getByRole('textbox', { name: /er beds/i }).inputValue();
expect(erBedValue).toBe('0');

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

test('Hospital status matches latest changes after decrementing', async ({ context }) => {
const appPage = await context.newPage();
await appPage.goto('/');
await appPage.getByLabel('Email').fill('[email protected]');
const password = appPage.getByLabel('Password');
await password.fill('abcd1234');
await password.press('Enter');
await expect(appPage).toHaveURL('/ems');
await appPage.getByRole('button', { name: /hospital info/i }).click();
const row = appPage.locator('.hospitalstatusrow_container', { hasText: /ucsf parnassus/i });
await expect(row.locator('.hospitalstatusrow__data', { hasText: '5' })).not.toBeVisible();
await expect(row.locator('.hospitalstatusrow__data', { hasText: '8' })).not.toBeVisible();
await expect(row.locator('.hospitalstatusrow__notes', { hasText: 'scanner broke' })).not.toBeVisible();
await context.close();
});
});