@@ -18,6 +18,7 @@ test.describe.serial('Notification Sounds', () => {
1818 let targetChannel : string ;
1919 let targetChannelId : string ;
2020 let poHomeChannel : HomeChannel ;
21+ let user1PoHomeChannel : HomeChannel ;
2122 let user1Page : Page ;
2223
2324 test . beforeAll ( async ( { api } ) => {
@@ -34,9 +35,12 @@ test.describe.serial('Notification Sounds', () => {
3435
3536 test . beforeEach ( async ( { page, browser } ) => {
3637 poHomeChannel = new HomeChannel ( page ) ;
37- user1Page = await browser . newPage ( { storageState : Users . user1 . state } ) ;
3838 await page . goto ( `/channel/${ targetChannel } ` ) ;
3939
40+ user1Page = await browser . newPage ( { storageState : Users . user1 . state } ) ;
41+ user1PoHomeChannel = new HomeChannel ( user1Page ) ;
42+ await user1Page . goto ( `/channel/${ targetChannel } ` ) ;
43+
4044 await page . evaluate ( ( ) => {
4145 Audio . prototype . play = ( ( fn ) =>
4246 function ( this : HTMLAudioElement , ...args : unknown [ ] ) {
@@ -53,12 +57,10 @@ test.describe.serial('Notification Sounds', () => {
5357 } ) ;
5458
5559 test ( 'should play default notification sounds' , async ( { page } ) => {
56- await user1Page . goto ( `/channel/${ targetChannel } ` ) ;
57- const user1PoHomeChannel = new HomeChannel ( user1Page ) ;
60+ await poHomeChannel . content . waitForChannel ( ) ;
5861 await user1PoHomeChannel . content . waitForChannel ( ) ;
5962
6063 await poHomeChannel . navbar . btnHome . click ( ) ;
61-
6264 await user1PoHomeChannel . content . sendMessage ( `Hello @${ Users . admin . data . username } from User 1` ) ;
6365
6466 await page . waitForTimeout ( 100 ) ; // wait for the sound to play
@@ -83,12 +85,10 @@ test.describe.serial('Notification Sounds', () => {
8385 } ) ;
8486
8587 test ( 'should play notification sound based on user preferences' , async ( { page } ) => {
86- await user1Page . goto ( `/channel/${ targetChannel } ` ) ;
87- const user1PoHomeChannel = new HomeChannel ( user1Page ) ;
88+ await poHomeChannel . content . waitForChannel ( ) ;
8889 await user1PoHomeChannel . content . waitForChannel ( ) ;
8990
9091 await poHomeChannel . navbar . btnHome . click ( ) ;
91-
9292 await user1PoHomeChannel . content . sendMessage ( `Hello @${ Users . admin . data . username } from User 1` ) ;
9393
9494 await page . waitForTimeout ( 100 ) ; // wait for the sound to play
@@ -111,12 +111,10 @@ test.describe.serial('Notification Sounds', () => {
111111 } ) ;
112112
113113 test ( 'should play custom room notification sound' , async ( { page } ) => {
114- await user1Page . goto ( `/channel/${ targetChannel } ` ) ;
115- const user1PoHomeChannel = new HomeChannel ( user1Page ) ;
114+ await poHomeChannel . content . waitForChannel ( ) ;
116115 await user1PoHomeChannel . content . waitForChannel ( ) ;
117116
118117 await poHomeChannel . navbar . btnHome . click ( ) ;
119-
120118 await user1PoHomeChannel . content . sendMessage ( `Hello @${ Users . admin . data . username } from User 1` ) ;
121119
122120 await page . waitForTimeout ( 100 ) ; // wait for the sound to play
@@ -139,12 +137,10 @@ test.describe.serial('Notification Sounds', () => {
139137 } ) ;
140138
141139 test ( 'should not play any notification sound' , async ( { page } ) => {
142- await user1Page . goto ( `/channel/${ targetChannel } ` ) ;
143- const user1PoHomeChannel = new HomeChannel ( user1Page ) ;
140+ await poHomeChannel . content . waitForChannel ( ) ;
144141 await user1PoHomeChannel . content . waitForChannel ( ) ;
145142
146143 await poHomeChannel . navbar . btnHome . click ( ) ;
147-
148144 await user1PoHomeChannel . content . sendMessage ( `Hello @${ Users . admin . data . username } from User 1` ) ;
149145
150146 await page . waitForTimeout ( 100 ) ; // wait for the sound to play
0 commit comments