Skip to content

Commit

Permalink
Test that buttons appear only when applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcnulty committed Apr 2, 2024
1 parent 7c0d311 commit d95088a
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion site/gatsby-site/cypress/e2e/integration/cite.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ describe('Cite pages', () => {

let user;

let lastIncidentId;

before('before', function () {
// Skip all tests if the environment is empty since /cite/{incident_id} is not available
Cypress.env('isEmptyEnvironment') && this.skip();
Expand All @@ -32,13 +34,35 @@ describe('Cite pages', () => {
first_name
last_name
}
incidents(limit: 1, sortBy: INCIDENT_ID_DESC) {
incident_id
}
}
`,
}).then(({ data: { user: userData } }) => {
}).then(({ data: { user: userData, incidents: incidentsData } }) => {
user = userData;
lastIncidentId = incidentsData[0].incident_id;
});
});

it('Should disable Previous and Next incident buttons in header on first and last incidents', () => {
cy.visit('/cite/1');

cy.get(`[data-cy="header-previous-incident-link"]`).should('not.exist');

cy.get(`[data-cy="header-next-incident-link"]`)
.should('be.visible')
.should('have.attr', 'href', '/cite/2');

cy.visit(`/cite/${lastIncidentId}`);

cy.get(`[data-cy="header-next-incident-link"]`).should('not.exist');

cy.get(`[data-cy="header-previous-incident-link"]`)
.should('be.visible')
.should('have.attr', 'href', `/cite/${lastIncidentId - 1}`);
});

maybeIt('Should show an edit link to users with the appropriate role', {}, () => {
cy.login(Cypress.env('e2eUsername'), Cypress.env('e2ePassword'));

Expand Down

0 comments on commit d95088a

Please sign in to comment.