Skip to content

Commit

Permalink
updated tests to reflect current ckan endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tejpowar committed Apr 10, 2024
1 parent 0fb87a4 commit 82b9128
Showing 1 changed file with 45 additions and 54 deletions.
99 changes: 45 additions & 54 deletions ui/cypress/e2e/home.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ import { a11yLog } from '../support/custom';
describe('Homepage', () => {
it('should show home page and call to action', () => {
cy.visit('/');
cy.contains(
'Find standards to record, handle and exchange data in England'
);
cy.contains(
'Use this directory to find nationally recognised data standards for use in health and adult social care.'

cy.get('.nhsuk-body-l').contains('Use this service to find out about recognised published and future standards in health and adult social care.'
);
});

Expand All @@ -23,63 +20,57 @@ describe('Homepage', () => {
cy.doSearch('hospital');
cy.get('#browse-results li').not('have.length', 0);
});
it('Blank search returns results', () => {
cy.visit('/');
cy.doSearch(' ');
cy.get('#browse-results li').not('have.length', 0);
describe('a11y', () => {
it('has sufficient contrast on focussed links', () => {
cy.visit('/');
cy.get('main');
cy.injectAxe();
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(100);
cy.get('.nhsuk-phase-banner__text a').focus();
cy.checkA11y(null, null, a11yLog);
cy.get('#recent-standards a').first().focus();
cy.checkA11y(null, null, a11yLog);
});

it('use a11y checker with wcag2aa', () => {
cy.visit('/');
cy.injectAxe();
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(100);
cy.checkA11y(null, {
runOnly: {
type: 'tag',
values: ['wcag2aa', 'wcag21aa'],
},
});
});
});
});

describe('a11y', () => {
it('has sufficient contrast on focussed links', () => {
it('passes html validation', () => {
cy.visit('/');
cy.get('main');
cy.injectAxe();
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(100);
cy.get('.nhsuk-phase-banner__text a').focus();
cy.checkA11y(null, null, a11yLog);
cy.get('#recent-standards a').first().focus();
cy.checkA11y(null, null, a11yLog);
cy.htmlvalidate();
});

it('use a11y checker with wcag2aa', () => {
cy.visit('/');
cy.injectAxe();
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(100);
cy.checkA11y(null, {
runOnly: {
type: 'tag',
values: ['wcag2aa', 'wcag21aa'],
},
describe('cookies', () => {
it('clicking approve removes banner, sets consent preference:true', () => {
cy.visit('/');
cy.get('#nhsuk-cookie-banner').should('be.visible');
cy.getCookie('localConsent').should('not.exist');
cy.get('#nhsuk-cookie-banner__link_accept_analytics').click();
cy.get('#nhsuk-cookie-banner').should('not.exist');
cy.getCookie('localConsent').should('have.property', 'value', 'true');
});
});
});

it('passes html validation', () => {
cy.visit('/');
cy.get('main');
cy.htmlvalidate();
});

describe('cookies', () => {
it('clicking approve removes banner, sets consent preference:true', () => {
cy.visit('/');
cy.get('#nhsuk-cookie-banner').should('be.visible');
cy.getCookie('localConsent').should('not.exist');
cy.get('#nhsuk-cookie-banner__link_accept_analytics').click();
cy.get('#nhsuk-cookie-banner').should('not.exist');
cy.getCookie('localConsent').should('have.property', 'value', 'true');
});

it('clicking reject removes banner, sets consent preference:false', () => {
cy.visit('/');
cy.get('#nhsuk-cookie-banner').should('be.visible');
cy.getCookie('localConsent').should('not.exist');
cy.get('#nhsuk-cookie-banner__link_reject').click();
cy.get('#nhsuk-cookie-banner').should('not.exist');
cy.getCookie('localConsent').should('have.property', 'value', 'false');
it('clicking reject removes banner, sets consent preference:false', () => {
cy.visit('/');
cy.get('#nhsuk-cookie-banner').should('be.visible');
cy.getCookie('localConsent').should('not.exist');
cy.get('#nhsuk-cookie-banner__link_reject').click();
cy.get('#nhsuk-cookie-banner').should('not.exist');
cy.getCookie('localConsent').should('have.property', 'value', 'false');
});
});
});
});

0 comments on commit 82b9128

Please sign in to comment.