@@ -21,9 +21,10 @@ const SNAPSHOT_OPTIONS = {
2121 failureThreshold : 0.25
2222} ;
2323
24+ let r = ( Math . random ( ) + 1 ) . toString ( 36 ) . substring ( 7 ) ;
2425
2526//USERS:
26- const USERNAME = 'color_picker_TestUser'
27+ const USERNAME = `TestUser ${ r } `
2728const PASSWORD = 'testpassword'
2829
2930//TESTS:
@@ -59,9 +60,10 @@ describe('Test for the Control Panel - color picker', () => {
5960
6061 await page . on ( "dialog" , dialog =>
6162 dialog . accept ( ) ) ;
62-
63+
64+ await page . waitForSelector ( selectors . SELECT_CELL_BUTTON_SELECTOR , { timeout : TIMEOUT , visible : true } )
6365 await page . waitForSelector ( selectors . FILE_TAB_SELECTOR , { timeout : PAGE_WAIT * 30 } )
64- await page . waitForTimeout ( PAGE_WAIT * 7 )
66+ await page . waitForTimeout ( PAGE_WAIT )
6567 await page . click ( selectors . FILE_TAB_SELECTOR )
6668 await page . waitForSelector ( selectors . NEW_FILE_SELECTOR , { timeout : PAGE_WAIT * 10 } )
6769 await page . waitForTimeout ( PAGE_WAIT )
@@ -182,9 +184,7 @@ describe('Test for the Control Panel - color picker', () => {
182184 } ) ;
183185
184186 expect ( rndm_primary_level_colors [ 0 ] ) . toContain ( 'fill="#989898"' )
185- // expect(rndm_primary_level_colors[1]).not.toEqual(rndm_primary_level_colors[0])
186- // expect(rndm_primary_level_colors[2]).not.toEqual(rndm_primary_level_colors[0])
187- // expect(rndm_primary_level_colors[2]).not.toEqual(rndm_primary_level_colors[1])
187+ expect ( rndm_primary_level_colors [ 2 ] ) . not . toEqual ( rndm_primary_level_colors [ 1 ] )
188188
189189 console . log ( 'Main Network color randomized successfully' )
190190
@@ -201,14 +201,15 @@ describe('Test for the Control Panel - color picker', () => {
201201 await rows [ 1 ] . click ( )
202202 await rows [ 1 ] . hover ( )
203203 }
204+ await page . waitForTimeout ( PAGE_WAIT )
204205
205206 const second_level_colors = await page . $$eval ( selectors . COLOR_RECT_SELECTOR , second_level_colors => {
206207 return second_level_colors . map ( second_level_color => second_level_color . outerHTML ) ;
207208 } ) ;
208209
209210
210- expect ( second_level_colors [ 1 ] ) . not . toEqual ( second_level_colors [ 2 ] )
211- // expect(second_level_colors[2]).toEqual(second_level_colors[3])
211+ expect ( second_level_colors [ 1 ] ) . toEqual ( second_level_colors [ 2 ] )
212+ expect ( second_level_colors [ 2 ] ) . toEqual ( second_level_colors [ 3 ] )
212213
213214
214215 const buttons = await page . $$ ( selectors . COLOR_CONTROL_BUTTONS_SELECTOR )
@@ -217,8 +218,15 @@ describe('Test for the Control Panel - color picker', () => {
217218 await buttons [ 2 ] . click ( )
218219 }
219220
220- expect ( second_level_colors [ 2 ] ) . not . toEqual ( second_level_colors [ 3 ] )
221- expect ( second_level_colors [ 1 ] ) . toContain ( 'fill="#989898"' )
221+ await page . waitForTimeout ( PAGE_WAIT * 2 )
222+
223+ const second_level_colors_after_rndm = await page . $$eval ( selectors . COLOR_RECT_SELECTOR , second_level_colors_after_rndm => {
224+ return second_level_colors_after_rndm . map ( second_level_color_after_rndm => second_level_color_after_rndm . outerHTML ) ;
225+ } ) ;
226+
227+ expect ( second_level_colors_after_rndm [ 1 ] ) . toContain ( 'fill="#989898"' )
228+ expect ( second_level_colors_after_rndm [ 2 ] ) . not . toEqual ( second_level_colors_after_rndm [ 3 ] )
229+ expect ( second_level_colors_after_rndm [ 2 ] ) . not . toEqual ( second_level_colors_after_rndm [ 1 ] )
222230
223231 console . log ( 'E Network color randomized successfully' )
224232
@@ -244,12 +252,14 @@ describe('Test for the Control Panel - color picker', () => {
244252 await rows_ [ 2 ] . click ( )
245253 }
246254
255+ await page . waitForTimeout ( PAGE_WAIT )
256+
247257 const network_colors = await page . $$eval ( selectors . COLOR_RECT_SELECTOR , network_colors => {
248258 return network_colors . map ( network_color => network_color . outerHTML ) ;
249259 } ) ;
250260
251- // expect(network_colors[2 ]).toContain('fill="#989898"' )
252- // expect(network_colors[3]).toEqual(network_colors[4 ])
261+ expect ( network_colors [ 3 ] ) . toEqual ( network_colors [ 4 ] )
262+ expect ( network_colors [ 3 ] ) . toEqual ( network_colors [ 2 ] )
253263
254264 await page . waitForTimeout ( PAGE_WAIT * 3 )
255265
@@ -283,7 +293,6 @@ describe('Test for the Control Panel - color picker', () => {
283293 } ) ;
284294 await page . waitForTimeout ( PAGE_WAIT )
285295
286- expect ( network_colors_after_colouring_I [ 2 ] ) . toContain ( 'fill="#420b0b"' )
287296 expect ( network_colors_after_colouring_I [ 2 ] ) . toEqual ( network_colors_after_colouring_I [ 3 ] )
288297 expect ( network_colors_after_colouring_I [ 2 ] ) . toEqual ( network_colors_after_colouring_I [ 4 ] )
289298
@@ -293,17 +302,19 @@ describe('Test for the Control Panel - color picker', () => {
293302
294303 it ( 'Filter results from the Control panel' , async ( ) => {
295304
305+
306+ await page . waitForTimeout ( PAGE_WAIT )
296307 console . log ( 'Filtering results' )
297308
309+ await expect ( page ) . toFill ( 'input[class="MuiInputBase-input MuiOutlinedInput-input"]' , 'E' )
298310
299-
300-
301- // await page.waitForSelector('ul[role="tree"]')
302- // const network_items = (await page.$$('li[role="treeitem"]')).length;
303- // await expect(network_items).toEqual(3)
311+ await page . waitForTimeout ( PAGE_WAIT )
304312
305- console . log ( 'Results filtered successfully' )
313+ await page . waitForSelector ( 'ul[role="tree"]' )
314+ const network_items = ( await page . $$ ( 'li[role="treeitem"]' ) ) . length ;
315+ await expect ( network_items ) . toEqual ( 3 )
306316
317+ console . log ( 'Results filtered successfully' )
307318
308319 } )
309320
0 commit comments