-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VOTE-555 update cypress tests for new enhancements (#469)
- Loading branch information
Showing
3 changed files
with
60 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 56 additions & 19 deletions
75
testing/cypress/e2e/frontEndTests/state-registration.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,60 @@ | ||
/// <reference types="Cypress" /> | ||
|
||
describe('Validate state selection options', () => { | ||
it('verify state selection is correct', () => { | ||
beforeEach('visit page', () => { | ||
cy.visit('/') | ||
cy.get('[data-test="state-selection"]').find('option:not([value="default"])').each(option => { | ||
// * trimming white space | ||
const opn = option.text().trim() | ||
cy.get(option).invoke('attr', 'value').then(value => { | ||
// * getting the value that is in the option and saving it for later to be compared with the url | ||
cy.wrap(value) | ||
cy.get('[data-test="state-selection"]').select(opn) | ||
cy.get('[data-test="register-button"]').click() | ||
// * comparing the URL to the sorted value and then checking that the url is giving a status of 200 | ||
cy.url().should('contain', value).then(url => { | ||
cy.request(url).then((response) => { | ||
expect(response.status).to.eq(200)}) | ||
}) | ||
cy.get('[data-test="back-button"]').click() | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
it('Verify that menu drop down is working', () => { | ||
cy.get('[data-test="dropdown-btn"]').click() | ||
cy.get('[data-test="state-list"]').should('be.visible') | ||
}) | ||
|
||
it('Verify that type search is working', () => { | ||
// * Check that 'South' renders expected states | ||
cy.get('[data-test="state-selection"]').type('South') | ||
cy.get('[data-test="state-list"]').should('contain', 'South Carolina', 'South Dakota') | ||
cy.reload() | ||
// * Check that 'Virgin' renders expected states | ||
cy.get('[data-test="state-selection"]').type('Virgin') | ||
cy.get('[data-test="state-list"]').should('contain', 'U.S. Virgin Island', 'Virginia', 'West Virginia') | ||
cy.reload() | ||
// * Check that 'Carolina' renders expected states | ||
cy.get('[data-test="state-selection"]').type('Carolina') | ||
cy.get('[data-test="state-list"]').should('contain', 'South Carolina', 'North Carolina') | ||
cy.reload() | ||
// * Check that 'mar' renders expected states | ||
cy.get('[data-test="state-selection"]').type('mar') | ||
cy.get('[data-test="state-list"]').should('contain', 'Maryland', 'Northern Mariana Islands') | ||
}) | ||
|
||
it('Verify that user can navigate to state page from dropdown', () => { | ||
// * Check Alaska | ||
cy.get('[data-test="dropdown-btn"]').click() | ||
cy.get('[data-test=state-list]').find('li').then(option => { | ||
cy.get(option[1]).realClick() | ||
}) | ||
cy.url().should('include', '/register/ak') | ||
cy.get('[data-test="vote-logo"]').click() | ||
// * Check American Samoa | ||
cy.get('[data-test="dropdown-btn"]').click() | ||
cy.get('[data-test=state-list]').find('li').then(option => { | ||
cy.get(option[2]).realClick() | ||
}) | ||
cy.url().should('include', '/register/as') | ||
cy.get('[data-test="vote-logo"]').click() | ||
// * Check Arkansas | ||
cy.get('[data-test="dropdown-btn"]').click() | ||
cy.get('[data-test=state-list]').find('li').then(option => { | ||
cy.get(option[4]).realClick() | ||
}) | ||
cy.url().should('include', '/register/ar') | ||
cy.get('[data-test="vote-logo"]').click() | ||
// * Check North Dakota | ||
cy.get('[data-test="dropdown-btn"]').click() | ||
cy.get('[data-test=state-list]').find('li').then(option => { | ||
cy.get(option[36]).realClick() | ||
}) | ||
cy.url().should('include', '/register/nd') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters