Skip to content

Commit 71d8849

Browse files
committed
Revert functional changes and use buttons instead
1 parent 5a88428 commit 71d8849

File tree

3 files changed

+50
-19
lines changed

3 files changed

+50
-19
lines changed

client/src/Components/Counter.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,24 @@ function Counter({ label, min, max, name, onChange, value, isEditing }) {
2828
<label className="counter__label" htmlFor={name}>
2929
{label}
3030
</label>
31-
<div className="counter__control">
32-
<button type="button" className="usa-button counter__button counter__button--decrement" onClick={handleDecrement}>
31+
<div className="counter__control" data-testid={`counter_${name}`}>
32+
<button
33+
data-testid="decrement"
34+
type="button"
35+
className="usa-button counter__button counter__button--decrement"
36+
onClick={handleDecrement}
37+
>
3338
&minus;
3439
</button>
3540
{!Number.isNaN(value) && (
36-
<input
37-
className="usa-input usa-input--small counter__input"
38-
type="text"
39-
readOnly={!isEditing}
40-
id={name}
41-
name={name}
42-
value={value}
43-
onChange={onChange}
44-
/>
41+
<input className="usa-input usa-input--small counter__input" type="text" readOnly id={name} name={name} value={value} />
4542
)}
46-
<button type="button" className="usa-button counter__button counter__button--increment" onClick={handleIncrement}>
43+
<button
44+
data-testid="increment"
45+
type="button"
46+
className="usa-button counter__button counter__button--increment"
47+
onClick={handleIncrement}
48+
>
4749
+
4850
</button>
4951
</div>

client/src/ER/Beds.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function Beds({ statusUpdate, onStatusUpdate, incomingRingdownsCount }) {
1717

1818
function handleChange(event) {
1919
const newStatusUpdate = new HospitalStatus(statusUpdate);
20-
newStatusUpdate[event.target.name] = parseInt(event.target.value, 10) || 0;
20+
newStatusUpdate[event.target.name] = parseInt(event.target.value, 10);
2121
onStatusUpdate(newStatusUpdate);
2222
}
2323

e2e/tests/erStatus.spec.js

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ const { test, expect } = require('@playwright/test');
22

33
test.describe('ER status', () => {
44
test.describe.configure({ mode: 'serial' });
5+
let erBeds = 0;
6+
let behaviorBeds = 0;
7+
58
test('Update ER status', async ({ context }) => {
69
const appPage = await context.newPage();
710
await appPage.goto('/');
@@ -15,8 +18,20 @@ test.describe('ER status', () => {
1518
await expect(appPage.getByText(/available beds/i)).toBeVisible();
1619
await expect(appPage.getByText(/er conditions/i)).toBeVisible();
1720
await appPage.getByRole('button', { name: /update hospital/i }).click();
18-
await appPage.getByRole('textbox', { name: /er beds/i }).fill('5');
19-
await appPage.getByRole('textbox', { name: /behavioral beds/i }).fill('8');
21+
const erBedsRow = appPage.getByTestId('counter_openEdBedCount');
22+
erBeds = parseInt(await erBedsRow.getByRole('textbox').inputValue(), 10);
23+
for (let i = 0; i < 5; i++) {
24+
await erBedsRow.getByRole('button', { name: '+' }).click();
25+
erBeds += 1;
26+
}
27+
28+
const behaviorNode = appPage.getByLabel(/behavioral beds/i);
29+
const behaviorBedsRow = appPage.getByTestId('counter_openPsychBedCount');
30+
behaviorBeds = parseInt(await behaviorNode.inputValue(), 10);
31+
for (let i = 0; i < 8; i++) {
32+
await behaviorBedsRow.getByRole('button', { name: '+' }).click();
33+
behaviorBeds += 1;
34+
}
2035
await appPage.locator('#additionalNotes').fill('scanner broke');
2136
await appPage.getByRole('button', { name: /confirm/i }).click();
2237
});
@@ -31,8 +46,8 @@ test.describe('ER status', () => {
3146
await expect(appPage).toHaveURL('/ems');
3247
await appPage.getByRole('button', { name: /hospital info/i }).click();
3348
const ucsfRow = appPage.locator('.hospitalstatusrow_container').filter({ hasText: /ucsf parnassus/i });
34-
await expect(ucsfRow.locator('.hospitalstatusrow__data').filter({ hasText: '5' })).toBeVisible();
35-
await expect(ucsfRow.locator('.hospitalstatusrow__data').filter({ hasText: '8' })).toBeVisible();
49+
await expect(ucsfRow.locator('.hospitalstatusrow__data').filter({ hasText: `${erBeds}` })).toBeVisible();
50+
await expect(ucsfRow.locator('.hospitalstatusrow__data').filter({ hasText: `${behaviorBeds}` })).toBeVisible();
3651
await expect(ucsfRow.getByText('scanner broke')).toBeVisible();
3752
await context.close();
3853
});
@@ -50,8 +65,22 @@ test.describe('ER status', () => {
5065
await expect(appPage.getByText(/available beds/i)).toBeVisible();
5166
await expect(appPage.getByText(/er conditions/i)).toBeVisible();
5267
await appPage.getByRole('button', { name: /update hospital/i }).click();
53-
await appPage.getByRole('textbox', { name: /er beds/i }).fill('0');
54-
await appPage.getByRole('textbox', { name: /behavioral beds/i }).fill('0');
68+
const erBedsRow = appPage.getByTestId('counter_openEdBedCount');
69+
erBeds = parseInt(await erBedsRow.getByRole('textbox').inputValue(), 10);
70+
while (erBeds >= 0) {
71+
await erBedsRow.getByTestId('decrement').click();
72+
erBeds--;
73+
}
74+
const erBedValue = await appPage.getByRole('textbox', { name: /er beds/i }).inputValue();
75+
expect(erBedValue).toBe('0');
76+
77+
const behaviorBedsRow = appPage.getByTestId('counter_openPsychBedCount');
78+
behaviorBeds = parseInt(await behaviorBedsRow.getByRole('textbox').inputValue(), 10);
79+
while (behaviorBeds >= 0) {
80+
await behaviorBedsRow.getByTestId('decrement').click();
81+
behaviorBeds--;
82+
}
83+
expect(await appPage.getByRole('textbox', { name: /behavioral beds/i }).inputValue()).toBe('0');
5584
await appPage.locator('#additionalNotes').fill('');
5685
await appPage.getByRole('button', { name: /confirm/i }).click();
5786
});

0 commit comments

Comments
 (0)