Skip to content

Commit

Permalink
Vote-3148: Cypress Test Updates (#1164)
Browse files Browse the repository at this point in the history
* Vote-3148: add tests for more coverage

* Add step in pipeline
  • Loading branch information
clmedders authored Dec 16, 2024
1 parent ae6c875 commit 9686864
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 1 deletion.
26 changes: 26 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,22 @@ jobs:
npm install
npm run cy:pipeline:proofer
when: on_fail
home-page-redirect:
docker:
- image: cypress/included:cypress-13.14.2-node-20.17.0-chrome-128.0.6613.119-1-ff-130.0-edge-128.0.2739.63-1
environment:
cypress_pipeline: 1
cypress_cloudgov_application_name: "${project}-drupal-${CIRCLE_BRANCH}"
steps:
- checkout
- attach_workspace:
at: ~/
- run:
name: "Home Page Redirect"
command: |
cd testing
npm install
npm run cy:pipeline:hpRedirect
workflows:
deploy-workflow:
when:
Expand Down Expand Up @@ -396,6 +412,16 @@ workflows:
- prod
jobs:
- link-validation
home-page-redirect-workflow:
triggers:
- schedule:
cron: '0 9 * * 1-5'
filters:
branches:
only:
- prod
jobs:
- home-page-redirect
scheduled-backup-workflow:
when:
and:
Expand Down
14 changes: 14 additions & 0 deletions testing/cypress/e2e/frontEndTests/touchpoints-module.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// <reference types="cypress" />

import { pageObjects } from "../../support/pageObjects"

describe('Check Touchpoints Module', () => {
it('Verify that module is opening', () => {
cy.visit('/')

pageObjects
.touchpointsBtn().click()

cy.get('[class="fba-usa-modal fba-modal"]').should('be.visible')
})
})
39 changes: 39 additions & 0 deletions testing/cypress/e2e/redirect/homepage-redirect.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/// <reference types="cypress" />

const baseurl = 'https://vote.gov';
const languages = [
"es",
"am",
"ar",
"bn",
"zh-hans",
"zh",
"fr",
"ht",
"hi",
"km",
"ko",
"pt",
"ru",
"so",
"tl",
"vi",
"ypk"
];

describe('Homepage Redirect Check', () => {
languages.forEach(language => {
it(`Verify ${language} homepage does not redirect`, () => {
cy.visit(`${baseurl}/${language}`).then(() => {
cy.get('body').then($body => {
if ($body.text().includes('Redirecting to')) {
cy.log(`Error: Redirecting to detected for ${language}`);
expect(false, `Redirecting to detected for ${language}`).to.be.true;
} else {
cy.log(`Success: No redirect detected for ${language}`);
}
});
})
});
});
});
20 changes: 20 additions & 0 deletions testing/cypress/fixtures/language-urls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
"en",
"es",
"am",
"ar",
"bn",
"zh-hans",
"zh",
"fr",
"ht",
"hi",
"km",
"ko",
"pt",
"ru",
"so",
"tl",
"vi",
"ypk"
]
4 changes: 4 additions & 0 deletions testing/cypress/support/pageObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ class PageObjects {
return cy.get('[data-test="stateList"]')
}

touchpointsBtn() {
return cy.get('[data-test="touchpointsBtn"]')
}

// Backend Tests
pageTitle() {
return cy.get('[data-drupal-selector="edit-title-0-value"]')
Expand Down
3 changes: 2 additions & 1 deletion testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"cy:pipeline:frontEnd": "cypress run --spec 'cypress/e2e/frontEndTests/**/*' --config-file pipeline.config.js",
"cy:pipeline:axe": "cypress run --spec 'cypress/e2e/accessibility/**/*' --config-file pipeline.config.js",
"cy:pipeline:links": "cypress run --spec 'cypress/e2e/internalLinks/**/*' --config-file pipeline.config.js",
"cy:pipeline:proofer": "cypress run --spec 'cypress/e2e/externalLinks/**/*' --config-file pipeline.config.js"
"cy:pipeline:proofer": "cypress run --spec 'cypress/e2e/externalLinks/**/*' --config-file pipeline.config.js",
"cy:pipeline:hpRedirect": "cypress run --spec 'cypress/e2e/redirect/**/*' --config-file pipeline.config.js"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 9686864

Please sign in to comment.