2020-12-10 14:52:35 +01:00
|
|
|
import {TeamFactory} from '../../factories/team'
|
|
|
|
import {TeamMemberFactory} from '../../factories/team_member'
|
2021-01-06 23:36:31 +01:00
|
|
|
import {UserFactory} from '../../factories/user'
|
2020-12-10 14:52:35 +01:00
|
|
|
import '../../support/authenticateUser'
|
|
|
|
|
|
|
|
describe('Team', () => {
|
|
|
|
it('Creates a new team', () => {
|
|
|
|
TeamFactory.truncate()
|
|
|
|
cy.visit('/teams')
|
|
|
|
|
2021-01-21 20:14:26 +01:00
|
|
|
const newTeamName = 'New Team'
|
|
|
|
|
2020-12-10 14:52:35 +01:00
|
|
|
cy.get('a.button')
|
2021-06-24 01:24:57 +02:00
|
|
|
.contains('Create a new team')
|
2020-12-10 14:52:35 +01:00
|
|
|
.click()
|
|
|
|
cy.url()
|
|
|
|
.should('contain', '/teams/new')
|
2021-01-21 23:33:16 +01:00
|
|
|
cy.get('.card-header-title')
|
2020-12-10 14:52:35 +01:00
|
|
|
.contains('Create a new team')
|
|
|
|
cy.get('input.input')
|
2021-01-21 20:14:26 +01:00
|
|
|
.type(newTeamName)
|
2021-01-17 18:57:57 +01:00
|
|
|
cy.get('.button')
|
2021-01-21 23:33:16 +01:00
|
|
|
.contains('Create')
|
2020-12-10 14:52:35 +01:00
|
|
|
.click()
|
|
|
|
|
|
|
|
cy.url()
|
|
|
|
.should('contain', '/edit')
|
2021-01-21 20:14:26 +01:00
|
|
|
cy.get('input#teamtext')
|
|
|
|
.should('have.value', newTeamName)
|
2020-12-10 14:52:35 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Shows all teams', () => {
|
|
|
|
TeamMemberFactory.create(10, {
|
|
|
|
team_id: '{increment}',
|
|
|
|
})
|
|
|
|
const teams = TeamFactory.create(10, {
|
|
|
|
id: '{increment}',
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.visit('/teams')
|
|
|
|
|
|
|
|
cy.get('.teams.box')
|
|
|
|
.should('not.be.empty')
|
|
|
|
teams.forEach(t => {
|
|
|
|
cy.get('.teams.box')
|
|
|
|
.should('contain', t.name)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Allows an admin to edit the team', () => {
|
|
|
|
TeamMemberFactory.create(1, {
|
|
|
|
team_id: 1,
|
|
|
|
admin: true,
|
|
|
|
})
|
|
|
|
const teams = TeamFactory.create(1, {
|
|
|
|
id: 1,
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.visit('/teams/1/edit')
|
|
|
|
cy.get('.card input.input')
|
|
|
|
.first()
|
|
|
|
.type('{selectall}New Team Name')
|
|
|
|
|
|
|
|
cy.get('.card .button')
|
|
|
|
.contains('Save')
|
|
|
|
.click()
|
|
|
|
|
|
|
|
cy.get('table.table td')
|
|
|
|
.contains('Admin')
|
|
|
|
.should('exist')
|
|
|
|
cy.get('.global-notification')
|
|
|
|
.should('contain', 'Success')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Does not allow a normal user to edit the team', () => {
|
|
|
|
TeamMemberFactory.create(1, {
|
|
|
|
team_id: 1,
|
|
|
|
admin: false,
|
|
|
|
})
|
|
|
|
const teams = TeamFactory.create(1, {
|
|
|
|
id: 1,
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.visit('/teams/1/edit')
|
|
|
|
cy.get('.card input.input')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('table.table td')
|
|
|
|
.contains('Member')
|
|
|
|
.should('exist')
|
|
|
|
})
|
2021-01-06 23:36:31 +01:00
|
|
|
|
|
|
|
it('Allows an admin to add members to the team', () => {
|
|
|
|
TeamMemberFactory.create(1, {
|
|
|
|
team_id: 1,
|
|
|
|
admin: true,
|
|
|
|
})
|
|
|
|
TeamFactory.create(1, {
|
|
|
|
id: 1,
|
|
|
|
})
|
|
|
|
const users = UserFactory.create(5)
|
|
|
|
|
|
|
|
cy.visit('/teams/1/edit')
|
|
|
|
cy.get('.card')
|
|
|
|
.contains('Team Members')
|
|
|
|
.get('.card-content .multiselect .input-wrapper input')
|
|
|
|
.type(users[1].username)
|
|
|
|
cy.get('.card')
|
|
|
|
.contains('Team Members')
|
|
|
|
.get('.card-content .multiselect .search-results')
|
|
|
|
.children()
|
|
|
|
.first()
|
|
|
|
.click()
|
|
|
|
cy.get('.card')
|
|
|
|
.contains('Team Members')
|
2021-01-17 18:57:57 +01:00
|
|
|
.get('.card-content .button')
|
2021-06-24 01:24:57 +02:00
|
|
|
.contains('Add to team')
|
2021-01-06 23:36:31 +01:00
|
|
|
.click()
|
|
|
|
|
|
|
|
cy.get('table.table td')
|
|
|
|
.contains('Admin')
|
|
|
|
.should('exist')
|
|
|
|
cy.get('table.table tr')
|
|
|
|
.should('contain', users[1].username)
|
|
|
|
.should('contain', 'Member')
|
|
|
|
cy.get('.global-notification')
|
|
|
|
.should('contain', 'Success')
|
|
|
|
})
|
2020-12-10 14:52:35 +01:00
|
|
|
})
|