-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into FDG-9101-Cypress-Debt-Explainer
- Loading branch information
Showing
28 changed files
with
478 additions
and
116 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
describe('About Us Links interaction flow', () => { | ||
beforeEach(() => { | ||
cy.visit('/about-us/'); | ||
}); | ||
|
||
it('Navigates to the About Us page', () => { | ||
cy.findAllByText('About Fiscal Data').should('exist'); | ||
}); | ||
|
||
it('Validates all links on the page function as intended', () => { | ||
const links: object[] = [ | ||
{ | ||
name: 'Bureau of the Fiscal Service (Fiscal Service)', | ||
url: 'https://fiscal.treasury.gov/about.html', | ||
external: true, | ||
}, | ||
{ | ||
name: 'getting started section', | ||
url: 'api-documentation/#getting-started', | ||
external: false, | ||
}, | ||
{ | ||
name: 'International Monetary Fund (IMF)', | ||
url: 'https://www.imf.org/en/home', | ||
external: true, | ||
}, | ||
{ | ||
name: 'Special Data Dissemination Standard (SDDS)', | ||
url: | ||
'https://www.imf.org/en/About/Factsheets/Sheets/2023/Standards-for-data-dissemination#:~:text=The%20Special%20Data%20Dissemination%20System,access%20to%20international%20capital%20markets.', | ||
external: true, | ||
}, | ||
{ | ||
name: 'Monthly Statement of the Public Debt (MSPD)', | ||
url: 'datasets/monthly-statement-public-debt/summary-of-treasury-securities-outstanding', | ||
external: false, | ||
}, | ||
{ | ||
name: 'Monthly Treasury Statement (MTS)', | ||
url: 'datasets/monthly-treasury-statement/summary-of-receipts-outlays-and-the-deficit-surplus-of-the-u-s-government', | ||
external: false, | ||
}, | ||
{ | ||
name: 'IMF SDDS website', | ||
url: | ||
'https://www.imf.org/en/About/Factsheets/Sheets/2023/Standards-for-data-dissemination#:~:text=The%20Special%20Data%20Dissemination%20System,access%20to%20international%20capital%20markets.', | ||
external: true, | ||
}, | ||
{ | ||
name: 'API Documentation', | ||
url: 'api-documentation/', | ||
external: false, | ||
}, | ||
]; | ||
|
||
links.forEach(link => { | ||
if (link.external) { | ||
cy.findByRole('link', { name: link.name }).should('have.attr', 'href', link.url); | ||
} else { | ||
cy.findByRole('link', { name: link.name }).click(); | ||
cy.url().should('include', link.url); | ||
cy.visit('/about-us/'); | ||
} | ||
}); | ||
}); | ||
|
||
it('Validates duplicate links', () => { | ||
const duplicateLinks: object[] = [ | ||
{ | ||
name: 'visit their Contact Us page', | ||
url: 'https://fiscal.treasury.gov/top/contact.html', | ||
external: true, | ||
}, | ||
{ | ||
name: 'Economic Impact Payments Page', | ||
url: 'http://www.irs.gov/coronavirus-tax-relief-and-economic-impact-payments', | ||
external: true, | ||
}, | ||
{ | ||
name: "Where's My Refund?", | ||
url: 'https://www.irs.gov/refunds', | ||
external: true, | ||
}, | ||
{ | ||
name: 'contact the Bureau of the Fiscal Service', | ||
url: 'https://fiscal.treasury.gov/contact/', | ||
external: true, | ||
}, | ||
{ | ||
name: 'visit their Contact Us page', | ||
url: 'https://fiscal.treasury.gov/top/contact.html', | ||
external: true, | ||
}, | ||
{ | ||
name: 'Economic Impact Payments Page', | ||
url: 'http://www.irs.gov/coronavirus-tax-relief-and-economic-impact-payments', | ||
external: true, | ||
}, | ||
]; | ||
|
||
duplicateLinks.forEach(link => { | ||
const dupes = cy.findAllByRole('link', { name: link.name }); | ||
|
||
dupes.each(dupe => { | ||
cy.wrap(dupe).should('have.attr', 'href', link.url); | ||
}); | ||
}); | ||
}); | ||
|
||
it('Validates download links', () => { | ||
const downloadLinks: object[] = [ | ||
{ | ||
name: 'Open Data Policy', | ||
url: '/data/about-us/901-1 Open Data Policy.pdf', | ||
}, | ||
{ | ||
name: 'https://fiscaldata.treasury.gov/static-data/reports-statements/mts/imf/cgd.xml', | ||
url: 'https://fiscaldata.treasury.gov/static-data/reports-statements/mts/imf/cgd.xml', | ||
}, | ||
{ | ||
name: 'https://fiscaldata.treasury.gov/static-data/reports-statements/mts/imf/cgo.xml', | ||
url: 'https://fiscaldata.treasury.gov/static-data/reports-statements/mts/imf/cgo.xml', | ||
}, | ||
]; | ||
|
||
downloadLinks.forEach(link => { | ||
cy.findByRole('link', { name: link.name }).should('have.attr', 'href', link.url); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
describe('About us interaction flow', () => { | ||
beforeEach(() => { | ||
cy.visit('/about-us/').wait(1500); | ||
}); | ||
|
||
it('Verifies about us page loads', () => { | ||
cy.findAllByText('About Fiscal Data').should('exist'); | ||
}); | ||
it('Verifies about us sub nav interaction flow FAQ', () => { | ||
cy.findByTitle('Why do some datasets...') | ||
.should('exist') | ||
.click(); | ||
cy.url().should('include', '/#why-datasets-go-further-than-others'); | ||
}); | ||
it('Verifies keyboard interaction about us sub nav interaction flow FAQ', () => { | ||
cy.findByTitle('I’m new to using APIs...') | ||
.should('exist') | ||
.focus() | ||
.type('{enter}'); | ||
cy.url().should('include', '/#new-to-apis'); | ||
}); | ||
it('Verifies about us sub nav interaction flow About Fiscal Data', () => { | ||
cy.findByTitle('Background') | ||
.should('exist') | ||
.click(); | ||
cy.url().should('include', '/#background'); | ||
}); | ||
it('Verifies keyboard interaction about us sub nav interaction flow About Fiscal Data', () => { | ||
cy.findByTitle('Mission') | ||
.should('exist') | ||
.focus() | ||
.type('{enter}'); | ||
cy.url().should('include', '/#mission'); | ||
}); | ||
it('Verifies about us sub nav interaction flow Contact Us', () => { | ||
cy.findByTitle('Contact Us') | ||
.should('exist') | ||
.click(); | ||
cy.url().should('include', '/#contact-us'); | ||
}); | ||
it('Verifies keyboard interaction about us sub nav interaction flow About Contact Us', () => { | ||
cy.findByTitle('Contact Us') | ||
.should('exist') | ||
.focus() | ||
.type('{enter}'); | ||
cy.url().should('include', '/#contact-us'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
describe('DDP related dataset go to the correct datasets', () => { | ||
beforeEach(() => { | ||
cy.visit('/datasets/monthly-treasury-statement/summary-of-receipts-outlays-and-the-deficit-surplus-of-the-u-s-government').wait(3000); | ||
}); | ||
it('Validates the DDP page loads', () => { | ||
cy.findByTitle('Monthly Treasury Statement (MTS)').should('be.visible'); | ||
cy.findAllByText('Debt to the Penny') | ||
.eq(1) | ||
.click(); | ||
cy.url().should('include', '/debt-to-the-penny'); | ||
cy.findAllByText('Daily Treasury Statement (DTS)') | ||
.eq(1) | ||
.click(); | ||
cy.url().should('include', '/daily-treasury-statement/operating-cash-balance'); | ||
cy.findAllByText('Monthly Treasury Statement (MTS)') | ||
.eq(1) | ||
.click(); | ||
cy.url().should('include', '/summary-of-receipts-outlays-and-the-deficit-surplus-of-the-u-s-government'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
describe('Glossary terms interaction flow', () => { | ||
beforeEach(() => { | ||
cy.visit('/').wait(3000); | ||
cy.findAllByText('Resources').click(); | ||
cy.findAllByText('Glossary') | ||
.click() | ||
.wait(3000); | ||
}); | ||
it('Verifies Glossary opens and closes correctly', () => { | ||
cy.findByText('Search the glossary').should('exist'); | ||
cy.findByLabelText('Close glossary').click(); | ||
cy.findByText('Search the glossary').should('not.exist'); | ||
}); | ||
|
||
it('Search bar search and Back to list interaction', () => { | ||
cy.findAllByLabelText('Search the glossary').should('be.visible'); | ||
cy.findAllByLabelText('Search the glossary') | ||
.eq(1) | ||
.type('Revenue'); | ||
cy.findAllByText('Back to list') | ||
.should('exist') | ||
.click(); | ||
cy.findAllByLabelText('Search the glossary') | ||
.eq(1) | ||
.type('Debt Ceiling') | ||
.click(); | ||
cy.findAllByText('Back to list') | ||
.should('exist') | ||
.click(); | ||
}); | ||
it('Search bar click into a selected search', () => { | ||
cy.findAllByLabelText('Search the glossary') | ||
.eq(1) | ||
.type('Debt Ceiling'); | ||
cy.findAllByText('Debt Ceiling') | ||
.should('exist') | ||
.click(); | ||
cy.findAllByText( | ||
'This is the maximum amount of money the federal government is allowed to borrow without receiving additional authority from Congress.' | ||
).should('exist'); | ||
}); | ||
it('Search bar interaction with Floating Rate Notes and external link', () => { | ||
cy.findAllByLabelText('Search the glossary') | ||
.eq(1) // Target the correct search bar | ||
.should('be.visible') | ||
.type('Floating Rate Notes'); | ||
cy.findAllByText('Floating Rate Notes') | ||
.should('exist') | ||
.click(); | ||
cy.findAllByText('TreasuryDirect') | ||
.should('exist') | ||
.invoke('attr', 'href') | ||
.should('include', '/marketable-securities/floating-rate-notes/'); | ||
|
||
cy.findAllByText('TreasuryDirect') | ||
.invoke('removeAttr', 'target') | ||
.click(); | ||
}); | ||
}); |
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
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,17 +1,29 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { render, fireEvent } from '@testing-library/react'; | ||
import AnchorText from './anchor-text'; | ||
|
||
const mockFootnote = { | ||
text: 'Test Footnote Text', | ||
link: 'testFootnote', | ||
body: | ||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque vulputate odio a enim hendrerit interdum. Duis volutpat, nibh porttitor pellentesque mattis, mi justo', | ||
}; | ||
jest.mock('../links/custom-link/custom-link', () => { | ||
return ({ onClick, children, 'data-testid': dataTestId }) => { | ||
return ( | ||
<button onClick={onClick} data-testid={dataTestId}> | ||
{children} | ||
</button> | ||
); | ||
}; | ||
}); | ||
|
||
describe('Anchor Text', () => { | ||
it('it renders the Anchor Text component', () => { | ||
const { getByTestId } = render(<AnchorText link={mockFootnote.link} text={mockFootnote.text} />); | ||
describe('AnchorText', () => { | ||
it('renders the Anchor Text component', () => { | ||
const { getByTestId } = render(<AnchorText link="testFootnote" text="Test Footnote Text" />); | ||
expect(getByTestId('anchor-text')).toBeInTheDocument(); | ||
}); | ||
|
||
it('calls onAnchorClick with the link when clicked', () => { | ||
const mockClickHandler = jest.fn(); | ||
const { getByTestId } = render(<AnchorText link="testFootnote" text="Test Footnote Text" onAnchorClick={mockClickHandler} />); | ||
fireEvent.click(getByTestId('anchor-text')); | ||
|
||
expect(mockClickHandler).toHaveBeenCalledWith('testFootnote'); | ||
expect(mockClickHandler).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
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
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
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
Oops, something went wrong.