Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create unit test for fragment render component #1032

Merged
merged 28 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1d70fd4
Unit testing for ArticleCTA component
blai0264 May 14, 2024
82e8659
Unit testing for BasicTextWithImage component
blai0264 May 14, 2024
16c72b4
Unit testing for Button component
blai0264 May 14, 2024
6172aa8
fixed typos in ImageWithCollapse.stories.js
blai0264 May 14, 2024
8227db5
Unit testing for ImageWithCollapse component
blai0264 May 14, 2024
81f23a2
Unit testing for QuoteVerticalLineContent component
blai0264 May 14, 2024
a4d9c53
Unit testing for ImageVerticalLineContent component
blai0264 May 14, 2024
a09e72e
Unit testing for TextContent component
blai0264 May 14, 2024
ba6cd8e
Unit testing for TextWithImage component
blai0264 May 14, 2024
1fbae41
updated alt arg value to match unit test query
blai0264 May 14, 2024
bde63d7
fix dcterms metadata to better support AA (#1019)
will0684 May 14, 2024
a6380d2
Font Optimization (#1020)
will0684 May 15, 2024
a195f72
Merge branch 'main' into fragment-component-tests
will0684 May 16, 2024
34f40a2
added on click test-case for ImageWithCollapse.test
blai0264 May 16, 2024
409c45b
small update to ImageWithCollapse.test
blai0264 May 16, 2024
4a309cf
stashing WIP changes for ImageWithCollapse.test.js
blai0264 May 23, 2024
efc1732
updated title path for fragment components
blai0264 May 31, 2024
4f3a14f
Created storybook entry for FragmentRender component
blai0264 May 31, 2024
d31ae72
created unit test for FragmentRender component
blai0264 May 31, 2024
fa4a734
add missing ISR_ENABLED ARG to Dockerfile (#1030)
will0684 May 23, 2024
bb62eff
add nullish coalescing operator to error page AA check (#1024)
will0684 May 23, 2024
063a3c7
upgrade nextjs version to fix issue with sharp and output:standalone …
will0684 May 23, 2024
b94661a
[Snyk] Upgrade: react, react-dom (#1026)
s-laugh May 27, 2024
6d2feb3
[Snyk] Upgrade i18next from 23.10.1 to 23.11.3 (#1027)
s-laugh May 27, 2024
a3ad828
[Snyk] Upgrade @types/react from 18.2.79 to 18.3.1 (#1028)
s-laugh May 27, 2024
ff9da23
[Snyk] Upgrade joi from 17.13.0 to 17.13.1 (#1029)
s-laugh May 27, 2024
8b78956
Merge branch 'main' into fragment-component-tests
blai0264 May 31, 2024
311c848
formatting
blai0264 May 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,249 changes: 1,249 additions & 0 deletions components/fragment_renderer/FragmentRender.stories.js

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions components/fragment_renderer/FragmentRender.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import FragmentRender from "./FragmentRender";
import { axe, toHaveNoViolations } from "jest-axe";
import {
ArticleCTA,
TextWithImage,
QuoteVerticalLineContent,
ImageWithCollapse,
Button,
TextContent,
} from "./FragmentRender.stories";
expect.extend(toHaveNoViolations);

describe("FragmentRender", () => {
it("renders ArticleCTA component", async () => {
const { container } = render(<FragmentRender {...ArticleCTA.args} />);
expect(screen.getByText((content) => content.startsWith("Information")))
.toBeInTheDocument;
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it("renders TextWithImage component", async () => {
const { container } = render(<FragmentRender {...TextWithImage.args} />);
expect(screen.getByText("It takes time to learn about government benefits"))
.toBeInTheDocument;
expect(screen.getByAltText("Community workers helping people"))
.toBeInTheDocument;
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it("renders QuoteVerticalLineContent component", async () => {
const { container } = render(
<FragmentRender {...QuoteVerticalLineContent.args} />
);
expect(
screen.getByText(
"I didn’t like having to change my birth year to get an estimate"
)
).toBeInTheDocument;
expect(screen.getByText((content) => content.startsWith("We now")))
.toBeInTheDocument;
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it("renders Button component", async () => {
const { container } = render(<FragmentRender {...Button.args} />);
expect(screen.getByText((content) => content.startsWith("Sign in")))
.toBeInTheDocument;
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it("renders TextContent component", async () => {
const { container } = render(<FragmentRender {...TextContent.args} />);
expect(screen.getByText((content) => content.startsWith("Alpha")))
.toBeInTheDocument;
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it("renders ImageWithCollapse component", async () => {
const { container } = render(
<FragmentRender {...ImageWithCollapse.args} />
);
expect(screen.getByText((content) => content.startsWith("Text version")))
.toBeInTheDocument;
expect(screen.getByAltText("Benefit news and updates page"))
.toBeInTheDocument;
const results = await axe(container);
expect(results).toHaveNoViolations();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";
import ArticleCTA from "./ArticleCTA";

export default {
title: "Components/Fragment_Renderer/ArticleCTA",
title: "Components/Fragment_Renderer/Fragment_Components/ArticleCTA",
component: ArticleCTA,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";
import BasicTextWithImage from "./BasicTextWithImage";

export default {
title: "Components/Fragment_Renderer/BasicTextWithImage",
title: "Components/Fragment_Renderer/Fragment_Components/BasicTextWithImage",
component: BasicTextWithImage,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";
import Button from "./Button";

export default {
title: "Components/Fragment_Renderer/Button",
title: "Components/Fragment_Renderer/Fragment_Components/Button",
component: Button,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";
import ImageFragment from "./ImageFragment";

export default {
title: "Components/Fragment_Renderer/ImageFragment",
title: "Components/Fragment_Renderer/Fragment_Components/ImageFragment",
component: ImageFragment,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as React from "react";
import ImageVerticalLineContent from "./ImageVerticalLineContent";

export default {
title: "Components/Fragment_Renderer/ImageVerticalLineContent",
title:
"Components/Fragment_Renderer/Fragment_Components/ImageVerticalLineContent",
component: ImageVerticalLineContent,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";
import ImageWithCollapse from "./ImageWithCollapse";

export default {
title: "Components/Fragment_Renderer/ImageWithCollapse",
title: "Components/Fragment_Renderer/Fragment_Components/ImageWithCollapse",
component: ImageWithCollapse,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ describe("ImageWithCollapse", () => {
expect(
screen.getByText((content) => content.startsWith("Ordered list item 1"))
).toBeInTheDocument();

// const details = screen.getByTestId("details");
// const div = screen.getByTestId("div");
// const paragraph = div.getElementsByTagName("p")[0];
// const unordered = div.getElementsByTagName("ul")[0];
// const ordered = div.getElementsByTagName("ol")[0];
// userEvent.click(details);
// const open = details.hasAttribute("open")
// expect( await open).toBeTruthy();
// expect(await paragraph).toBeVisible();
// expect(await unordered).toBeVisible();
// expect(await ordered).toBeVisible();

const results = await axe(container);
expect(results).toHaveNoViolations();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as React from "react";
import QuoteVerticalLineContent from "./QuoteVerticalLineContent";

export default {
title: "Components/Fragment_Renderer/QuoteVerticalLineContent",
title:
"Components/Fragment_Renderer/Fragment_Components/QuoteVerticalLineContent",
component: QuoteVerticalLineContent,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";
import TextContent from "./TextContent";

export default {
title: "Components/Fragment_Renderer/TextContent",
title: "Components/Fragment_Renderer/Fragment_Components/TextContent",
component: TextContent,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";
import TextWithImage from "./TextWithImage";

export default {
title: "Components/Fragment_Renderer/TextWithImage",
title: "Components/Fragment_Renderer/Fragment_Components/TextWithImage",
component: TextWithImage,
};

Expand Down
Loading