diff --git a/ui/src/Components/Toast/__snapshots__/AppToasts.test.tsx.snap b/ui/src/Components/Toast/__snapshots__/AppToasts.test.tsx.snap index d69cf7762..24e7be143 100644 --- a/ui/src/Components/Toast/__snapshots__/AppToasts.test.tsx.snap +++ b/ui/src/Components/Toast/__snapshots__/AppToasts.test.tsx.snap @@ -77,6 +77,25 @@ exports[` renders UpgradeToastMessage when alertStore.info.upgradeR +
+ + + + + + +
@@ -130,6 +149,25 @@ exports[` renders upstream error toasts for each unhealthy upstream +
+ + + + + + +
@@ -176,6 +214,25 @@ exports[` renders upstream error toasts for each unhealthy upstream
+
+ + + + + + +
diff --git a/ui/src/Components/Toast/index.test.tsx b/ui/src/Components/Toast/index.test.tsx new file mode 100644 index 000000000..72f9b0535 --- /dev/null +++ b/ui/src/Components/Toast/index.test.tsx @@ -0,0 +1,39 @@ +import React from "react"; + +import { mount } from "enzyme"; + +import toDiffableHtml from "diffable-html"; + +import { faExclamation } from "@fortawesome/free-solid-svg-icons/faExclamation"; + +import { Toast } from "."; + +describe("", () => { + it("renders body by default", () => { + const tree = mount( + + ); + expect(toDiffableHtml(tree.html())).toMatch(/fake error/); + }); + + it("toggles body on toggle icon click", () => { + const tree = mount( + + ); + expect(toDiffableHtml(tree.html())).toMatch(/fake error/); + + tree.find("svg.cursor-pointer").simulate("click"); + expect(toDiffableHtml(tree.html())).not.toMatch(/fake error/); + + tree.find("svg.cursor-pointer").simulate("click"); + expect(toDiffableHtml(tree.html())).toMatch(/fake error/); + }); +}); diff --git a/ui/src/Components/Toast/index.tsx b/ui/src/Components/Toast/index.tsx index 63986fd9c..ee8b5e004 100644 --- a/ui/src/Components/Toast/index.tsx +++ b/ui/src/Components/Toast/index.tsx @@ -1,4 +1,4 @@ -import React, { FC, ReactNode } from "react"; +import React, { FC, ReactNode, useState } from "react"; import ReactDOM from "react-dom"; import TransitionGroup from "react-transition-group/TransitionGroup"; @@ -9,12 +9,15 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCircle } from "@fortawesome/free-solid-svg-icons/faCircle"; import { ThemeContext } from "Components/Theme"; +import { ToggleIcon } from "Components/ToggleIcon"; const Toast: FC<{ icon: IconDefinition; iconClass: string; message: ReactNode; }> = ({ icon, iconClass, message }) => { + const [isOpen, setIsOpen] = useState(true); + return (
@@ -26,7 +29,16 @@ const Toast: FC<{
- {message} + {isOpen ? message : null} +
+
+ + setIsOpen((v) => !v)} + /> +