mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-08-16 18:41:39 -07:00
Gherkin workflows for desktop (#788)
* Add gherkin tests for page navigation links - test that every page will load when navigating from any other page - update snapshots * Add gherkin workflows 2 - 5 - add test for Federal program officer key information and CTA - add test for Community members key information and CTA - add test for Send feedback - add test for Join the Open Source community - update snapshots * Add gherkin tests for footer links - add footerlinks feature gherkin file - adds a comment to the hyphenizeString() - adds keyword functions for footer - adds data-cy tags to footer component - updates snapshots * Adds workflow to learn more about EO * Add gherkin test for dataset links - add data-cy tags to dataset sections - modify Cy command functions names - update snapshots * Add cypress test to deploy_staging.yml * Add working directory env * Remove keywords.js from cypress test * Add a Then step to all About and Footer tests * Refactor step definitions - use globalStepDefinitions - rename keywords to commonSteps - remove keyword from exclusion list
This commit is contained in:
parent
3b04356fb3
commit
92d76fb6f4
27 changed files with 295 additions and 71 deletions
|
@ -1,17 +1,16 @@
|
|||
Feature: Does the About page open?
|
||||
I want to open the about page
|
||||
Feature: The About page will open from all other pages
|
||||
|
||||
Scenario: About page FROM Explore Tool page
|
||||
Given I am on the Explore Tool page
|
||||
Scenario: About page open when navigating from Explore the Tool page
|
||||
Given I am on the "Explore the tool" page
|
||||
When I click on the "About" page in the navigation
|
||||
Then I see "About" in the title
|
||||
|
||||
Scenario: About page FROM Methodology page
|
||||
Given I am on the Explore Tool page
|
||||
When I click on the "Methodology" page in the navigation
|
||||
Then I see "Data and Methodology" in the title
|
||||
Scenario: About page open when navigating from Methodology page
|
||||
Given I am on the "Methodology" page
|
||||
When I click on the "About" page in the navigation
|
||||
Then I see "About" in the title
|
||||
|
||||
Scenario: About page FROM Contact page
|
||||
Given I am on the Explore Tool page
|
||||
When I click on the "Contact" page in the navigation
|
||||
Then I see "Contact" in the title
|
||||
Scenario: About page open when navigating from Contact page
|
||||
Given I am on the "Contact" page
|
||||
When I click on the "About" page in the navigation
|
||||
Then I see "About" in the title
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
// / <reference types="Cypress" />
|
||||
import {Given, When} from 'cypress-cucumber-preprocessor/steps';
|
||||
import {ENDPOINTS} from '../LegacyTests/constants';
|
||||
|
||||
// eslint-disable-next-line new-cap
|
||||
Given('I am on the About page', () => {
|
||||
cy.viewport(1060, 800);
|
||||
cy.visit(ENDPOINTS.ABOUT);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line new-cap
|
||||
Given('I am on the Explore Tool page', () => {
|
||||
cy.viewport(1060, 800);
|
||||
cy.visit(ENDPOINTS.EXPLORE_THE_TOOL);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line new-cap
|
||||
Given('I am on the Data & Methodology page', () => {
|
||||
cy.viewport(1060, 800);
|
||||
cy.visit(ENDPOINTS.METHODOLOGY);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line new-cap
|
||||
Given('I open the Contact page', () => {
|
||||
cy.viewport(1060, 800);
|
||||
cy.visit(ENDPOINTS.CONTACT);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line new-cap
|
||||
When(`I click on the {string} page in the navigation`, (page) => {
|
||||
cy.get(`[data-cy="nav-link-${page.toLowerCase()}"]`).click();
|
||||
});
|
30
client/cypress/integration/AboutLinks.feature
Normal file
30
client/cypress/integration/AboutLinks.feature
Normal file
|
@ -0,0 +1,30 @@
|
|||
Feature: All links on About page are functional
|
||||
|
||||
Scenario: Visitors can learn more about the J40 EO
|
||||
Given I am on the "About" page
|
||||
When I look for the "The Justice40 Initiative" CTA
|
||||
And I click on the "The Justice40 Initiative" "external" link
|
||||
Then the link should respond successfully
|
||||
|
||||
Scenario: Federal program officer can find and click on their CTA
|
||||
Given I am on the "About" page
|
||||
When I look for the "Federal program managers" CTA
|
||||
And I click on the "Federal program managers" "internal" link
|
||||
Then I see "Methodology" in the title
|
||||
|
||||
Scenario: Community members can find and click on their CTA
|
||||
Given I am on the "About" page
|
||||
When I look for the "Community members" CTA
|
||||
And I click on the "Community members" "internal" link
|
||||
Then I see "Explore the tool" in the title
|
||||
|
||||
Scenario: People can find how to Send feedback
|
||||
Given I am on the "About" page
|
||||
When I look for the "Send feedback" CTA
|
||||
Then the link should allow client to send an email to "screeningtool.feedback@usds.gov"
|
||||
|
||||
Scenario: Open source community can find and click on their CTA
|
||||
Given I am on the "About" page
|
||||
When I look for the "Join the open source community" CTA
|
||||
And I click on the "Join the open source community" "external" link
|
||||
Then the link should respond successfully
|
16
client/cypress/integration/Contact.feature
Normal file
16
client/cypress/integration/Contact.feature
Normal file
|
@ -0,0 +1,16 @@
|
|||
Feature: The Contact page will open from all other pages
|
||||
|
||||
Scenario: Contact page open when navigating from About page
|
||||
Given I am on the "About" page
|
||||
When I click on the "Contact" page in the navigation
|
||||
Then I see "Contact" in the title
|
||||
|
||||
Scenario: Contact page open when navigating from Explore the tool page
|
||||
Given I am on the "Explore the tool" page
|
||||
When I click on the "Contact" page in the navigation
|
||||
Then I see "Contact" in the title
|
||||
|
||||
Scenario: Contact page open when navigating from Methodology page
|
||||
Given I am on the "Methodology" page
|
||||
When I click on the "Contact" page in the navigation
|
||||
Then I see "Contact" in the title
|
11
client/cypress/integration/DatasetLinks.feature
Normal file
11
client/cypress/integration/DatasetLinks.feature
Normal file
|
@ -0,0 +1,11 @@
|
|||
Feature: All links on the dataset cards should be functional
|
||||
|
||||
Scenario: If I click on any link in the indicators dataset, they should work
|
||||
Given I am on the "Methodology" page
|
||||
When I look for the "Datasets used in methodology" CTA
|
||||
Then All links under "Datasets used in methodology" should work
|
||||
|
||||
Scenario: If I click on any link in the additional indicators dataset, they should work
|
||||
Given I am on the "Methodology" page
|
||||
When I look for the "Additional Indicators" CTA
|
||||
Then All links under "Additional Indicators" should work
|
16
client/cypress/integration/Explore.feature
Normal file
16
client/cypress/integration/Explore.feature
Normal file
|
@ -0,0 +1,16 @@
|
|||
Feature: The Explore the tool page will open from all other pages
|
||||
|
||||
Scenario: Explore the tool page open when navigating from About page
|
||||
Given I am on the "About" page
|
||||
When I click on the "Explore the tool" page in the navigation
|
||||
Then I see "Explore the tool" in the title
|
||||
|
||||
Scenario: Explore the tool page open when navigating from Methodology page
|
||||
Given I am on the "Methodology" page
|
||||
When I click on the "Explore the tool" page in the navigation
|
||||
Then I see "Explore the tool" in the title
|
||||
|
||||
Scenario: Explore the tool page open when navigating from Contact page
|
||||
Given I am on the "Contact" page
|
||||
When I click on the "Explore the tool" page in the navigation
|
||||
Then I see "Explore the tool" in the title
|
25
client/cypress/integration/FooterLinks.feature
Normal file
25
client/cypress/integration/FooterLinks.feature
Normal file
|
@ -0,0 +1,25 @@
|
|||
Feature: All links in the Footer are functional
|
||||
|
||||
Scenario: I can find more information on the Whitehouse
|
||||
Given I am on the "About" page
|
||||
When I look for the "footer"
|
||||
And I click on the "Whitehouse.gov" footer link
|
||||
Then the link should respond successfully
|
||||
|
||||
Scenario: I can find more information on FOIA
|
||||
Given I am on the "About" page
|
||||
When I look for the "footer"
|
||||
And I click on the "Freedom of Information Act (FOIA)" footer link
|
||||
Then the link should respond successfully
|
||||
|
||||
Scenario: I can find more information on the Privacy Policy
|
||||
Given I am on the "About" page
|
||||
When I look for the "footer"
|
||||
And I click on the "Privacy Policy" footer link
|
||||
Then the link should respond successfully
|
||||
|
||||
Scenario: I can find find a contact at USA.gov
|
||||
Given I am on the "About" page
|
||||
When I look for the "footer"
|
||||
And I click on the "Find a contact at USA.gov" footer link
|
||||
Then the link should respond successfully
|
|
@ -1,5 +1,5 @@
|
|||
export const ENDPOINTS = {
|
||||
ABOUT: 'en',
|
||||
ABOUT: 'en/',
|
||||
EXPLORE_THE_TOOL: '/en/cejst',
|
||||
METHODOLOGY: '/en/methodology',
|
||||
CONTACT: 'en/contact',
|
||||
|
|
16
client/cypress/integration/Methodology.feature
Normal file
16
client/cypress/integration/Methodology.feature
Normal file
|
@ -0,0 +1,16 @@
|
|||
Feature: The Methodology page will open from all other pages
|
||||
|
||||
Scenario: Methodology page open when navigating from About page
|
||||
Given I am on the "About" page
|
||||
When I click on the "Methodology" page in the navigation
|
||||
Then I see "Methodology" in the title
|
||||
|
||||
Scenario: Methodology page open when navigating from Explore the tool page
|
||||
Given I am on the "Explore the tool" page
|
||||
When I click on the "Methodology" page in the navigation
|
||||
Then I see "Methodology" in the title
|
||||
|
||||
Scenario: Methodology page open when navigating from Contact page
|
||||
Given I am on the "Contact" page
|
||||
When I click on the "Methodology" page in the navigation
|
||||
Then I see "Methodology" in the title
|
16
client/cypress/integration/common/helpers.js
Normal file
16
client/cypress/integration/common/helpers.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Helper functions that need to be shared between both the src codebase
|
||||
// and the cypress tests
|
||||
|
||||
/**
|
||||
* This function will take a string and hyphenize it.
|
||||
* For example:
|
||||
* Whitehouse.gov => whitehouse-gov
|
||||
* Privacy Policy => privacy-policy
|
||||
*
|
||||
* @param {string} string
|
||||
* @return {string}
|
||||
*/
|
||||
export const hyphenizeString = (string) => {
|
||||
return string.split(/\.| /).join('-').toLowerCase();
|
||||
};
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
// eslint-disable-next-line new-cap
|
||||
Then(`I see {string} in the title`, (title) => {
|
||||
cy.title().should('include', title);
|
||||
});
|
|
@ -1,4 +1,4 @@
|
|||
/* MAP */
|
||||
import {hyphenizeString} from '../integration/common/helpers';
|
||||
|
||||
// For some interactions, we need access to the underlying map
|
||||
// Below adapted from https://github.com/codeforcologne/edelgard-map
|
||||
|
@ -26,3 +26,11 @@ Cypress.Commands.add('waitForMapIdle', (map) => {
|
|||
map.once('idle', resolve);
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('testExternalLinks', (string) => {
|
||||
return cy.get(`[data-cy="${hyphenizeString(string)}-block"] a`).each((link) => {
|
||||
cy.request(link.prop('href'))
|
||||
.its('status')
|
||||
.should('eq', 200);
|
||||
});
|
||||
});
|
||||
|
|
64
client/cypress/support/step_definitions/commonSteps.js
Normal file
64
client/cypress/support/step_definitions/commonSteps.js
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* eslint-disable new-cap */
|
||||
|
||||
// Common step definitions for Gherkin
|
||||
|
||||
import {ENDPOINTS} from '../../integration/LegacyTests/constants';
|
||||
import {hyphenizeString} from '../../integration/common/helpers';
|
||||
|
||||
// Common Givens:
|
||||
Given('I am on the {string} page', (page) => {
|
||||
const pageArray = page.split(' ');
|
||||
cy.viewport(1060, 800);
|
||||
cy.visit(ENDPOINTS[pageArray.join('_').toUpperCase()]);
|
||||
});
|
||||
|
||||
// Common Whens:
|
||||
When(`I click on the {string} page in the navigation`, (page) => {
|
||||
const pageHyphenCase = hyphenizeString(page);
|
||||
cy.get(`[data-cy="nav-link-${pageHyphenCase}"]`).click();
|
||||
});
|
||||
|
||||
When(`I look for the {string} CTA`, (ctaString) => {
|
||||
cy.get(`[data-cy="${hyphenizeString(ctaString)}-block"]`).as('CTA_block');
|
||||
cy.get('@CTA_block').scrollIntoView().should('be.visible');
|
||||
});
|
||||
|
||||
When(`I look for the {string}`, (footer) => {
|
||||
cy.get(`[data-cy="${hyphenizeString(footer)}-primary-block"]`).scrollIntoView().should('be.visible');
|
||||
});
|
||||
|
||||
// Common Thens:
|
||||
Then(`I see {string} in the title`, (title) => {
|
||||
cy.title().should('include', title);
|
||||
});
|
||||
|
||||
Then(`All links under {string} should work`, (title) => {
|
||||
cy.testExternalLinks(title);
|
||||
});
|
||||
|
||||
Then(`the link should allow client to send an email to {string}`, (email) => {
|
||||
cy.get(`@CTA_block`).find('a').invoke('attr', 'href').should('eq', `mailto:${email}`);
|
||||
});
|
||||
|
||||
Then(`the link should respond successfully`, () => {
|
||||
cy.get(`@externalLink`).then((link) => {
|
||||
cy.request(link.prop('href'))
|
||||
.its('status')
|
||||
.should('eq', 200);
|
||||
});
|
||||
});
|
||||
|
||||
// Common Ands:
|
||||
And(`I click on the {string} {string} link`, (ctaString, type) => {
|
||||
const CTALinkSelector = `[data-cy="${hyphenizeString(ctaString)}-block"] a`;
|
||||
|
||||
if (type === 'internal') {
|
||||
cy.get(CTALinkSelector).click();
|
||||
} else {
|
||||
cy.get(CTALinkSelector).as('externalLink');
|
||||
};
|
||||
});
|
||||
|
||||
And(`I click on the {string} footer link`, (string) => {
|
||||
cy.get(`[data-cy="${hyphenizeString(string)}"]`).as('externalLink');
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue