Skip to content

Commit

Permalink
test(cy): use child commands for seeding circle
Browse files Browse the repository at this point in the history
Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Nov 9, 2023
1 parent b463947 commit d5865f5
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,33 +355,30 @@ Cypress.Commands.add('seedCircleMember', (name, userId, type = 1, level) => {
cy.dispatch(GET_CIRCLES)
cy.store('state.circles.circles')
.findBy({ sanitizedName: name })
.its('id')
.then(circleId => {
cy.circleAddMember(circleId, { userId, type })
})
.then(({ circleId, memberId }) => {
if (level) {
cy.circleSetMemberLevel(circleId, memberId, level)
}
})
.circleAddMember({ userId, type })
.circleSetMemberLevel(level)
})

Cypress.Commands.add('circleSetMemberLevel', (circleId, memberId, level) => {
Cypress.Commands.add('circleAddMember',
{ prevSubject: true },
async ({ id }, { userId, type }) => {
Cypress.log()

Check failure on line 365 in cypress/support/commands.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 2 tabs but found 1
const url = `${Cypress.env('baseUrl')}/ocs/v2.php/apps/circles/circles/${circleId}/members`
return axios.put(`${url}/${memberId}/level`,
{ level },
const url = `${Cypress.env('baseUrl')}/ocs/v2.php/apps/circles/circles/${id}/members`

Check failure on line 366 in cypress/support/commands.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 2 tabs but found 1
const response = await axios.post(url,

Check failure on line 367 in cypress/support/commands.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 2 tabs but found 1
{ userId, type },

Check failure on line 368 in cypress/support/commands.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 3 tabs but found 2
)

Check failure on line 369 in cypress/support/commands.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 2 tabs but found 1
const memberId = response.data.ocs.data.id

Check failure on line 370 in cypress/support/commands.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 2 tabs but found 1
return { circleId: id, userId, memberId }

Check failure on line 371 in cypress/support/commands.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 2 tabs but found 1
})

Check failure on line 372 in cypress/support/commands.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 1 tab but found 0

Cypress.Commands.add('circleAddMember', async (circleId, { userId, type }) => {
Cypress.Commands.add('circleSetMemberLevel',
{ prevSubject: true },
({ circleId, memberId }, level) => {
Cypress.log()

Check failure on line 377 in cypress/support/commands.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 2 tabs but found 1
const url = `${Cypress.env('baseUrl')}/ocs/v2.php/apps/circles/circles/${circleId}/members`
const response = await axios.post(url,
{ userId, type },
return axios.put(`${url}/${memberId}/level`,
{ level },
)
const memberId = response.data.ocs.data.id
return { circleId, userId, memberId }
})

/**
Expand Down

0 comments on commit d5865f5

Please sign in to comment.