Skip to content

Commit

Permalink
test(cy): add getCollectives and getTrashCollectives commands
Browse files Browse the repository at this point in the history
Also return the collective from deleteAndSeedCollective

Signed-off-by: Max <max@nextcloud.com>
  • Loading branch information
max-nextcloud committed Nov 14, 2023
1 parent 622b558 commit beae1fa
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ Cypress.Commands.add('deleteAndSeedCollective', (name) => {
Cypress.log()
cy.deleteCollective(name)
cy.seedCollective(name)
cy.getCollectives()
.findBy({ name })
})

Cypress.Commands.add('seedCollective', (name) => {
Expand Down Expand Up @@ -215,30 +217,34 @@ Cypress.Commands.add('deleteCollective', (name) => {
cy.deleteCollectiveFromTrash(name)
})

Cypress.Commands.add('getCollectives', () => {
return api.getCollectives()
.then(response => response.data.data)
})

/**
* Move a collective into the trash if it exists.
*
* This command will succeed if the collective does not exist at all.
*/
Cypress.Commands.add('trashCollective', (name) => {
cy.then(() => {
return api.getCollectives()
.then(response => response.data.data)
})
cy.getCollectives()
.findBy({ name })
.then((found) => found && api.trashCollective(found.id))
})

Cypress.Commands.add('getTrashCollectives', () => {
return api.getTrashCollectives()
.then(response => response.data.data)
})

/**
* Clear a collective from the trash if it is in there.
*
* This command will succeed if the collective does not exist at all.
*/
Cypress.Commands.add('deleteCollectiveFromTrash', (name) => {
cy.then(() => {
return api.getTrashCollectives()
.then(response => response.data.data)
})
cy.getTrashCollectives()
.findBy({ name })
.then((found) => found && api.deleteCollective(found.id))
})
Expand Down

0 comments on commit beae1fa

Please sign in to comment.