Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #136 from cfpb/560-add-cypress-tests
Browse files Browse the repository at this point in the history
Add Cypress tests
  • Loading branch information
meissadia committed Jul 24, 2020
2 parents 3ecc830 + 728f442 commit 7452a21
Show file tree
Hide file tree
Showing 85 changed files with 739 additions and 59 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
.env.development.local
.env.test.local
.env.production.local
cypress.env.json
cypress/videos
cypress/snapshots

npm-debug.log*
yarn-debug.log*
Expand Down
10 changes: 10 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"chromeWebSecurity": false,
"pluginsFile": false,
"env": {
"HH_INSTITUTION": "FRONTENDTESTBANK9999",
"HH_AUTH_REALM": "hmda2",
"HH_AUTH_CLIENT_ID": "hmda2-api",
"HH_HOST": "http://localhost:3000"
}
}
115 changes: 115 additions & 0 deletions cypress/integration/institution.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
const {
HH_HOST,
HH_USERNAME,
HH_PASSWORD,
HH_INSTITUTION,
HH_AUTH_URL,
HH_AUTH_REALM,
HH_AUTH_CLIENT_ID
} = Cypress.env()

describe('HMDA Help', () => {
beforeEach(() => {
cy.logout({ root: HH_AUTH_URL, realm: HH_AUTH_REALM })
cy.login({
root: HH_AUTH_URL,
realm: HH_AUTH_REALM,
client_id: HH_AUTH_CLIENT_ID,
redirect_uri: HH_HOST,
username: HH_USERNAME,
password: HH_PASSWORD
})
cy.viewport(1600, 900)
cy.visit(HH_HOST)
})

it('Can update existing Institutions', () => {
// Search for existing Instititution
cy.findByLabelText("LEI").type(HH_INSTITUTION)
cy.findByText('Search institutions').click()
cy.findAllByText('Update')
.first()
.click()

const successMessage = `The institution, ${HH_INSTITUTION}, has been updated.`
const nameLabelText = 'Respondent Name'
const updateButtonText = 'Update the institution'
const testName = 'Cypress Test Name Update'

cy.findByLabelText(nameLabelText).then($name => {
const savedName = $name.attr('value')
expect($name.attr('value')).to.not.contain(testName)

// Change Respondent Name
cy.findByLabelText(nameLabelText)
.type('{selectAll}' + testName)
.blur()
.then($name2 => {
cy.findByText(updateButtonText)
.should('be.enabled')
.click()
.then(() => {
// Validate
cy.findAllByText(successMessage)
.should('exist')
.then(() => {
expect($name2.attr('value')).to.contain(testName)
})
})
})

// Change it back
cy.findByLabelText(nameLabelText)
.type('{selectAll}' + savedName)
.blur()
.then(() => {
cy.findByText(updateButtonText)
.should('be.enabled')
.click()
.then(() => {
// Validate
cy.findAllByText(successMessage)
.should('exist')
.then(() => {
expect($name.attr('value')).to.contain(savedName)
})
})
})
})
})

it('Can delete and create Institutions', () => {
const institution = 'MEISSADIATESTBANK001'
const year = '2020'

// Delete
cy.findByLabelText("LEI").type(`${institution}{enter}`)
cy.get('table.institutions tbody tr').first().get('td').first().should('contain', year)
cy.findAllByText('Delete').first().click()
cy.findAllByText('Yes').first().click()
cy.get('table.institutions tbody tr').first().get('td').first().should('not.contain', year)

// Create
cy.visit(HH_HOST)
cy.findByLabelText("LEI").type("MEISSADIATESTBANK001{enter}")
cy.findByText(`Add ${institution} for ${year}`).click()

cy.findByLabelText('Activity Year').select(year).should('have.value', year)
cy.findByLabelText('Respondent Name').type('MD Bank 1')
cy.findByLabelText('Email Domains').type('bank1.com')
cy.findByLabelText('Tax Id').type('53-0000001')
cy.findByLabelText('9 - Consumer Financial Protection Bureau (CFPB)').click()

cy.findByText('Show other fields').click()
cy.findByLabelText('RSSD').type('-1')
cy.findByLabelText('Parent ID RSSD').type('-1')
cy.findByLabelText('Assets').type('-1')
cy.findByLabelText('Top Holder ID RSSD').type('-1')

cy.findByText('Add the institution')
.should('be.enabled')
.click()

cy.findAllByText(`The institution, ${institution}, has been added!`).should('exist')
})
})
7 changes: 7 additions & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// ***********************************************************
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

import '@testing-library/cypress/add-commands'
import 'cypress-keycloak';
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added npm-packages-offline-cache/@jest-types-25.5.0.tgz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed npm-packages-offline-cache/@types-node-14.0.24.tgz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added npm-packages-offline-cache/arch-2.1.2.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/aria-query-4.2.2.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/async-3.2.0.tgz
Binary file not shown.
Binary file not shown.
Binary file added npm-packages-offline-cache/cachedir-2.3.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/chalk-3.0.0.tgz
Binary file not shown.
Binary file not shown.
Binary file added npm-packages-offline-cache/cli-cursor-1.0.2.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/cli-cursor-2.1.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/cli-table3-0.5.1.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/cli-truncate-0.2.1.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/colors-1.4.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/cypress-4.11.0.tgz
Binary file not shown.
Binary file not shown.
Binary file added npm-packages-offline-cache/date-fns-1.30.1.tgz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added npm-packages-offline-cache/executable-4.1.1.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/exit-hook-1.1.1.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/extract-zip-1.7.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/fd-slicer-1.1.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/figures-1.7.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/figures-2.0.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/getos-3.2.1.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/global-dirs-2.0.1.tgz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added npm-packages-offline-cache/is-promise-2.2.2.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/lazy-ass-1.6.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/listr-0.14.3.tgz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added npm-packages-offline-cache/lodash.once-4.1.1.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/log-symbols-1.0.2.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/log-symbols-3.0.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/log-update-2.3.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/mimic-fn-1.2.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/moment-2.26.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/onetime-1.1.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/onetime-2.0.1.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/ospath-1.2.2.tgz
Binary file not shown.
Binary file removed npm-packages-offline-cache/parse-json-5.0.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/parse-json-5.0.1.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/pend-1.2.0.tgz
Binary file not shown.
Binary file not shown.
Binary file added npm-packages-offline-cache/ramda-0.26.1.tgz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added npm-packages-offline-cache/slice-ansi-0.0.4.tgz
Binary file not shown.
Binary file not shown.
Binary file added npm-packages-offline-cache/throttleit-1.0.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/tmp-0.1.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/untildify-4.0.0.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/wrap-ansi-3.0.1.tgz
Binary file not shown.
Binary file added npm-packages-offline-cache/yauzl-2.10.0.tgz
Binary file not shown.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
"react-router-dom": "4.3.1",
"react-scripts": "3.4.1"
},
"devDependencies": {
"@testing-library/cypress": "6.0.0",
"cypress": "4.11.0",
"cypress-keycloak": "1.5.0"
},
"browserslist": [
"Chrome >= 60",
"Safari >= 10.1",
Expand Down
2 changes: 1 addition & 1 deletion src/InputRadio.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class InputRadio extends Component {
render() {
return (
<React.Fragment>
<label>{this.props.label}</label>
<label htmlFor={this.props.id}>{this.props.label}</label>
<ul className="unstyled-list">
{this.props.options.map((option, i) => {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/InputSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class InputSelect extends Component {
render() {
return (
<React.Fragment>
<label>{this.props.label}</label>
<label htmlFor={this.props.id}>{this.props.label}</label>
<select
ref={this.props.innerRef}
name={this.props.name}
id={this.props.inputId}
id={this.props.id}
onChange={this.handleChange}
disabled={this.props.disabled}
value={this.state.value}
Expand Down
2 changes: 1 addition & 1 deletion src/InputText.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class InputText extends Component {
render() {
return (
<React.Fragment>
<label>{this.props.label}</label>
<label htmlFor={this.props.id}>{this.props.label}</label>
{this.state.error ? (
<span className="input-error-message">{this.state.error}</span>
) : null}
Expand Down
Loading

0 comments on commit 7452a21

Please sign in to comment.