@@ -37,21 +37,22 @@ test('Admin groups management', async ({ page }) => {
3737 }
3838 } ) ;
3939
40- let group2 ;
40+ let group2 , group3 ;
4141 await test . step ( 'Create other 2 test groups' , async ( ) => {
4242 group2 = await createTestGroup ( page ) ;
43- await createTestGroup ( page ) ;
43+ group3 = await createTestGroup ( page ) ;
4444 } ) ;
4545
4646 const groupBadges = page . locator ( '.row' , { hasText : 'Groups' } ) . locator ( '.badge' ) ;
47+ let initialGroupBadgesCount ;
4748
4849 await test . step ( 'Open user editing page' , async ( ) => {
4950 await page . goto ( '/v2/admin/users' ) ;
5051 await waitPageLoading ( page ) ;
5152 await page . getByRole ( 'row' , { name : user1 } ) . getByRole ( 'link' , { name : 'Edit' } ) . click ( ) ;
5253 await waitPageLoading ( page ) ;
5354 const currentGroups = await groupBadges . allInnerTexts ( ) ;
54- expect ( currentGroups . length ) . toEqual ( 2 ) ;
55+ initialGroupBadgesCount = await groupBadges . count ( ) ;
5556 expect ( currentGroups . includes ( 'All' ) ) . toBeTruthy ( ) ;
5657 expect ( currentGroups . includes ( group1 ) ) . toBeTruthy ( ) ;
5758 } ) ;
@@ -65,7 +66,7 @@ test('Admin groups management', async ({ page }) => {
6566 await selectSlimSelect ( page , page . getByLabel ( 'Select groups' ) , group2 , true ) ;
6667 await modal . getByRole ( 'button' , { name : 'Add' } ) . click ( ) ;
6768 await waitModalClosed ( page ) ;
68- await expect ( groupBadges ) . toHaveCount ( 3 ) ;
69+ await expect ( groupBadges ) . toHaveCount ( initialGroupBadgesCount + 1 ) ;
6970 } ) ;
7071
7172 await test . step ( 'Reopen modal and check options' , async ( ) => {
@@ -80,24 +81,23 @@ test('Admin groups management', async ({ page }) => {
8081
8182 await test . step ( 'Remove group2 from groups to add' , async ( ) => {
8283 await page . getByLabel ( `Remove group ${ group2 } ` ) . click ( ) ;
83- await expect ( groupBadges ) . toHaveCount ( 2 ) ;
84+ await expect ( groupBadges ) . toHaveCount ( initialGroupBadgesCount ) ;
8485 } ) ;
8586
8687 let finalCount ;
87- await test . step ( 'Reopen modal and add all the groups to the user ' , async ( ) => {
88+ await test . step ( 'Reopen modal and group2 again and group3 ' , async ( ) => {
8889 await page . getByRole ( 'button' , { name : 'Add group' } ) . click ( ) ;
8990 const modal = page . locator ( '.modal.show' ) ;
9091 await modal . waitFor ( ) ;
9192 const selectableGroups = await page . getByRole ( 'option' ) . allInnerTexts ( ) ;
9293 expect ( selectableGroups . length ) . toEqual ( selectableGroups1 ) ;
93- for ( const group of selectableGroups ) {
94+ for ( let group of [ group2 , group3 ] . sort ( ) ) {
9495 await selectSlimSelect ( page , page . getByLabel ( 'Select groups' ) , group , true ) ;
9596 }
9697 await modal . getByRole ( 'button' , { name : 'Add' } ) . click ( ) ;
9798 await waitModalClosed ( page ) ;
98- finalCount = selectableGroups1 + 2 ;
99+ finalCount = initialGroupBadgesCount + 2 ;
99100 await expect ( groupBadges ) . toHaveCount ( finalCount ) ;
100- await expect ( page . getByRole ( 'button' , { name : 'Add group' } ) ) . not . toBeVisible ( ) ;
101101 } ) ;
102102
103103 await test . step ( 'Save and check' , async ( ) => {
0 commit comments