Skip to content

Commit

Permalink
Merge branch 'master' into FDG-10028
Browse files Browse the repository at this point in the history
  • Loading branch information
chasls2 committed Jan 14, 2025
2 parents ad10680 + d474657 commit e884e0b
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 12 deletions.
225 changes: 225 additions & 0 deletions cypress/e2e/explainers/debt.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
describe('Debt Explainer Page', () => {
beforeEach(() => {
cy.visit('/americas-finance-guide/national-debt/');
cy.wait(3000);
});

it('Navigate to the debt explainer, ensure page does not contain NaN, null, or undefined values', () => {
cy.findAllByText('null').should('not.exist');
cy.findAllByText('NaN').should('not.exist');
cy.findAllByText('undefined').should('not.exist');
});

describe('Validate that the sub nav takes the user to the correct section on the page', () => {
it('Validate that the sub nav takes the user Overview section', () => {
cy.findByRole('link', { name: 'Overview' })
.type('{enter}')
.wait(2000);
cy.url().should('include', 'americas-finance-guide/');
});

it('Validate that the sub nav takes the user Revenue section', () => {
cy.findByRole('link', { name: 'Revenue' })
.type('{enter}')
.wait(2000);
cy.url().should('include', 'americas-finance-guide/government-revenue');
});

it('Validate that the sub nav takes the user Spending section', () => {
cy.findByRole('link', { name: 'Spending' })
.type('{enter}')
.wait(2000);
cy.url().should('include', 'americas-finance-guide/federal-spending');
});

it('Validate that the sub nav takes the user Deficit section', () => {
cy.get('span')
.contains("Deficit")
.type('{enter}')
.wait(2000);
cy.url().should('include', 'americas-finance-guide/national-deficit');
});
});

describe('Validate all links on page', () => {
it('Part 1: Validate all internal links on the page navigate to the correct destinations ', () => {
const hyperlinks1: object[] = [
{
name: 'deficit',
url: '/americas-finance-guide/national-deficit/'
},
{
name: 'federal revenues',
url: '/americas-finance-guide/government-revenue/'
},
{
name: 'spending',
url: '/americas-finance-guide/federal-spending/'
},
{
name: 'Historical Debt Outstanding',
url: '/datasets/historical-debt-outstanding/historical-debt-outstanding'
}
];
hyperlinks1.forEach(link => {
cy.findAllByRole('link', { name: link.name })
.first()
.click()
.wait(2000);
cy.url().should('include', link.url);
cy.visit('/americas-finance-guide/national-debt/');
})
});

it('Part 2: Validate all internal links on the page navigate to the correct destinations', () => {
const hyperlinks2: object[] = [
{
name: 'U.S. Treasury Monthly Statement of the Public Debt (MSPD)',
url: '/datasets/monthly-statement-public-debt/summary-of-treasury-securities-outstanding'
},
{
name: 'Average Interest Rates on U.S. Treasury Securities',
url: '/datasets/average-interest-rates-treasury-securities/average-interest-rates-on-u-s-treasury-securities'
}
];
hyperlinks2.forEach(link => {
cy.findAllByRole('link', { name: link.name })
.first()
.click()
.wait(2000);
cy.url().should('include', link.url);
cy.visit('/americas-finance-guide/national-debt/');
})
});

it('Validate all external links on the page navigate to the correct destinations ', () => {
const externalHyperlinks: object[] = [
{
name: 'Bureau of Labor Statistics',
url: 'https://www.bls.gov/developers/'
},
{
name: 'Bureau of Economic Analysis',
url: 'https://www.bea.gov/'
},
{
name: 'Bureau of the Fiscal Service',
url: 'https://www.fiscal.treasury.gov/'
},
{
name: 'https://fiscaldata.treasury.gov/static-data/published-reports/frusg/FRUSG_2022.pdf',
url: 'https://fiscaldata.treasury.gov/static-data/published-reports/frusg/FRUSG_2022.pdf'
},
{
name: 'https://fiscaldata.treasury.gov/static-data/published-reports/frusg/FRUSG_2022.pdf',
url: 'https://fiscaldata.treasury.gov/static-data/published-reports/frusg/FRUSG_2022.pdf'
},
{
name: 'https://www.gao.gov/americas-fiscal-future/federal-debt',
url: 'https://www.gao.gov/americas-fiscal-future/federal-debt'
},
{
name: 'https://www.whitehouse.gov/cea/written-materials/2021/10/06/the-debt-ceiling-an-explainer/',
url: 'https://www.whitehouse.gov/cea/written-materials/2021/10/06/the-debt-ceiling-an-explainer/'
},
{
name: 'https://www.whitehouse.gov/wp-content/uploads/2021/05/ap_4_borrowing_fy22.pdf',
url: 'https://www.whitehouse.gov/wp-content/uploads/2021/05/ap_4_borrowing_fy22.pdf'
},
{
name: 'https://www.cbo.gov/publication/56910',
url: 'https://www.cbo.gov/publication/56910'
},
{
name: 'https://www.federalreserve.gov/faqs/money_12853.htm',
url: 'https://www.federalreserve.gov/faqs/money_12853.htm'
},
{
name: 'https://www.cbo.gov/publication/56783',
url: 'https://www.cbo.gov/publication/56783'
},
{
name: 'https://fiscal.treasury.gov/reports-statements/treasury-bulletin/',
url: 'https://fiscal.treasury.gov/reports-statements/treasury-bulletin/'
},
{
name: 'https://www.usaspending.gov',
url: 'https://www.usaspending.gov'
}
];

externalHyperlinks.forEach(link => {
cy.findByRole('link',{ name: link.name }).should('have.attr', 'href', link.url);
});
});
});

describe('Validate charts', () => {
it('Load properly with no null or empty values', () => {
cy.get('[role="figure"]').each((chart) => {
cy.wrap(chart).scrollIntoView({ duration: 2000 })
.findAllByText('null').should('not.exist')
.findAllByText('NaN').should('not.exist')
.findAllByText('undefined').should('not.exist');
})
});

// it('Toggle-able views render properly on charts that have them', () => {
//
// });
//
// it('Test keyboard accessibility on charts that have it', () => {
//
// });
});

it('Validate all glossary terms on page', () => {
const glossaryTerms: string[] = [
'non-marketable',
'marketable',
'fiscal year (FY)',
'spending',
'revenue',
'deficit',
'bonds',
'bills',
'notes',
'floating rate notes',
'Treasury inflation-protected securities (TIPS)',
'gross domestic product (GDP)',
'debt held by the public',
'intragovernmental',
'calendar year',
'interest rates',
];

const foundTerms = cy.findAllByTestId('infoTipContainer');

foundTerms.each((term, index) => {
cy.wrap(term).should('include.text', glossaryTerms[index]);
});

foundTerms.contains('bills')
.click();

cy.findAllByTestId('popupContainer')
.findByText('View in glossary')
.click();

});

it('Validate that the related datasets section contains the correct datasets', () => {
const relatedDs: string[] = [
'Debt to the Penny',
'Historical Debt Outstanding',
'U.S. Treasury Monthly Statement of the Public Debt (MSPD)',
'Average Interest Rates on U.S. Treasury Securities'
]

const foundRelatedDs = cy.findAllByTestId('cardWrapper');

foundRelatedDs.each((ds, index) => {
cy.wrap(ds).should('include.text', relatedDs[index]);
});
});
});
46 changes: 44 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"amd-loader": "^0.0.8",
"better-npm-audit": "^3.11.0",
"bignumber.js": "^9.1.2",
"camelcase-keys": "^9.0.0",
"classnames": "^2.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,16 @@ const DataPreviewSectionContainer: FunctionComponent<DataPreviewSectionProps> =

const getDepaginatedData = async () => {
if (!selectedTable?.apiFilter || (selectedTable.apiFilter && applyApiFilter())) {
const from = formatDateForApi(dateRange.from);
const to = formatDateForApi(dateRange.to);
let from = formatDateForApi(dateRange.from);
let to = formatDateForApi(dateRange.to);

// redemption_tables and sb_value are exception scenarios where the date string needs to
// be YYYY-MM.
if (selectedTable.endpoint.indexOf('redemption_tables') > -1 || selectedTable.endpoint.indexOf('sb_value') > -1) {
from = from.substring(0, from.lastIndexOf('-'));
to = to.substring(0, to.lastIndexOf('-'));
}

const dateFilter = buildDateFilter(selectedTable, from, to);
const sortParam = buildSortParams(selectedTable, selectedPivot);
const apiFilterParam =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,16 @@ const TableSectionContainer = ({

const getDepaginatedData = async () => {
if (!selectedTable?.apiFilter || (selectedTable.apiFilter && applyApiFilter())) {
const from = formatDateForApi(dateRange.from);
const to = formatDateForApi(dateRange.to);
let from = formatDateForApi(dateRange.from);
let to = formatDateForApi(dateRange.to);

// redemption_tables and sb_value are exception scenarios where the date string needs to
// be YYYY-MM.
if (selectedTable.endpoint.indexOf('redemption_tables') > -1 || selectedTable.endpoint.indexOf('sb_value') > -1) {
from = from.substring(0, from.lastIndexOf('-'));
to = to.substring(0, to.lastIndexOf('-'));
}

const dateFilter = buildDateFilter(selectedTable, from, to);
const sortParam = buildSortParams(selectedTable, selectedPivot);
const apiFilterParam =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const mockDateRange = {

export const selectedTableMoreFields = {
apiId: 1,
endpoint: 'v1/accounting/od/gas_held_by_public_daily_activity',
tableName: 'Table 1',
fields: [
{ columnName: 'facility_desc', prettyName: 'Facility Description', dataType: 'string' },
Expand All @@ -109,6 +110,7 @@ export const selectedTableMoreFields = {

export const selectedTableLessFields = {
apiId: 2,
endpoint: 'v1/accounting/od/gas_held_by_public_daily_activity',
tableName: 'Table 1',
fields: [
{ columnName: 'facility_desc', prettyName: 'Facility Description', dataType: 'string' },
Expand All @@ -123,6 +125,7 @@ export const selectedTableLessFields = {

export const mockTableWithPivot = {
apiId: 3,
endpoint: 'v1/accounting/od/gas_held_by_public_daily_activity',
tableName: 'Debt to the Nickel',
dateField: 'record_date',
dataDisplays: [
Expand Down Expand Up @@ -150,6 +153,7 @@ export const mockTableWithNoChartAvailable = {

export const mockTableWithUserFilterAvailable = {
apiId: 4,
endpoint: 'v1/accounting/od/gas_held_by_public_daily_activity',
tableName: 'Exchange Rates',
dataDisplays: [{ dimensionField: null, title: 'Complete Table' }],
fields: [
Expand All @@ -168,6 +172,7 @@ export const mockTableWithUserFilterAvailable = {

export const mockTableWithApiFilterAvailable = {
apiId: 4,
endpoint: 'v1/accounting/od/gas_held_by_public_daily_activity',
tableName: 'Exchange Rates',
isLargeDataset: true,
dataDefaultHeader: true,
Expand All @@ -188,6 +193,7 @@ export const mockTableWithApiFilterAvailable = {
};
export const mockTableWithApiFilterAvailableDisplayDefaultData = {
apiId: 4,
endpoint: 'v1/accounting/od/gas_held_by_public_daily_activity',
tableName: 'Exchange Rates',
isLargeDataset: true,
dataDefaultHeader: true,
Expand Down
Loading

0 comments on commit e884e0b

Please sign in to comment.