Skip to content

Commit

Permalink
Fixed outdated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peterhudec committed Dec 12, 2024
1 parent b9ffdb9 commit 7e65e00
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 125 deletions.
32 changes: 9 additions & 23 deletions test/end-to-end/cypress/specs/DIT/event-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,15 @@ describe('Event', () => {
cy.visit(urls.events.index())
cy.contains(eventName).click()
cy.contains('Attendees').click()
cy.get(selectors.entityCollection.addAttendee).click()
cy.contains('Add attendee').click()

cy.get('[data-test="contact-name-filter"]')
.type('dean cox')
.type('{enter}')
cy.get('input[name="name"]').type('dean cox').type('{enter}')
cy.contains('Dean Cox').click()

cy.get(selectors.message.flashMessages)
.should(
'contain',
'Event attendee added - This has created a service delivery record.'
)
.and(
'contain',
cy.contains(
'Event attendee added - This has created a service delivery record. ' +
'If required, you can view or edit the service delivery directly from the attendee record.'
)
)
})
})

Expand Down Expand Up @@ -182,9 +175,7 @@ describe('Event', () => {
cy.visit(urls.events.details(event.pk))
cy.contains('a', 'Attendees').click()
cy.contains('Add attendee').click()
cy.get('[data-test="contact-name-filter"]')
.type('Attendee')
.type('{enter}')
cy.get('input[name="name"]').type('Attendee').type('{enter}')
cy.contains('Joe Attendee').click()
cy.contains('Event attendee added')
})
Expand All @@ -193,17 +184,12 @@ describe('Event', () => {
cy.visit(urls.events.details(event.pk))
cy.contains('a', 'Attendees').click()
cy.contains('Add attendee').click()
cy.get('[data-test="contact-name-filter"]')
.type('Attendee')
.type('{enter}')
cy.get('input[name="name"]').type('Attendee').type('{enter}')
cy.contains('Joe Attendee').click()
cy.contains('Add attendee').click()
cy.get('[data-test="contact-name-filter"]')
.type('Attendee')
.type('{enter}')
cy.get('input[name="name"]').type('Attendee').type('{enter}')
cy.contains('Joe Attendee').click()
cy.get(selectors.message.flashMessages).should(
'contain',
cy.contains(
'Event attendee not added - This contact has already been added as an event attendee'
)
})
Expand Down
9 changes: 3 additions & 6 deletions test/functional/cypress/specs/events/attendees-search-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,9 @@ describe('Event attendee search', () => {
it('should add an attendee to the event', () => {
cy.contains('Hanna Reinger').click()

cy.get('.c-message')
.should('exist')
.should(
'have.text',
'Event attendee added - This has created a service delivery record. If required, you can view or edit the service delivery directly from the attendee record.Dismiss'
)
cy.contains(
'Event attendee added - This has created a service delivery record. If required, you can view or edit the service delivery directly from the attendee record.'
)
})
})
})
123 changes: 28 additions & 95 deletions test/functional/cypress/specs/events/attendees-spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const fixtures = require('../../fixtures')
const selectors = require('../../../../selectors')
const urls = require('../../../../../src/lib/urls')

const {
Expand All @@ -8,101 +7,35 @@ const {
} = require('../../support/assertions')

describe('Event Attendees', () => {
context('Enabled events', () => {
beforeEach(() => {
cy.visit(`/events/${fixtures.event.oneDayExhibition.id}/attendees`)
cy.get('.c-collection').as('collectionList')
})

it('should render breadcrumbs', () => {
assertBreadcrumbs({
Home: urls.dashboard.index(),
Events: urls.events.index(),
'One-day exhibition': null,
})
})

it('should render the header', () => {
assertLocalHeader('One-day exhibition')
})

it('should display a collection header', () => {
cy.get('main article h2').should('contain', 'Event Attendees')
})

it('should display attendee collection list', () => {
cy.get(selectors.entityCollection.collection)
.find('header')
.should('contain', '1,233')
.parent()
.find('span')
.should('contain', 'Page 1 of 13')
.parents('header')
.next()
.find('li')
.should('have.length', 100)
})

it('should be able to use the pagination', () => {
cy.get(selectors.entityCollection.collection)
.find('nav ul li')
.as('pageLinks')
.eq(1)
.click()

cy.get(selectors.entityCollection.collection)
.find('header')
.should('contain', 'Page 2 of 13')

cy.get('@pageLinks').eq(0).click()

cy.get(selectors.entityCollection.collection)
.find('header')
.should('contain', 'Page 1 of 13')
})
it('Enabled events', () => {
cy.visit(`/events/${fixtures.event.oneDayExhibition.id}/attendees`)
assertBreadcrumbs({
Home: urls.dashboard.index(),
Events: urls.events.index(),
'One-day exhibition': null,
Attendees: null,
})
assertLocalHeader('One-day exhibition')
cy.contains('h2', 'Event Attendees')
cy.contains('h2', '1,233 attendees')
cy.contains('Page 1 of 124')
})
context('Disabled events', () => {
beforeEach(() => {
cy.visit(`/events/${fixtures.event.teddyBearExpo.id}/attendees`)
})

it('should render breadcrumbs', () => {
assertBreadcrumbs({
Home: urls.dashboard.index(),
Events: urls.events.index(),
'Teddy bear expo': null,
})
})

it('should render the header', () => {
assertLocalHeader('Teddy bear expo')
})

it('should display a message indicating when the event was disabled', () => {
assertLocalHeader(
'This event was disabled on 5 September 2017 and can no longer be edited'
)
})

it('should not display add attendees button for disabled events', () => {
cy.get(selectors.entityCollection.addAttendee).should('not.exist')
})

it('should display a message indicating that you cannot add an event attendee', () => {
cy.get('main article h2')
.next()
.should(
'contain',
'You cannot add an event attendee because the event has been disabled.'
)
})

it('should display a collection header', () => {
cy.get('main article h2').should('contain', 'Event Attendees')
})

it('should display attendee collection list', () => {
cy.get(selectors.collection.headerCount).should('contain', '1,233')
})
it('Disabled events', () => {
cy.visit(`/events/${fixtures.event.teddyBearExpo.id}/attendees`)
assertBreadcrumbs({
Home: urls.dashboard.index(),
Events: urls.events.index(),
'Teddy bear expo': null,
Attendees: null,
})
assertLocalHeader('Teddy bear expo')
assertLocalHeader(
'This event was disabled on 5 September 2017 and can no longer be edited'
)
cy.contains(
'You cannot add an event attendee because the event has been disabled.'
)
cy.contains('Add attendee').should('not.exist')
})
})
1 change: 0 additions & 1 deletion test/selectors/entity-collection.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
addAttendee: '[data-test="Add attendee"]',
addProposition: '[data-test="add-collection-item-button"]',
collection: '.c-collection',
sortBy: '[name="sortBy"] > select',
Expand Down

0 comments on commit 7e65e00

Please sign in to comment.