Skip to content

Commit

Permalink
Project page unit tests (#1040)
Browse files Browse the repository at this point in the history
* updated mockStore.js to include current projects

* removed updatesData query from pages since the data is available through the pageData object, updated props value for updatesData

* added unit testing for pages

* updated mockStore.js to include current projects

* updated mockStore.js

* added experiments data import to OAS benefits navigator test
  • Loading branch information
blai0264 authored Jun 18, 2024
1 parent 0433db6 commit b55024e
Show file tree
Hide file tree
Showing 10 changed files with 6,991 additions and 1,660 deletions.
8,538 changes: 6,901 additions & 1,637 deletions __mocks__/mockStore.js

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions __tests__/pages/benefits-navigator.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { render } from "@testing-library/react";
import BenefitsNavigatorOverview from "../../pages/projects/benefits-navigator/index";
import {
dictionaryData,
benefitsNavigatorData,
experimentsData,
benefitsNavigatorUpdatesData,
} from "../../__mocks__/mockStore";

describe("Benefits Navigator", () => {
it("renders without crashing", () => {
render(
<BenefitsNavigatorOverview
pageData={benefitsNavigatorData.data.sclabsPageV1ByPath}
updatesData={benefitsNavigatorUpdatesData}
dictionary={dictionaryData.data.dictionaryV1List}
allProjects={experimentsData.data.scLabsPagev1List.items}
/>
);
});
});
21 changes: 21 additions & 0 deletions __tests__/pages/dashboard.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { render } from "@testing-library/react";
import MscaDashboard from "../../pages/projects/dashboard/index";
import {
dictionaryData,
dashboardData,
experimentsData,
dashboardUpdatesData,
} from "../../__mocks__/mockStore";

describe("MSCA Dashboard", () => {
it("renders without crashing", () => {
render(
<MscaDashboard
pageData={dashboardData.data.sclabsPageV1ByPath}
updatesData={dashboardUpdatesData}
dictionary={dictionaryData.data.dictionaryV1List}
allProjects={experimentsData.data.scLabsPagev1List.items}
/>
);
});
});
21 changes: 21 additions & 0 deletions __tests__/pages/digital-standards-playbook.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { render } from "@testing-library/react";
import DigitalStandardsPlaybookPage from "../../pages/projects/digital-standards-playbook/index";
import {
dictionaryData,
playbookData,
experimentsData,
playbookUpdatesData,
} from "../../__mocks__/mockStore";

describe("Digital Standards Playbook", () => {
it("renders without crashing", () => {
render(
<DigitalStandardsPlaybookPage
pageData={playbookData.data.sclabsPageV1ByPath}
updatesData={playbookUpdatesData}
dictionary={dictionaryData.data.dictionaryV1List}
allProjects={experimentsData.data.scLabsPagev1List.items}
/>
);
});
});
21 changes: 21 additions & 0 deletions __tests__/pages/making-easier-get-benefits.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { render } from "@testing-library/react";
import IntegratedChannelStrategyPage from "../../pages/projects/making-easier-get-benefits/index";
import {
dictionaryData,
ICSData,
experimentsData,
ICSUpdatesData,
} from "../../__mocks__/mockStore";

describe("Integrated Channel Strategy", () => {
it("renders without crashing", () => {
render(
<IntegratedChannelStrategyPage
pageData={ICSData.data.sclabsPageV1ByPath}
updatesData={ICSUpdatesData}
dictionary={dictionaryData.data.dictionaryV1List}
allProjects={experimentsData.data.scLabsPagev1List.items}
/>
);
});
});
5 changes: 2 additions & 3 deletions __tests__/pages/oas-benefits-estimator.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/**
* @jest-environment jsdom
*/
import { render } from "@testing-library/react";
import OasBenefitsEstimator from "../../pages/projects/oas-benefits-estimator/index";
import {
dictionaryData,
oasBenefitsEstimatorData,
oasUpdatesData,
experimentsData,
} from "../../__mocks__/mockStore";

describe("OAS Benefits Estimator", () => {
Expand All @@ -16,6 +14,7 @@ describe("OAS Benefits Estimator", () => {
pageData={oasBenefitsEstimatorData.data.sclabsPageV1ByPath}
updatesData={oasUpdatesData}
dictionary={dictionaryData.data.dictionaryV1List}
allProjects={experimentsData.data.scLabsPagev1List.items}
/>
);
});
Expand Down
6 changes: 1 addition & 5 deletions pages/projects/benefits-navigator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,6 @@ export const getStaticProps = async ({ locale }) => {
const { data: pageData } = await aemServiceInstance.getFragment(
"benefitsNavigatorQuery"
);
// Get updates/article data
const { data: updatesData } = await aemServiceInstance.getFragment(
"benefitsNavigatorArticlesQuery"
);
// get dictionary
const { data: dictionary } = await aemServiceInstance.getFragment(
"dictionaryQuery"
Expand All @@ -657,7 +653,7 @@ export const getStaticProps = async ({ locale }) => {
locale: locale,
adobeAnalyticsUrl: process.env.ADOBE_ANALYTICS_URL ?? null,
pageData: pageData.sclabsPageV1ByPath,
updatesData: updatesData.sclabsPageV1List.items,
updatesData: pageData.sclabsPageV1ByPath.item.scLabProjectUpdates,
dictionary: dictionary.dictionaryV1List,
...(await serverSideTranslations(locale, ["common"])),
},
Expand Down
6 changes: 1 addition & 5 deletions pages/projects/digital-standards-playbook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,6 @@ export const getStaticProps = async ({ locale }) => {
const { data: pageData } = await aemServiceInstance.getFragment(
"getDigitalStandardsPlaybookPage"
);
// Get updates/article data
const { data: updatesData } = await aemServiceInstance.getFragment(
"getDigitalStandardsPlaybookArticles"
);
// get dictionary
const { data: dictionary } = await aemServiceInstance.getFragment(
"dictionaryQuery"
Expand All @@ -476,7 +472,7 @@ export const getStaticProps = async ({ locale }) => {
locale: locale,
adobeAnalyticsUrl: process.env.ADOBE_ANALYTICS_URL ?? null,
pageData: pageData.sclabsPageV1ByPath,
updatesData: updatesData.sclabsPageV1List.items,
updatesData: pageData.sclabsPageV1ByPath.item.scLabProjectUpdates,
dictionary: dictionary.dictionaryV1List,
...(await serverSideTranslations(locale, ["common"])),
},
Expand Down
6 changes: 1 addition & 5 deletions pages/projects/making-easier-get-benefits/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,6 @@ export const getStaticProps = async ({ locale }) => {
const { data: pageData } = await aemServiceInstance.getFragment(
"integratedChannelStrategyQuery"
);
// Get updates/article data
const { data: updatesData } = await aemServiceInstance.getFragment(
"integratedChannelStrategyArticlesQuery"
);
// get dictionary
const { data: dictionary } = await aemServiceInstance.getFragment(
"dictionaryQuery"
Expand All @@ -371,7 +367,7 @@ export const getStaticProps = async ({ locale }) => {
locale: locale,
adobeAnalyticsUrl: process.env.ADOBE_ANALYTICS_URL ?? null,
pageData: pageData.sclabsPageV1ByPath,
updatesData: updatesData.sclabsPageV1List.items,
updatesData: pageData.sclabsPageV1ByPath.item.scLabProjectUpdates,
dictionary: dictionary.dictionaryV1List,
...(await serverSideTranslations(locale, ["common"])),
},
Expand Down
6 changes: 1 addition & 5 deletions pages/projects/oas-benefits-estimator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,6 @@ export const getStaticProps = async ({ locale }) => {
const { data: pageData } = await aemServiceInstance.getFragment(
"oasBenefitsEstimatorQuery"
);
// Get updates/article data
const { data: updatesData } = await aemServiceInstance.getFragment(
"oasBenefitsEstimatorArticlesQuery"
);
// get dictionary
const { data: dictionary } = await aemServiceInstance.getFragment(
"dictionaryQuery"
Expand All @@ -428,7 +424,7 @@ export const getStaticProps = async ({ locale }) => {
locale: locale,
adobeAnalyticsUrl: process.env.ADOBE_ANALYTICS_URL ?? null,
pageData: pageData.sclabsPageV1ByPath,
updatesData: updatesData.sclabsPageV1List.items,
updatesData: pageData.sclabsPageV1ByPath.item.scLabProjectUpdates,
dictionary: dictionary.dictionaryV1List,
...(await serverSideTranslations(locale, ["common"])),
},
Expand Down

0 comments on commit b55024e

Please sign in to comment.