Skip to content

Commit

Permalink
Merge pull request #907 from cfpb/829-cypress-cleanup
Browse files Browse the repository at this point in the history
Pre-v1.2.15 cleanup
  • Loading branch information
BarakStout authored Apr 12, 2021
2 parents be3b6c2 + bdb58cb commit 0b186f0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
6 changes: 2 additions & 4 deletions cypress/integration/data-browser/2018.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const { HOST, ENVIRONMENT } = Cypress.env()
const dbUrl = dbURL.bind(null, HOST)

describe('Data Browser 2018', function () {
if(isCI(ENVIRONMENT)) it("Does not run on CI")
else if((!isBeta(HOST) || (isBeta(HOST) && !isProd(HOST)))){
if(!isProd(HOST)) it("Only runs in Production")
else {
it('State/Institution/PropertyType', function () {
cy.get({ HOST, ENVIRONMENT }).logEnv()
cy.viewport(1000, 940)
Expand Down Expand Up @@ -171,7 +171,5 @@ describe('Data Browser 2018', function () {
})
}
})
} else {
it(`does not run on host: ${HOST}`)
}
})
6 changes: 2 additions & 4 deletions cypress/integration/data-browser/2019.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const { HOST, ENVIRONMENT } = Cypress.env()
const dbUrl = dbURL.bind(null, HOST)

describe('Data Browser 2019', function () {
if(isCI(ENVIRONMENT)) it("Does not run on CI")
else if(!isBeta(HOST)){
if(!isProd(HOST)) it("Only runs in Production")
else {
it('State/Institution/PropertyType', function () {
cy.get({ HOST, ENVIRONMENT }).logEnv()
cy.viewport(1000, 940)
Expand Down Expand Up @@ -172,7 +172,5 @@ describe('Data Browser 2019', function () {
})
}
})
} else {
it(`does not run on host: ${HOST}`)
}
})
1 change: 1 addition & 0 deletions src/common/environmentChecks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isCI = () => process.env.REACT_APP_ENVIRONMENT === 'CI'
6 changes: 4 additions & 2 deletions src/common/useRemoteJSON.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ export function useRemoteJSON(sourceUrl, options = {}) {

fetch(sourceUrl)
.then((response) => {
if (hasHttpError(response)) return Promise.reject(response)
return response.json()
return hasHttpError(response).then(res => {
if(res) return Promise.reject(response)
return response.json()
})
})
.then((json) => {
if (options.transformReceive) setData(options.transformReceive(json))
Expand Down
3 changes: 2 additions & 1 deletion src/tools/rate-spread/CSVUpload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react'
import fileSaver from 'file-saver'
import LoadingIcon from '../../common/LoadingIcon.jsx'
import Alert from '../../common/Alert.jsx'
import { isCI } from '../../common/environmentChecks'
import Heading from '../../common/Heading.jsx'
import runFetch from './runFetch.js'

Expand Down Expand Up @@ -64,7 +65,7 @@ class CSVUpload extends Component {
event.target.value = null

this.onCSVFetch()
const CSV_URL = '/public/rateSpread/csv'
const CSV_URL = (isCI() ? '' : 'https://ffiec.cfpb.gov') + '/public/rateSpread/csv'
runFetch(CSV_URL, this.prepareCSVBody(file), true).then(res => {
this.onCSVCalculated(res, file)
})
Expand Down
3 changes: 2 additions & 1 deletion src/tools/rate-spread/Form.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react'
import LoadingIcon from '../../common/LoadingIcon.jsx'
import Alert from '../../common/Alert.jsx'
import { isCI } from '../../common/environmentChecks'
import Heading from '../../common/Heading.jsx'
import runFetch from './runFetch.js'

Expand Down Expand Up @@ -175,7 +176,7 @@ class Form extends Component {
if (errs.rateSetDate || errs.APR || errs.loanTerm) return

this.onFetch()
const API_URL = '/public/rateSpread'
const API_URL = (isCI() ? '' : 'https://ffiec.cfpb.gov') + '/public/rateSpread'
runFetch(API_URL, this.prepareBodyFromState()).then(res => {
this.onCalculated(res)
})
Expand Down

0 comments on commit 0b186f0

Please sign in to comment.