Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cypress tests #368

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});
});
});
Loading
Loading