Skip to content

Commit

Permalink
Merge pull request #1546 from GSA/dev
Browse files Browse the repository at this point in the history
Release v0.5.0.beta.1 (sprint 35)
  • Loading branch information
scottqueen-bixal authored Jul 10, 2024
2 parents b67a0b6 + 4025201 commit a88f4a5
Show file tree
Hide file tree
Showing 40 changed files with 416 additions and 1,331 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
- dev
- main

permissions:
contents: read
packages: write

jobs:
php-lint:
name: PHP Lint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-cypress-prod-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
with:
browser: chrome
env: NODE_ENV=test
config-file: cypress.prod.config.js
config-file: cypress.prod.links.config.js
working-directory: benefit-finder

- name: create github issue
Expand Down
29 changes: 0 additions & 29 deletions .github/workflows/thog_scan.yml

This file was deleted.

83 changes: 83 additions & 0 deletions .github/workflows/thog_scan_commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: TruffleHog Scan

on:
push:
branches:
- main
- develop
pull_request:

jobs:
scan:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install GitHub CLI
run: |
sudo apt-get update
sudo apt-get install -y gh
- name: Authenticate GitHub CLI
env:
GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }}
run: |
gh auth setup-git
- name: Run TruffleHog scan
id: trufflehog_scan
uses: trufflesecurity/[email protected]
with:
base: ""
head: ${{ github.ref_name }}
extra_args: --only-verified --json --entropy --max-depth=50
continue-on-error: true

- name: Check TruffleHog Results
id: check_results
run: |
if [ -f truffleHogResults.json ]; then
echo "file_exists=true" >> $GITHUB_ENV
else
echo "file_exists=false" >> $GITHUB_ENV
fi
- name: Upload TruffleHog scan results
if: always() && env.file_exists == 'true'
uses: actions/upload-artifact@v3
with:
name: trufflehog-results
path: truffleHogResults.json

- name: Convert JSON to Readable Report
if: always() && env.file_exists == 'true'
run: |
jq -r '.results[] | "File: \(.path)\nCommit: \(.commit)\nDate: \(.date)\nReason: \(.reason)\n---------------------------"' truffleHogResults.json > truffleHogReport.txt
- name: Upload Readable Report
if: always() && env.file_exists == 'true'
uses: actions/upload-artifact@v3
with:
name: trufflehog-readable-report
path: truffleHogReport.txt

- name: Check for findings and create issue
if: failure() && env.file_exists == 'true'
env:
GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }}
run: |
if jq -e '.results | length > 0' truffleHogResults.json > /dev/null; then
echo "Secrets found. Creating GitHub issue."
gh issue create --title "TruffleHog Scan Results" --body "$(cat truffleHogReport.txt)" --label "bug,security" --assignee "@me"
exit 1
else
echo "No secrets found or no results file."
fi
- name: Fail the job if any secrets are found
if: steps.trufflehog_scan.outcome == 'failure'
run: exit 1
Empty file.
12 changes: 0 additions & 12 deletions benefit-finder/cypress.prod.config.js

This file was deleted.

64 changes: 47 additions & 17 deletions benefit-finder/cypress/e2e/storybook/dataLayer.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { pageObjects } from '../../support/pageObjects'
import * as EN_LOCALE_DATA from '../../../../benefit-finder/src/shared/locales/en/en.json'
import * as BENEFITS_ELIBILITY_DATA from '../../fixtures/benefits-eligibility.json'

const { intro, lifeEventSection, resultsView, benefitCount } =
const { intro, lifeEventSection, resultsView, openAllBenefitAccordions } =
dataLayerUtils.dataLayerStructure

const dataLayerValues = [
Expand All @@ -26,17 +26,17 @@ const dataLayerValues = [
{
event: resultsView.event,
bfData: {
pageView: resultsView.bfData.pageView,
pageView: resultsView.bfData.pageView[0],
viewTitle: 'Your potential benefits',
viewState: resultsView.bfData.viewState[1],
eligibleBenefitCount: { number: 4, string: '4' },
moreInfoBenefitCount: { number: 1, string: '1' },
notEligibleBenefitCount: { number: 25, string: '25' },
},
},
{
event: benefitCount.event,
event: openAllBenefitAccordions.event,
bfData: {
eligible: 4,
moreInfo: 1,
notEligible: 25,
accordionsOpen: openAllBenefitAccordions.bfData.accordionsOpen,
},
},
]
Expand Down Expand Up @@ -120,19 +120,49 @@ describe('Calls to Google Analytics Object', function () {
}
delete ev[0]['gtm.uniqueEventId']

expect(dataLayerValues[2]).to.deep.equal(ev[0])
expect(ev[0]).to.deep.equal(dataLayerValues[2])
})
})
})
})

// // check count event
const evCount = {
...window.dataLayer.filter(
x => x.event === dataLayerValues[3].event
),
}
it('clicking open all on results page has a bf_open_all_accordions event', function () {
const selectedData = BENEFITS_ELIBILITY_DATA.scenario_1_covid.en.param
const scenario = utils.encodeURIFromObject(selectedData)
cy.visit(`${utils.storybookUri}${scenario}`)

delete evCount[0]['gtm.uniqueEventId']
cy.window().then(window => {
assert.isDefined(window.dataLayer, 'window.dataLayer is defined')

expect(dataLayerValues[3]).to.deep.equal(evCount[0])
})
pageObjects
.expandAll()
.click()
.then(() => {
// check last page change event
const ev = {
...window.dataLayer.filter(
x => x?.event === dataLayerValues[3].event
),
}
delete ev[0]['gtm.uniqueEventId']

expect(dataLayerValues[3]).to.deep.equal(ev[0])
})

pageObjects
.expandAll()
.click()
.then(() => {
// check last page change event
const ev = {
...window.dataLayer.filter(
x => x?.event === dataLayerValues[3].event
),
}
// we ignore dedup here so there can be multiple fires
delete ev[1]['gtm.uniqueEventId']

expect(dataLayerValues[4]).to.not.deep.equal(ev[1])
})
})
})
Expand Down
136 changes: 90 additions & 46 deletions benefit-finder/cypress/e2e/usagov-public-site/links.cy.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,108 @@
import * as utils from '../../support/utils'
import * as BENEFITS_ELIBILITY_DATA from '../../fixtures/benefits-eligibility.json'

describe('Verify correct status code when user navigates links', () => {
// to be removed when uncaught exceptions are addressed
Cypress.on('uncaught:exception', (_err, runnable) => {
return false
})
it('Verify success status code response for links in Death of a loved one English page', () => {
const selectedData =
BENEFITS_ELIBILITY_DATA['death-of-a-loved-one'].en.param
const scenario = utils.encodeURIFromObject(selectedData)
cy.visit(`benefit-finder/death?${scenario}`)
cy.get('main a[href]').each(link => {
cy.request(link.prop('href'))
const localePaths = {
en: [
{ key: 'death-of-a-loved-one', path: 'death' },
{ key: 'retirement', path: 'retirement' },
{ key: 'disability', path: 'disability' },
],
es: [
{ key: 'death-of-a-loved-one', path: 'muerte' },
{ key: 'retirement', path: 'jubilacion' },
{ key: 'disability', path: 'discapacidad' },
],
}

const handlerequest = ({ testLink, link }) => {
const url = testLink || link.prop('href')
return cy
.request({
url,
failOnStatusCode: false,
})
.then(response => {
if (response.status === 200) {
expect(response.status).to.eq(200)
} else if (response.status === 403) {
cy.get('body').children().its('length').should('be.gt', 0)
} else if (response.status === 503) {
throw new Error(`site down - gave a 503 ${url}`)
} else if (response.status === 404) {
throw new Error(`page not found - gave a 404 ${url}`)
} else {
cy.get('body').children().its('length').should('be.gt', 0)
}
})
}

const validateErrorCodes = test => {
// we verify site is alive and fail on 404 || 503
cy.get('#benefit-finder a[href]').each(link => {
handlerequest({ link })
})
}

it('Verify success status code response for links in Death of a Loved One Spanish page', () => {
const selectedData =
BENEFITS_ELIBILITY_DATA['death-of-a-loved-one'].es.param
const scenario = utils.encodeURIFromObject(selectedData)
cy.visit(`es/buscador-beneficios/muerte?${scenario}`)
cy.get('main a[href]').each(link => {
cy.request(link.prop('href'))
})
const validateLinks = ({ selectedData, path }) => {
const scenario = utils.encodeURIFromObject(selectedData)
cy.visit(`${path}?${scenario}`)
validateErrorCodes()
}

// to be removed when uncaught exceptions are addressed
// eslint-disable-next-line n/handle-callback-err
Cypress.on('uncaught:exception', (error, runnable) => {
return false
})

describe('Verify correct status code handling', () => {
// negate validation on our functional code
Cypress.on('fail', (error, runnable) => {
if (JSON.stringify(error).includes('httpstat')) {
// eslint-disable-next-line no-unused-expressions
expect(error).to.not.be.undefined
} else {
throw error
}
})

it('Verify success status code response for links in Retirement English page', () => {
const selectedData = BENEFITS_ELIBILITY_DATA.retirement.en.param
const scenario = utils.encodeURIFromObject(selectedData)
cy.visit(`benefit-finder/retirement?${scenario}`)
cy.get('main a[href]').each(link => {
cy.request(link.prop('href'))
})
it(`handles 404 with an error`, () => {
handlerequest({ testLink: 'https://httpstat.us/404' })
})

it('Verify success status code response for links in Retirement Spanish page', () => {
const selectedData = BENEFITS_ELIBILITY_DATA.retirement.es.param
const scenario = utils.encodeURIFromObject(selectedData)
cy.visit(`es/buscador-beneficios/jubilacion?${scenario}`)
cy.get('main a[href]').each(link => {
cy.request(link.prop('href'))
})
it(`handles 503 with an error`, () => {
handlerequest({ testLink: 'https://httpstat.us/503' })
})

it(`handles 200 successfully`, () => {
handlerequest({ testLink: 'https://httpstat.us/200' })
})

it(`handles any 403 successfully`, () => {
handlerequest({ testLink: 'https://httpstat.us/403' })
})

it(`handles any other request successfully`, () => {
handlerequest({ testLink: 'https://httpstat.us/201' })
})
})

it('Verify success status code response for links in Disability English page', () => {
const selectedData = BENEFITS_ELIBILITY_DATA.disability.en.param
const scenario = utils.encodeURIFromObject(selectedData)
cy.visit(`benefit-finder/disability?${scenario}`)
cy.get('main a[href]').each(link => {
cy.request(link.prop('href'))
describe('Verify correct status code when user navigates links in each locales', () => {
localePaths.en.forEach(location => {
it(`Verify success status code response for links in ${location.key} en page`, () => {
validateLinks({
selectedData: BENEFITS_ELIBILITY_DATA[`${location.key}`].en.param,
path: `benefit-finder/${location.path}`,
})
})
})

it('Verify success status code response for links in Disability English page', () => {
const selectedData = BENEFITS_ELIBILITY_DATA.disability.es.param
const scenario = utils.encodeURIFromObject(selectedData)
cy.visit(`es/buscador-beneficios/discapacidad?${scenario}`)
cy.get('main a[href]').each(link => {
cy.request(link.prop('href'))
localePaths.es.forEach(location => {
it(`Verify success status code response for links in ${location.key} es page`, () => {
validateLinks({
selectedData: BENEFITS_ELIBILITY_DATA[`${location.key}`].en.param,
path: `es/buscador-beneficios/${location.path}`,
})
})
})
})
Loading

0 comments on commit a88f4a5

Please sign in to comment.