diff --git a/cypress/support/commands.js b/cypress/support/commands.js index aa08d835b..bdaaeb529 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -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() - 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` + const response = await axios.post(url, + { userId, type }, ) + const memberId = response.data.ocs.data.id + return { circleId: id, userId, memberId } }) -Cypress.Commands.add('circleAddMember', async (circleId, { userId, type }) => { +Cypress.Commands.add('circleSetMemberLevel', + { prevSubject: true }, + ({ circleId, memberId }, level) => { Cypress.log() 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 } }) /**