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

Test new automation #1471

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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
143 changes: 143 additions & 0 deletions cypress/e2e/AccessibilityTests/accessibilityTests.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
describe('Accessibility Test Suite', () => {
context('when on the UK service', function() {
it('Find commodity page - Accessibility Test', () => {
cy.visit('/find_commodity');
cy.injectAndCheckA11y();
});
it('Browse page - Accessibility Test', () => {
cy.visit('/browse');
cy.injectAndCheckA11y();
});
it('A-z index page - Accessibility Test', () => {
cy.visit('/a-z-index/a');
cy.injectAndCheckA11y();
});
it('Tools page - Accessibility Test', () => {
cy.visit('/tools');
cy.injectAndCheckA11y();
});
it('News page - Accessibility Test', () => {
cy.visit('/news');
cy.injectAndCheckA11y();
});
it('Help page - Accessibility Test', () => {
cy.visit('/help');
cy.injectAndCheckA11y();
});
it('Quota search page - Accessibility Test', () => {
cy.visit('/quota_search');
cy.injectAndCheckA11y();
});
it('Additional code search page - Accessibility Test', () => {
cy.visit('/additional_code_search');
cy.injectAndCheckA11y();
});
it('Certificate search page - Accessibility Test', () => {
cy.visit('/certificate_search');
cy.injectAndCheckA11y();
});
it('Footnote search page - Accessibility Test', () => {
cy.visit('/footnote_search');
cy.injectAndCheckA11y();
});
it('Chemical search page - Accessibility Test', () => {
cy.visit('/chemical_search');
cy.injectAndCheckA11y();
});
it('Import page - Accessibility Test', () => {
cy.visit('/commodities/6004100091?country=JP#import');
cy.injectAndCheckA11y();
});
it('Export page - Accessibility Test', () => {
cy.visit('/commodities/6004100091?country=JP#export');
cy.injectAndCheckA11y();
});
it('Origin page - Accessibility Test', () => {
cy.visit('/commodities/6004100091?country=JP#rules-of-origin');
cy.injectAndCheckA11y();
});
it('Notes page - Accessibility Test', () => {
cy.visit('/commodities/6004100091?country=JP#footnotes');
cy.injectAndCheckA11y();
});
it('Duty calculator page - Northern Ireland to GB United Kingdom - Accessibility Test', () => {
cy.visit('/commodities/6004100091');
cy.dutyCalLink('6004100091');
cy.axeValidDate();
cy.axeSelectDestination('gb');
cy.axeOriginList({value: 'Northern Ireland'});
cy.axeNoDuty();
});
it.only('ROO - importing goods into the UK from Japan - Not Wholely Obtained + One Scheme + Insufficient processing - Japan - Accessibility Test', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ayfw Can you remove .only from this test case?

cy.visit('/commodities/6004100091?country=JP#rules-of-origin');
cy.axeCheckRoO();
cy.axeImpOrExp('Japan', 'import');
cy.axeHowOrginating('Japan', 'UK-Japan Comprehensive Economic Partnership Agreement');
cy.axeHowWhollyObtained('UK-Japan Comprehensive Economic Partnership Agreement');
cy.axeWhatComponents('UK-Japan Comprehensive Economic Partnership Agreement');
cy.axeWhollyObtained('Japan', 'no');
cy.axeNotWhollyObtained('Japan');
cy.axeCumulation('japan', '6004100091', 'JP', 'UK-Japan Comprehensive Economic Partnership Agreement');
cy.axeMinimalOps('UK-Japan Comprehensive Economic Partnership Agreement', 'no');
cy.axeRooNotMet('Importing', 'Japan', '6004100091', 'UK-Japan Comprehensive Economic Partnership Agreement');
});
});
context('when on the XI service', function() {
it('Find commodity page - Accessibility Test', () => {
cy.visit('/xi/find_commodity');
cy.injectAndCheckA11y();
});
it('Browse page - Accessibility Test', () => {
cy.visit('/xi/browse');
cy.injectAndCheckA11y();
});
it('A-z index page - Accessibility Test', () => {
cy.visit('/xi/a-z-index/a');
cy.injectAndCheckA11y();
});
it('Tools page - Accessibility Test', () => {
cy.visit('/xi/tools');
cy.injectAndCheckA11y();
});
it('News page - Accessibility Test', () => {
cy.visit('/xi/news');
cy.injectAndCheckA11y();
});
it('Help page - Accessibility Test', () => {
cy.visit('/xi/help');
cy.injectAndCheckA11y();
});
it('Additional code search page - Accessibility Test', () => {
cy.visit('/xi/additional_code_search');
cy.injectAndCheckA11y();
});
it('Certificate search page - Accessibility Test', () => {
cy.visit('/xi/certificate_search');
cy.injectAndCheckA11y();
});
it('Footnote search page - Accessibility Test', () => {
cy.visit('/xi/footnote_search');
cy.injectAndCheckA11y();
});
it('Chemical search page - Accessibility Test', () => {
cy.visit('/xi/chemical_search');
cy.injectAndCheckA11y();
});
it('Import page - Accessibility Test', () => {
cy.visit('/xi/commodities/6004100091?country=JP');
cy.injectAndCheckA11y();
});
it('Export page - Accessibility Test', () => {
cy.visit('/xi/commodities/6004100091?country=JP#export');
cy.injectAndCheckA11y();
});
it('Origin page - Accessibility Test', () => {
cy.visit('/xi/commodities/6004100091?country=JP#rules-of-origin');
cy.injectAndCheckA11y();
});
it('Notes page - Accessibility Test', () => {
cy.visit('/xi/commodities/6004100091?country=JP#footnotes');
cy.injectAndCheckA11y();
});
})
})
154 changes: 154 additions & 0 deletions cypress/support/accessibilityCommands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@

import dayjs from 'dayjs';

const currentDate = dayjs().format('DD');
const currentMonth = dayjs().format('MM');
const currentYear = dayjs().format('YYYY');

beforeEach(() => {
cy.clearCookies();
});

Cypress.Commands.add('axeIgnoreVio', (destination) => {
cy.injectAxe();
cy.checkA11y(null, null, (violations) => {
cy.log('Accessibility Violations:', violations);
violations.forEach(v => {
cy.log(`Violation: ${v.id} - ${v.description}`);
});
}, true);
});

Cypress.Commands.add('axeValidDate', () => {
cy.contains('When will the goods be imported?');
cy.title().should('eq', 'When will the good be imported - Online Tariff Duty calculator');
cy.get('#steps_import_date_import_date_3i').click();
cy.get('#steps_import_date_import_date_3i').clear();
cy.get('#steps_import_date_import_date_3i').type(currentDate);
cy.get('#steps_import_date_import_date_2i').click();
cy.get('#steps_import_date_import_date_2i').clear();
cy.get('#steps_import_date_import_date_2i').type(currentMonth);
cy.get('#steps_import_date_import_date_1i').click();
cy.get('#steps_import_date_import_date_1i').clear();
cy.get('#steps_import_date_import_date_1i').type(currentYear);
cy.axeIgnoreVio();
cy.contains('Continue').click();
cy.axeIgnoreVio();
});

Cypress.Commands.add('axeSelectDestination', (destination) => {
cy.contains('Which part of the UK are you importing into?');
cy.title().should('eq', 'Which part of the UK are you importing into - Online Tariff Duty calculator');
if (destination === 'xi') {
cy.get('#steps-import-destination-import-destination-xi-field').check();
} else {
cy.get('#steps-import-destination-import-destination-uk-field').check();
}
cy.contains('Continue').click();
cy.axeIgnoreVio();
});

Cypress.Commands.add('axeOriginList', (origin) => {
cy.contains('Where are the goods coming from?');
cy.title().should('eq', 'Which country are the goods dispatched from - Online Tariff Duty calculator');
cy.get('#steps-country-of-origin-country-of-origin-field').click();
cy.get('#steps-country-of-origin-country-of-origin-field').clear();
cy.get('#steps-country-of-origin-country-of-origin-field').type(origin.value);
cy.contains('Continue').click();
cy.axeIgnoreVio();
});

Cypress.Commands.add('axeNoDuty', (_options) => {
cy.contains('There is no import duty to pay');
cy.title().should('eq', 'There is no import duty to pay - Online Tariff Duty calculator');
cy.axeIgnoreVio();
});

Cypress.Commands.add('axeCheckRoO', ()=>{
cy.contains('UK Integrated Online Tariff ');
cy.get('div#rules-of-origin button[name=\'button\']').click();
cy.axeIgnoreVio();
});

Cypress.Commands.add('axeImpOrExp', (country, selection)=>{
cy.contains('Details of your trade');
cy.contains(`Are you importing goods into the UK or into ${country}?`);
cy.get(`#rules-of-origin-steps-import-export-import-or-export-${selection}-field`).check();
cy.get('.govuk-button').contains('Continue').click();
cy.axeIgnoreVio();
});

Cypress.Commands.add('axeHowOrginating', (country, agreement)=>{
cy.contains('Are your goods originating?');
cy.contains(`How to work out if your goods are classed as 'originating' in ${country}`);
cy.get('.govuk-body-l').contains(`${agreement}`);
cy.contains(`Click on the ‘Continue’ button to view the definition of ‘wholly obtained’ in the ${agreement}.`);
cy.get('.govuk-button').contains('Continue').click();
cy.axeIgnoreVio();
});

Cypress.Commands.add('axeHowWhollyObtained', (agreement)=>{
cy.contains('Are your goods originating?');
cy.contains(`How 'wholly obtained' is defined in the ${agreement}`);
cy.contains(`Click on the ‘Continue’ button to see which parts and processes should be included or disregarded in determining originating status for the ${agreement}.`);
cy.get('.govuk-button').contains('Continue').click();
cy.axeIgnoreVio();
});

Cypress.Commands.add('axeWhatComponents', (agreement)=>{
cy.contains('Are your goods originating?');
cy.contains(`Neutral elements in the ${agreement}`);
cy.contains(`Packing materials in the ${agreement}`);
cy.contains(`Accessories, spare parts and tools in the ${agreement}`);
cy.contains(`Click on the 'Continue' button to indicate if your goods are wholly obtained, based on the rules of the ${agreement}.`);
cy.get('.govuk-button').contains('Continue').click();
cy.axeIgnoreVio();
});

Cypress.Commands.add('axeWhollyObtained', (country, select)=>{
cy.get(`#rules-of-origin-steps-wholly-obtained-wholly-obtained-${select}-field`).check();
cy.get('.govuk-button').contains('Continue').click();
cy.axeIgnoreVio();
});

Cypress.Commands.add('axeNotWhollyObtained', (country)=>{
cy.contains('Are your goods originating?');
cy.get('.govuk-button').contains('Continue').click();
cy.axeIgnoreVio();
});

Cypress.Commands.add('axeCumulation', (country, code, countryShortName, scheme)=>{
cy.contains('Are your goods originating?');
cy.get('form#edit_rules_of_origin_steps_cumulation_cumulation a[target=\'_blank\']').should('have.attr', 'href', `/cumulation_maps/${country}.png`);
cy.contains('Bilateral cumulation - an example').click();
cy.contains('insufficient processing clause').should('have.attr', 'href', `/rules_of_origin/${code}/${countryShortName}/sufficient_processing`);
if (`${countryShortName}` === 'JP') {
cy.contains('Extended cumulation - an example').click();
cy.contains('insufficient processing clause').should('have.attr', 'href', `/rules_of_origin/${code}/${countryShortName}/sufficient_processing`);
} else if (`${countryShortName}` === 'KR') {
cy.contains('Diagonal cumulation - an example').click();
cy.should('not.contain.text', 'insufficient processing clause');
}
cy.get('.govuk-button').contains('Continue').click();
cy.axeIgnoreVio();
});

Cypress.Commands.add('axeMinimalOps', (scheme, selection)=>{
cy.contains('Are your goods originating?');
cy.get(`#rules-of-origin-steps-sufficient-processing-sufficient-processing-${selection}-field`).check();
cy.get('.govuk-button').contains('Continue').click();
cy.axeIgnoreVio();
});

Cypress.Commands.add('axeRooNotMet', (tradetype, country, code, scheme)=>{
cy.contains(`${tradetype} commodity ${code} from ${country}`);
cy.contains('Product-specific rules not met');
cy.should('not.have.text', 'Find out about duty drawback');
cy.get('.govuk-warning-text__text').contains('obtaining and verifying proofs of origin').click();
cy.contains('Valid proofs of origin');
cy.go('back');
cy.get('.govuk-warning-text__text').contains('start again').click();
cy.contains(`Are you importing goods into the UK or into ${country}?`);
cy.axeIgnoreVio();
bhavanibandla marked this conversation as resolved.
Show resolved Hide resolved
});

22 changes: 22 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ const months = [

const goodsNomenclatureLinkRegex = /\/(headings|subheadings|commodities)\/[0-9]{4}(?:-[0-9]{2})?/;



// Add custom command to run axe
Cypress.Commands.add('injectAndCheckA11y', (context = 'body', options = null, violationCallback = null, skipFailures = false) => {
cy.injectAxe();
cy.checkA11y(context, options, violationCallback, skipFailures);
});

Cypress.Commands.add('disableAnimations', () => {
const css = `
*, *::before, *::after {
transition: none !important;
animation: none !important;
}
`;
cy.document().then((doc) => {
const style = doc.createElement('style');
style.appendChild(doc.createTextNode(css));
doc.head.appendChild(style);
});
});

Cypress.Commands.add('datePickerPage', (date) => {
const importDateInput = (index) => `input[name='import_export_date[import_date(${index}i)]']`;

Expand Down
2 changes: 2 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import './adminCommands';
import './dutyCommands';
import './apiCommands';
import './rooCommands';
import './accessibilityCommands';
import './glCommands';
import 'cypress-fill-command';
import 'cypress-axe';
require('@cypress/grep')();
require('cypress-downloadfile/lib/downloadFileCommand');

Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"allure-commandline": "^2.29.0",
"ansi-regex": "^6.0.1",
"ansi-styles": "^6.2.1",
"cypress": "13.10.0",
"cypress-dark": "^1.7.14",
"axe-core": "^4.10.0",
bhavanibandla marked this conversation as resolved.
Show resolved Hide resolved
"cypress-dark": "^1.1.0",
"cypress-dotenv": "https://github.com/morficus/cypress-dotenv",
"cypress-downloadfile": "^1.2.3",
"cypress-file-upload": "^5.0.8",
Expand Down Expand Up @@ -69,5 +69,9 @@
"dev-tariff-duty-calculator-smoketests": "CYPRESS_SPACE=DEVELOPMENT CYPRESS_BASE_URL=https://dev.trade-tariff.service.gov.uk yarn run cypress run --spec cypress/e2e/smoketests/dcSmokeTestCI.cy.js",
"dev-tariff-admin-smoketests": "CYPRESS_SPACE=DEVELOPMENT CYPRESS_BASE_URL=https://dev.trade-tariff.service.gov.uk yarn run cypress run --spec cypress/e2e/smoketests/adminSmokeTestCI.cy.js",
"dev-tariff-infrastructure-smoketests": "CYPRESS_SPACE=DEVELOPMENT CYPRESS_BASE_URL=https://dev.trade-tariff.service.gov.uk yarn run cypress run --spec cypress/e2e/smoketests/infrastructureSmokeTestCI.cy.js"
},
"devDependencies": {
"cypress": "^13.13.1",
"cypress-axe": "^1.5.0"
}
}
Loading