Skip to content
Prev Previous commit
Cypress: Add test for picking members and fix create collective tests
Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- committed Feb 21, 2023
commit eca453b3b0512b14139d5c7ee3d7a1b6c801da25
19 changes: 10 additions & 9 deletions cypress/e2e/collective.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ describe('Collective', function() {
it('Reports existing circle', function() {
cy.login('bob')
cy.createCollective('Foreign Circle')
cy.get('main .empty-content').should('contain', 'build shared knowledge')
cy.get('.toast-warning').should('contain', 'Could not create the collective')
cy.get('.toast-warning').should('contain', 'A circle with that name exists')
cy.get('.modal-collective-name-error').should('contain', 'A collective with this name already exists')
})
it('Reports existing collective', function() {
cy.login('bob')
Expand All @@ -78,10 +76,13 @@ describe('Collective', function() {
it('creates collectives by picking circle',
function() {
cy.login('bob')
cy.get('button.action-item span.circles-icon').click({ force: true })
cy.get('.multiselect__option').should('not.contain', 'Foreign')
cy.get('.multiselect__option [title*=History]').click()
cy.get('input.icon-confirm').click()
cy.get('button').contains('New collective').click()
cy.get('button span.circles-icon').click()
// cy.get('.circle-selector ul').should('not.contain', 'Foreign')
cy.get('.circle-selector li [title*=History]').click()
cy.get('button').contains('Add people').click()
cy.get('button').contains('Create').click()

cy.get('#titleform input').invoke('val').should('contain', 'History Club')
cy.get('.toast-info').should('contain',
'Created collective "History Club" for existing circle.'
Expand Down Expand Up @@ -129,7 +130,7 @@ describe('Collective', function() {
const randomName = 'Created just now ' + Math.random().toString(36).substr(2, 4)
it('has all the ui elements', function() {
cy.login('bob')
cy.createCollective(randomName)
cy.createCollective(randomName, ['jane', 'john'])
cy.log('Check name in the disabled titleform')
cy.get('#titleform input').invoke('val').should('contain', randomName)
cy.get('#titleform input').should('have.attr', 'disabled')
Expand All @@ -146,7 +147,7 @@ describe('Collective', function() {
})

describe('in non-admin collective', function() {
it.only('can leave collective and undo', function() {
it('can leave collective and undo', function() {
cy.login('jane')
cy.visit('/apps/collectives')

Expand Down
11 changes: 9 additions & 2 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,17 @@ Cypress.Commands.add('seedCollective', (name) => {
/**
* Create a collective via UI
*/
Cypress.Commands.add('createCollective', (name) => {
Cypress.Commands.add('createCollective', (name, members = []) => {
cy.log(`Creating collective ${name}`)
cy.get('a [title="New collective"]').click()
cy.get('button').contains('New collective').click()
cy.get('.collective-name input[type="text"]').type(`${name}{enter}`)
if (members.length > 0) {
for (const member of members) {
cy.get('.member-picker input[type="text"]').clear().type(`${member}`)
cy.get('.search-results .user-bubble__content').contains(member).click()
cy.get('.selected-members .user-bubble__content').should('contain', member)
}
}
cy.get('button').contains('Create').click()
})

Expand Down