tag", async () => {
+ // render the comp
+ setupServiceSettingsScreen();
+ await activeLinkCheck(publishedUrl);
+ });
+ it("has an enabled copy button", () => {
+ // render the comp
+ setupServiceSettingsScreen();
+ enabledCopyCheck();
+ });
+
+ it("can be copied to the clipboard", async () => {
+ // render the comp
+ const user = await setupServiceSettingsScreen();
+ const copyButton = screen.getByRole("button", { name: `copy` });
+
+ user.click(copyButton);
+
+ expect(await screen.findByText("copied")).toBeVisible();
+ 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);
+});
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
new file mode 100644
index 0000000000..57060f858e
--- /dev/null
+++ b/editor.planx.uk/src/pages/FlowEditor/components/Settings/tests/helpers/setupServiceSettingsScreen.tsx
@@ -0,0 +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 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: "/mockTeam/mock-planning-permish",
+ search: "",
+ assign: jest.fn(),
+ reload: jest.fn(),
+ replace: jest.fn(),
+ ancestorOrigins: {
+ length: 0,
+ contains: () => true,
+ item: () => null,
+ [Symbol.iterator]: jest.fn(),
+ },
+};
diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/team.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/team.ts
index 824e6cb93b..99238abce5 100644
--- a/editor.planx.uk/src/pages/FlowEditor/lib/store/team.ts
+++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/team.ts
@@ -17,6 +17,7 @@ export interface TeamStore {
teamSettings: TeamSettings;
teamSlug: string;
teamTheme: TeamTheme;
+ teamDomain: string;
setTeam: (team: Team) => void;
getTeam: () => Team;
@@ -40,6 +41,7 @@ export const teamStore: StateCreator<
teamSettings: {} as TeamSettings,
teamSlug: "",
teamTheme: {} as TeamTheme,
+ teamDomain: "",
setTeam: (team) => {
set({
@@ -49,6 +51,7 @@ export const teamStore: StateCreator<
teamSettings: team.settings,
teamSlug: team.slug,
teamTheme: team.theme,
+ teamDomain: team.domain,
});
if (team.theme?.favicon) {
@@ -64,6 +67,7 @@ export const teamStore: StateCreator<
settings: get().teamSettings,
slug: get().teamSlug,
theme: get().teamTheme,
+ domain: get().teamDomain,
}),
createTeam: async (newTeam) => {
@@ -84,6 +88,7 @@ export const teamStore: StateCreator<
id
name
slug
+ domain
flows(order_by: { updated_at: desc }) {
slug
updated_at