@@ -2,6 +2,9 @@ const { test, expect } = require('@playwright/test');
22
33test . 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 ( / a v a i l a b l e b e d s / i) ) . toBeVisible ( ) ;
1619 await expect ( appPage . getByText ( / e r c o n d i t i o n s / i) ) . toBeVisible ( ) ;
1720 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+ }
2035 await appPage . locator ( '#additionalNotes' ) . fill ( 'scanner broke' ) ;
2136 await appPage . getByRole ( 'button' , { name : / c o n f i r m / i } ) . click ( ) ;
2237 } ) ;
@@ -31,8 +46,8 @@ test.describe('ER status', () => {
3146 await expect ( appPage ) . toHaveURL ( '/ems' ) ;
3247 await appPage . getByRole ( 'button' , { name : / h o s p i t a l i n f o / i } ) . click ( ) ;
3348 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 ( ) ;
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 ( / a v a i l a b l e b e d s / i) ) . toBeVisible ( ) ;
5166 await expect ( appPage . getByText ( / e r c o n d i t i o n s / i) ) . toBeVisible ( ) ;
5267 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' ) ;
5584 await appPage . locator ( '#additionalNotes' ) . fill ( '' ) ;
5685 await appPage . getByRole ( 'button' , { name : / c o n f i r m / i } ) . click ( ) ;
5786 } ) ;
0 commit comments