Skip to content

Commit 1d0ae0c

Browse files
committed
test(settings): Fix group items not being found
Signed-off-by: Christopher Ng <[email protected]>
1 parent c617f26 commit 1d0ae0c

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

cypress/e2e/settings/users_groups.cy.ts

+24-26
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ describe('Settings: Assign user to a group', { testIsolation: false }, () => {
6161
})
6262

6363
it('see that the group is in the list', () => {
64-
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').contains('li', groupName).should('exist')
65-
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').contains('li', groupName).within(() => {
66-
cy.get('.counter-bubble__counter')
67-
.should('not.exist') // is hidden when 0
68-
})
64+
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').find('li').contains(groupName)
65+
.should('exist')
66+
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').find('li').contains(groupName)
67+
.find('.counter-bubble__counter')
68+
.should('not.exist') // is hidden when 0
6969
})
7070

7171
it('see that the user is in the list', () => {
@@ -103,8 +103,7 @@ describe('Settings: Assign user to a group', { testIsolation: false }, () => {
103103

104104
it('see the group was successfully assigned', () => {
105105
// see a new memeber
106-
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]')
107-
.contains('li', groupName)
106+
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').find('li').contains(groupName)
108107
.find('.counter-bubble__counter')
109108
.should('contain', '1')
110109
})
@@ -129,14 +128,14 @@ describe('Settings: Delete an empty group', { testIsolation: false }, () => {
129128
})
130129

131130
it('see that the group is in the list', () => {
132-
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').within(() => {
133-
// see that the list of groups contains the group foo
134-
cy.contains(groupName).should('exist').scrollIntoView()
135-
// open the actions menu for the group
136-
cy.contains('li', groupName).within(() => {
137-
cy.get('button.action-item__menutoggle').click({ force: true })
138-
})
139-
})
131+
// see that the list of groups contains the group foo
132+
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').find('li').contains(groupName)
133+
.should('exist')
134+
.scrollIntoView()
135+
// open the actions menu for the group
136+
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').find('li').contains(groupName)
137+
.find('button.action-item__menutoggle')
138+
.click({ force: true })
140139
})
141140

142141
it('can delete the group', () => {
@@ -150,10 +149,9 @@ describe('Settings: Delete an empty group', { testIsolation: false }, () => {
150149
})
151150

152151
it('deleted group is not shown anymore', () => {
153-
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').within(() => {
154-
// see that the list of groups does not contain the group
155-
cy.contains(groupName).should('not.exist')
156-
})
152+
// see that the list of groups does not contain the group
153+
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').find('li').contains(groupName)
154+
.should('not.exist')
157155
// and also not in database
158156
cy.runOccCommand('group:list --output=json').then(($response) => {
159157
const groups: string[] = Object.keys(JSON.parse($response.stdout))
@@ -181,13 +179,14 @@ describe('Settings: Delete a non empty group', () => {
181179

182180
it('see that the group is in the list', () => {
183181
// see that the list of groups contains the group
184-
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').contains('li', groupName).should('exist').scrollIntoView()
182+
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').find('li').contains(groupName)
183+
.should('exist')
184+
.scrollIntoView()
185185
})
186186

187187
it('can delete the group', () => {
188188
// open the menu
189-
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]')
190-
.contains('li', groupName)
189+
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').find('li').contains(groupName)
191190
.find('button.action-item__menutoggle')
192191
.click({ force: true })
193192

@@ -201,10 +200,9 @@ describe('Settings: Delete a non empty group', () => {
201200
})
202201

203202
it('deleted group is not shown anymore', () => {
204-
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').within(() => {
205-
// see that the list of groups does not contain the group foo
206-
cy.contains(groupName).should('not.exist')
207-
})
203+
// see that the list of groups does not contain the group foo
204+
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').find('li').contains(groupName)
205+
.should('not.exist')
208206
// and also not in database
209207
cy.runOccCommand('group:list --output=json').then(($response) => {
210208
const groups: string[] = Object.keys(JSON.parse($response.stdout))

0 commit comments

Comments
 (0)