diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Settings/ServiceSettings.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Settings/ServiceSettings.tsx
index e277dbddb4..0709e23070 100644
--- a/editor.planx.uk/src/pages/FlowEditor/components/Settings/ServiceSettings.tsx
+++ b/editor.planx.uk/src/pages/FlowEditor/components/Settings/ServiceSettings.tsx
@@ -228,7 +228,7 @@ const ServiceSettings: React.FC = () => {
const handleClose = (
_event?: React.SyntheticEvent | Event,
- reason?: string,
+ reason?: string
) => {
if (reason === "clickaway") {
return;
@@ -279,7 +279,7 @@ const ServiceSettings: React.FC = () => {
});
const publishedLink = `${window.location.origin}${rootFlowPath(
- false,
+ false
)}/published`;
const subdomainLink = teamDomain && `https://${teamDomain}/${flowSlug}`;
@@ -405,9 +405,7 @@ const ServiceSettings: React.FC = () => {
onChange={() =>
statusForm.setFieldValue(
"status",
- statusForm.values.status === "online"
- ? "offline"
- : "online",
+ statusForm.values.status === "online" ? "offline" : "online"
)
}
/>
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
index e69de29bb2..ad44f9a486 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
@@ -0,0 +1,39 @@
+import { useStore } from "pages/FlowEditor/lib/store";
+import ServiceSettings from "../ServiceSettings";
+import setupServiceSettingsScreen, {
+ mockWindowLocationObject,
+} from "./helpers/setupServiceSettingsScreen";
+import { screen } from "@testing-library/react";
+import { rootFlowPath } from "routes/utils";
+
+const { getState, setState } = useStore;
+
+describe("Check when service is offline and published, the team has a subdomain", () => {
+ beforeEach(async () => {
+ // setup state values that depends on
+ setState({
+ flowSettings: {},
+ flowStatus: "offline",
+ teamDomain: "mockedteamdomain.com",
+ teamName: "mockTeam",
+ isFlowPublished: true,
+ flowSlug: "mock-planning-permish",
+ });
+
+ // render the comp
+ setupServiceSettingsScreen();
+
+ // Mocking window.location.origin
+ jest
+ .spyOn(window, "location", "get")
+ .mockReturnValue(mockWindowLocationObject);
+ });
+
+ it("public link should be the current published url", async () => {
+ expect(
+ await screen.findByText(
+ `https://mockedteamdomain.com/mock-planning-permish`
+ )
+ ).toBe;
+ });
+});
diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Settings/tests/helpers/setupServiceSettingsScreen.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Settings/tests/helpers/setupServiceSettingsScreen.tsx
index cdc4edb258..961c4440c7 100644
--- a/editor.planx.uk/src/pages/FlowEditor/components/Settings/tests/helpers/setupServiceSettingsScreen.tsx
+++ b/editor.planx.uk/src/pages/FlowEditor/components/Settings/tests/helpers/setupServiceSettingsScreen.tsx
@@ -1,7 +1,38 @@
import React from "react";
import ServiceSettings from "../../ServiceSettings";
+import { setup } from "testUtils";
+import { DndProvider } from "react-dnd";
+import { HTML5Backend } from "react-dnd-html5-backend";
+import { screen } from "@testing-library/react";
-export default function setupServiceSettingsScreen() {
- return ;
+export default async function setupServiceSettingsScreen() {
+ const { user } = setup(
+
+
+
+ );
+ await screen.findByText("Your public Link");
+ return user;
}
+
+export const mockWindowLocationObject = {
+ origin: "https://mocked-origin.com",
+ hash: "",
+ host: "dummy.com",
+ port: "80",
+ protocol: "http:",
+ hostname: "dummy.com",
+ href: "http://dummy.com?page=1&name=testing",
+ pathname: "",
+ search: "",
+ assign: jest.fn(),
+ reload: jest.fn(),
+ replace: jest.fn(),
+ ancestorOrigins: {
+ length: 0,
+ contains: () => true,
+ item: () => null,
+ [Symbol.iterator]: jest.fn(),
+ },
+};