@@ -2,6 +2,9 @@ const { test, expect } = require('@playwright/test');
2
2
3
3
test . describe ( 'ER status' , ( ) => {
4
4
test . describe . configure ( { mode : 'serial' } ) ;
5
+ let erBeds = 0 ;
6
+ let behaviorBeds = 0 ;
7
+
5
8
test ( 'Update ER status' , async ( { context } ) => {
6
9
const appPage = await context . newPage ( ) ;
7
10
await appPage . goto ( '/' ) ;
@@ -15,8 +18,20 @@ test.describe('ER status', () => {
15
18
await expect ( appPage . getByText ( / a v a i l a b l e b e d s / i) ) . toBeVisible ( ) ;
16
19
await expect ( appPage . getByText ( / e r c o n d i t i o n s / i) ) . toBeVisible ( ) ;
17
20
await appPage . getByRole ( 'button' , { name : / u p d a t e h o s p i t a l / i } ) . click ( ) ;
18
- await appPage . getByRole ( 'textbox' , { name : / e r b e d s / i } ) . fill ( '5' ) ;
19
- await appPage . getByRole ( 'textbox' , { name : / b e h a v i o r a l b e d s / 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 ( / b e h a v i o r a l b e d s / 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
+ }
20
35
await appPage . locator ( '#additionalNotes' ) . fill ( 'scanner broke' ) ;
21
36
await appPage . getByRole ( 'button' , { name : / c o n f i r m / i } ) . click ( ) ;
22
37
} ) ;
@@ -31,8 +46,8 @@ test.describe('ER status', () => {
31
46
await expect ( appPage ) . toHaveURL ( '/ems' ) ;
32
47
await appPage . getByRole ( 'button' , { name : / h o s p i t a l i n f o / i } ) . click ( ) ;
33
48
const ucsfRow = appPage . locator ( '.hospitalstatusrow_container' ) . filter ( { hasText : / u c s f p a r n a s s u s / 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 ( ) ;
36
51
await expect ( ucsfRow . getByText ( 'scanner broke' ) ) . toBeVisible ( ) ;
37
52
await context . close ( ) ;
38
53
} ) ;
@@ -50,8 +65,22 @@ test.describe('ER status', () => {
50
65
await expect ( appPage . getByText ( / a v a i l a b l e b e d s / i) ) . toBeVisible ( ) ;
51
66
await expect ( appPage . getByText ( / e r c o n d i t i o n s / i) ) . toBeVisible ( ) ;
52
67
await appPage . getByRole ( 'button' , { name : / u p d a t e h o s p i t a l / i } ) . click ( ) ;
53
- await appPage . getByRole ( 'textbox' , { name : / e r b e d s / i } ) . fill ( '0' ) ;
54
- await appPage . getByRole ( 'textbox' , { name : / b e h a v i o r a l b e d s / 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 : / e r b e d s / 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 : / b e h a v i o r a l b e d s / i } ) . inputValue ( ) ) . toBe ( '0' ) ;
55
84
await appPage . locator ( '#additionalNotes' ) . fill ( '' ) ;
56
85
await appPage . getByRole ( 'button' , { name : / c o n f i r m / i } ) . click ( ) ;
57
86
} ) ;
0 commit comments