Date: Tue, 20 Aug 2024 15:31:28 +0100
Subject: [PATCH 24/24] refactor file structure and fix typo
---
.../PublicLinks.test.tsx} | 47 ++++++++++++++++++-
1 file changed, 45 insertions(+), 2 deletions(-)
rename editor.planx.uk/src/pages/FlowEditor/components/Settings/tests/{ServiceSettings.PublicLinks.test.tsx => ServiceSettings/PublicLinks.test.tsx} (82%)
diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Settings/tests/ServiceSettings.PublicLinks.test.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Settings/tests/ServiceSettings/PublicLinks.test.tsx
similarity index 82%
rename from editor.planx.uk/src/pages/FlowEditor/components/Settings/tests/ServiceSettings.PublicLinks.test.tsx
rename to editor.planx.uk/src/pages/FlowEditor/components/Settings/tests/ServiceSettings/PublicLinks.test.tsx
index 8ed977efd4..e8e9770561 100644
--- a/editor.planx.uk/src/pages/FlowEditor/components/Settings/tests/ServiceSettings.PublicLinks.test.tsx
+++ b/editor.planx.uk/src/pages/FlowEditor/components/Settings/tests/ServiceSettings/PublicLinks.test.tsx
@@ -1,7 +1,7 @@
import { useStore } from "pages/FlowEditor/lib/store";
import setupServiceSettingsScreen, {
mockWindowLocationObject,
-} from "./helpers/setupServiceSettingsScreen";
+} from "../helpers/setupServiceSettingsScreen";
import { screen } from "@testing-library/react";
const { getState, setState } = useStore;
@@ -125,7 +125,26 @@ describe("A team with a subdomain has an online, published service. ", () => {
);
});
});
+describe("A team with a subdomain has an offline, unpublished service. ", () => {
+ beforeEach(async () => {
+ // setup state values that depends on
+ setState({
+ ...subdomainStateData,
+ isFlowPublished: false,
+ flowStatus: "offline",
+ });
+
+ // render the comp
+ setupServiceSettingsScreen();
+ });
+ it("has a public link with the subdomain url in a tag", async () => {
+ const { flowSlug, teamDomain } = getState();
+
+ await inactiveLinkCheck(`https://${teamDomain}/${flowSlug}`);
+ });
+ it("has a disabled copy button", disabledCopyCheck);
+});
describe("A team without a subdomain has an offline, published service. ", () => {
beforeEach(async () => {
// setup state values that depends on
@@ -198,7 +217,7 @@ describe("A team without a subdomain has an online, published service. ", () =>
setupServiceSettingsScreen();
await activeLinkCheck(publishedUrl);
});
- it("has a enabled copy button", () => {
+ it("has an enabled copy button", () => {
// render the comp
setupServiceSettingsScreen();
enabledCopyCheck();
@@ -215,3 +234,27 @@ describe("A team without a subdomain has an online, published service. ", () =>
expect(navigator.clipboard.writeText).toBeCalledWith(publishedUrl);
});
});
+
+describe("A team without a subdomain has an offline, unpublished service. ", () => {
+ beforeEach(async () => {
+ // setup state values that depends on
+ setState({
+ ...nonSubdomainStateData,
+ flowStatus: "offline",
+ isFlowPublished: false,
+ });
+
+ // Mocking window.location.origin
+ jest
+ .spyOn(window, "location", "get")
+ .mockReturnValue(mockWindowLocationObject);
+
+ // render the comp
+ setupServiceSettingsScreen();
+ });
+
+ it("has a public link with the url in a
tag", async () => {
+ await inactiveLinkCheck(publishedUrl);
+ });
+ it("has a disabled copy button", disabledCopyCheck);
+});