From f5e0849f8d2e4c0f3503506531157382124a808f Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 28 May 2024 15:54:20 +0100 Subject: [PATCH 01/33] add name to store functions --- .../src/pages/FlowEditor/lib/store/editor.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts index e24638d7b8..0817dc2d5c 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts @@ -73,7 +73,7 @@ export interface EditorStore extends Store.Store { connectTo: (id: Store.nodeId) => void; copyFlow: (flowId: string) => Promise; copyNode: (id: Store.nodeId) => void; - createFlow: (teamId: any, newSlug: any) => Promise; + createFlow: (teamId: any, newSlug: any, newName: string) => Promise; deleteFlow: (teamId: number, flowSlug: string) => Promise; validateAndDiffFlow: (flowId: string) => Promise; getFlows: (teamId: number) => Promise; @@ -186,12 +186,17 @@ export const editorStore: StateCreator< localStorage.setItem("clipboard", id); }, - createFlow: async (teamId, newSlug) => { + createFlow: async (teamId, newSlug, newName) => { let response = (await client.mutate({ mutation: gql` - mutation CreateFlow($data: jsonb, $slug: String, $teamId: Int) { + mutation CreateFlow( + $data: jsonb + $slug: String + $name: String + $teamId: Int + ) { insert_flows_one( - object: { slug: $slug, team_id: $teamId, version: 1 } + object: { slug: $slug, name: $name, team_id: $teamId, version: 1 } ) { id data @@ -201,6 +206,7 @@ export const editorStore: StateCreator< variables: { slug: newSlug, teamId, + name: newName, }, })) as any; @@ -277,6 +283,7 @@ export const editorStore: StateCreator< where: { team: { id: { _eq: $teamId } } } ) { id + name slug updated_at operations(limit: 1, order_by: { id: desc }) { From 54cb3b2460675aa49679fbb80b920ff6f3b49329 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 28 May 2024 16:52:08 +0100 Subject: [PATCH 02/33] revert changes to store --- .../src/pages/FlowEditor/lib/store/editor.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts index 0817dc2d5c..4bb7165609 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts @@ -73,7 +73,7 @@ export interface EditorStore extends Store.Store { connectTo: (id: Store.nodeId) => void; copyFlow: (flowId: string) => Promise; copyNode: (id: Store.nodeId) => void; - createFlow: (teamId: any, newSlug: any, newName: string) => Promise; + createFlow: (teamId: any, newSlug: any) => Promise; deleteFlow: (teamId: number, flowSlug: string) => Promise; validateAndDiffFlow: (flowId: string) => Promise; getFlows: (teamId: number) => Promise; @@ -186,17 +186,12 @@ export const editorStore: StateCreator< localStorage.setItem("clipboard", id); }, - createFlow: async (teamId, newSlug, newName) => { + createFlow: async (teamId, newSlug) => { let response = (await client.mutate({ mutation: gql` - mutation CreateFlow( - $data: jsonb - $slug: String - $name: String - $teamId: Int - ) { + mutation CreateFlow($data: jsonb, $slug: String, $teamId: Int) { insert_flows_one( - object: { slug: $slug, name: $name, team_id: $teamId, version: 1 } + object: { slug: $slug, team_id: $teamId, version: 1 } ) { id data @@ -206,7 +201,6 @@ export const editorStore: StateCreator< variables: { slug: newSlug, teamId, - name: newName, }, })) as any; @@ -283,7 +277,7 @@ export const editorStore: StateCreator< where: { team: { id: { _eq: $teamId } } } ) { id - name + slug updated_at operations(limit: 1, order_by: { id: desc }) { From 7458e9bbc7341e78dd04cf2684f2c966a47b70e8 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 29 May 2024 16:13:12 +0100 Subject: [PATCH 03/33] alter get flow and create flow on team page --- .../src/pages/FlowEditor/lib/store/editor.ts | 16 +++++++++++----- editor.planx.uk/src/pages/Team.tsx | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts index 4bb7165609..7148a46deb 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts @@ -73,7 +73,7 @@ export interface EditorStore extends Store.Store { connectTo: (id: Store.nodeId) => void; copyFlow: (flowId: string) => Promise; copyNode: (id: Store.nodeId) => void; - createFlow: (teamId: any, newSlug: any) => Promise; + createFlow: (teamId: any, newSlug: any, newName: string) => Promise; deleteFlow: (teamId: number, flowSlug: string) => Promise; validateAndDiffFlow: (flowId: string) => Promise; getFlows: (teamId: number) => Promise; @@ -186,12 +186,17 @@ export const editorStore: StateCreator< localStorage.setItem("clipboard", id); }, - createFlow: async (teamId, newSlug) => { + createFlow: async (teamId, newSlug, newName) => { let response = (await client.mutate({ mutation: gql` - mutation CreateFlow($data: jsonb, $slug: String, $teamId: Int) { + mutation CreateFlow( + $data: jsonb + $slug: String + $teamId: Int + $name: String + ) { insert_flows_one( - object: { slug: $slug, team_id: $teamId, version: 1 } + object: { slug: $slug, team_id: $teamId, version: 1, name: $name } ) { id data @@ -199,6 +204,7 @@ export const editorStore: StateCreator< } `, variables: { + name: newName, slug: newSlug, teamId, }, @@ -277,7 +283,7 @@ export const editorStore: StateCreator< where: { team: { id: { _eq: $teamId } } } ) { id - + name slug updated_at operations(limit: 1, order_by: { id: desc }) { diff --git a/editor.planx.uk/src/pages/Team.tsx b/editor.planx.uk/src/pages/Team.tsx index 7bd90a1776..73709cd1dd 100644 --- a/editor.planx.uk/src/pages/Team.tsx +++ b/editor.planx.uk/src/pages/Team.tsx @@ -203,7 +203,7 @@ const FlowItem: React.FC = ({ - {flow.slug} + {flow.name} {flowInfoHelper(flow.updated_at, flow.operations)} @@ -326,7 +326,7 @@ const Team: React.FC = () => { const newFlowSlug = slugify(newFlowName); useStore .getState() - .createFlow(teamId, newFlowSlug) + .createFlow(teamId, newFlowSlug, newFlowName) .then((newId: string) => { navigation.navigate(`/${slug}/${newId}`); }); From 19649def936ff6f517102c2579cc3cdc2afa8cde Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 29 May 2024 16:57:47 +0100 Subject: [PATCH 04/33] add name to renaming mutation --- editor.planx.uk/src/pages/Team.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/editor.planx.uk/src/pages/Team.tsx b/editor.planx.uk/src/pages/Team.tsx index 73709cd1dd..9259da8797 100644 --- a/editor.planx.uk/src/pages/Team.tsx +++ b/editor.planx.uk/src/pages/Team.tsx @@ -214,21 +214,23 @@ const FlowItem: React.FC = ({ items={[ { onClick: async () => { - const newSlug = prompt("New name", flow.slug); - if (newSlug && slugify(newSlug) !== flow.slug) { + const newName = prompt("New name", flow.name); + if (newName && slugify(newName) !== flow.slug) { + const newSlug = slugify(newName); await client.mutate({ mutation: gql` mutation UpdateFlowSlug( $teamId: Int $slug: String $newSlug: String + $newName: String ) { update_flows( where: { team: { id: { _eq: $teamId } } slug: { _eq: $slug } } - _set: { slug: $newSlug } + _set: { slug: $newSlug, name: $newName } ) { affected_rows } @@ -237,7 +239,8 @@ const FlowItem: React.FC = ({ variables: { teamId: teamId, slug: flow.slug, - newSlug: slugify(newSlug), + newSlug: newSlug, + newName: newName, }, }); From aaa05d141f0bbb8607557f459c5348c2ef00b6eb Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Thu, 30 May 2024 09:36:40 +0100 Subject: [PATCH 05/33] refactor code to switch slug to name in data retrieval --- .../src/pages/FlowEditor/lib/store/editor.ts | 7 ++++++- .../src/pages/FlowEditor/lib/store/shared.ts | 11 ++++++----- editor.planx.uk/src/routes/views/draft.tsx | 7 +++++-- editor.planx.uk/src/routes/views/preview.tsx | 4 ++-- editor.planx.uk/src/routes/views/published.tsx | 2 ++ editor.planx.uk/src/routes/views/standalone.tsx | 5 +++-- editor.planx.uk/src/types.ts | 1 + 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts index 7148a46deb..8b660be9ad 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts @@ -139,7 +139,12 @@ export const editorStore: StateCreator< const cloneStateFromShareDb = () => { const flow = JSON.parse(JSON.stringify(doc.data)); - get().setFlow({ id, flow, flowSlug: get().flowSlug }); + get().setFlow({ + id, + flow, + flowSlug: get().flowSlug, + flowName: get().flowName, + }); }; // set state from initial load diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts index 3b4381a463..da7d90e676 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts @@ -24,18 +24,20 @@ export interface SharedStore extends Store.Store { id, flow, flowSlug, + flowName, flowStatus, }: { id: string; flow: Store.flow; flowSlug: string; + flowName: string; flowStatus?: FlowStatus; }) => void; wasVisited: (id: Store.nodeId) => boolean; previewEnvironment: PreviewEnvironment; setPreviewEnvironment: (previewEnvironment: PreviewEnvironment) => void; setFlowSlug: (flowSlug: string) => void; - setFlowNameFromSlug: (flowSlug: string) => void; + setFlowName: (flowSlug: string) => void; $public: (auth?: Auth) => CoreDomainClient; $client: CoreDomainClient; } @@ -91,8 +93,8 @@ export const sharedStore: StateCreator< removeSessionIdSearchParam(); }, - setFlow({ id, flow, flowSlug, flowStatus }) { - this.setFlowNameFromSlug(flowSlug); + setFlow({ id, flow, flowSlug, flowName, flowStatus }) { + this.setFlowName(flowName); set({ id, flow, flowSlug, flowStatus }); get().initNavigationStore(); }, @@ -110,8 +112,7 @@ export const sharedStore: StateCreator< set({ flowSlug }); }, - setFlowNameFromSlug(flowSlug) { - const flowName = capitalize(flowSlug.replaceAll?.("-", " ")); + setFlowName(flowName) { set({ flowName }); }, diff --git a/editor.planx.uk/src/routes/views/draft.tsx b/editor.planx.uk/src/routes/views/draft.tsx index d5b85c679c..4bfbb1fbe4 100644 --- a/editor.planx.uk/src/routes/views/draft.tsx +++ b/editor.planx.uk/src/routes/views/draft.tsx @@ -32,12 +32,14 @@ export const draftView = async (req: NaviRequest) => { const flowData = await fetchDraftFlattenedFlowData(flow.id); const state = useStore.getState(); - state.setFlow({ id: flow.id, flow: flowData, flowSlug }); - state.setFlowNameFromSlug(flowSlug); + state.setFlow({ id: flow.id, flow: flowData, flowSlug, flowName: flow.name }); + state.setFlowName(flow.name); state.setGlobalSettings(data.globalSettings[0]); state.setFlowSettings(flow.settings); state.setTeam(flow.team); + console.log(flow.name); + return ( @@ -80,6 +82,7 @@ const fetchSettingsForDraftView = async ( } settings slug + name } globalSettings: global_settings { footerContent: footer_content diff --git a/editor.planx.uk/src/routes/views/preview.tsx b/editor.planx.uk/src/routes/views/preview.tsx index 0cedf9545a..c9514004cb 100644 --- a/editor.planx.uk/src/routes/views/preview.tsx +++ b/editor.planx.uk/src/routes/views/preview.tsx @@ -28,8 +28,8 @@ export const previewView = async (req: NaviRequest) => { const flowData = await fetchFlattenedFlowData(flow.id); const state = useStore.getState(); - state.setFlow({ id: flow.id, flow: flowData, flowSlug }); - state.setFlowNameFromSlug(flowSlug); + state.setFlow({ id: flow.id, flow: flowData, flowSlug, flowName: flow.name }); + state.setFlowName(flow.name); state.setGlobalSettings(data.globalSettings[0]); state.setFlowSettings(flow.settings); state.setTeam(flow.team); diff --git a/editor.planx.uk/src/routes/views/published.tsx b/editor.planx.uk/src/routes/views/published.tsx index 5f2b26e470..9570675577 100644 --- a/editor.planx.uk/src/routes/views/published.tsx +++ b/editor.planx.uk/src/routes/views/published.tsx @@ -49,6 +49,7 @@ export const publishedView = async (req: NaviRequest) => { flow: publishedFlow, flowSlug, flowStatus: flow.status, + flowName: flow.name, }); state.setGlobalSettings(data.globalSettings[0]); state.setFlowSettings(flow.settings); @@ -84,6 +85,7 @@ export const fetchSettingsForPublishedView = async ( } ) { id + name team { theme { primaryColour: primary_colour diff --git a/editor.planx.uk/src/routes/views/standalone.tsx b/editor.planx.uk/src/routes/views/standalone.tsx index 75d17bdcdb..b48367c309 100644 --- a/editor.planx.uk/src/routes/views/standalone.tsx +++ b/editor.planx.uk/src/routes/views/standalone.tsx @@ -24,14 +24,14 @@ const standaloneView = async (req: NaviRequest) => { const teamSlug = req.params.team || (await getTeamFromDomain(window.location.hostname)); const data = await fetchDataForStandaloneView(flowSlug, teamSlug); - + console.log(data); const { flows: [{ team, settings: flowSettings }], globalSettings, } = data; const state = useStore.getState(); - state.setFlowNameFromSlug(flowSlug); + state.setFlowName(flowSlug); state.setGlobalSettings(globalSettings[0]); state.setFlowSettings(flowSettings); state.setTeam(team); @@ -61,6 +61,7 @@ const fetchDataForStandaloneView = async ( } ) { id + name team { theme { primaryColour: primary_colour diff --git a/editor.planx.uk/src/types.ts b/editor.planx.uk/src/types.ts index ccb534ba1e..9a129e442e 100644 --- a/editor.planx.uk/src/types.ts +++ b/editor.planx.uk/src/types.ts @@ -17,6 +17,7 @@ export type FormikHookReturn = ReturnType; export interface Flow { id: string; slug: string; + name: string; team: Team; settings?: FlowSettings; status?: FlowStatus; From f4e8a0571efedb703d0ea03da97788e71e299ac5 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Fri, 31 May 2024 10:32:16 +0100 Subject: [PATCH 06/33] alter rename logic to check for name instead of slug to capture capitalisation changes --- editor.planx.uk/src/pages/Team.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor.planx.uk/src/pages/Team.tsx b/editor.planx.uk/src/pages/Team.tsx index 9259da8797..067d9696c3 100644 --- a/editor.planx.uk/src/pages/Team.tsx +++ b/editor.planx.uk/src/pages/Team.tsx @@ -215,7 +215,7 @@ const FlowItem: React.FC = ({ { onClick: async () => { const newName = prompt("New name", flow.name); - if (newName && slugify(newName) !== flow.slug) { + if (newName && newName !== flow.name) { const newSlug = slugify(newName); await client.mutate({ mutation: gql` From 03a508d67fbf2ce07f8f95f2dfe1c35656c49ae3 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Fri, 31 May 2024 14:58:34 +0100 Subject: [PATCH 07/33] alter state updates --- editor.planx.uk/src/@planx/components/Pay/Editor.tsx | 4 +++- editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts | 5 ++--- editor.planx.uk/src/routes/team.tsx | 2 ++ editor.planx.uk/src/routes/views/standalone.tsx | 9 ++++----- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/Pay/Editor.tsx b/editor.planx.uk/src/@planx/components/Pay/Editor.tsx index 528756c6d2..18e5631c18 100644 --- a/editor.planx.uk/src/@planx/components/Pay/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Pay/Editor.tsx @@ -137,7 +137,7 @@ export type Props = EditorProps; const Component: React.FC = (props: Props) => { const [flowName] = useStore((store) => [store.flowName]); - + console.log(flowName); const initialValues: Pay = { title: props.node?.data?.title || "Pay for your application", bannerTitle: @@ -189,6 +189,8 @@ const Component: React.FC = (props: Props) => { } }; + console.log(flowName); + return ( initialValues={initialValues} diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts index da7d90e676..11ce61a9bb 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts @@ -37,7 +37,7 @@ export interface SharedStore extends Store.Store { previewEnvironment: PreviewEnvironment; setPreviewEnvironment: (previewEnvironment: PreviewEnvironment) => void; setFlowSlug: (flowSlug: string) => void; - setFlowName: (flowSlug: string) => void; + setFlowName: (flowName: string) => void; $public: (auth?: Auth) => CoreDomainClient; $client: CoreDomainClient; } @@ -94,8 +94,7 @@ export const sharedStore: StateCreator< }, setFlow({ id, flow, flowSlug, flowName, flowStatus }) { - this.setFlowName(flowName); - set({ id, flow, flowSlug, flowStatus }); + set({ id, flow, flowSlug, flowName, flowStatus }); get().initNavigationStore(); }, diff --git a/editor.planx.uk/src/routes/team.tsx b/editor.planx.uk/src/routes/team.tsx index 60e68060f2..83ae2229b7 100644 --- a/editor.planx.uk/src/routes/team.tsx +++ b/editor.planx.uk/src/routes/team.tsx @@ -50,6 +50,7 @@ const routes = compose( } ) { id + name } } `, @@ -66,6 +67,7 @@ const routes = compose( } useStore.getState().setFlowSlug(slug); + useStore.getState().setFlowName(flow.name); await useStore.getState().connectTo(flow.id); } diff --git a/editor.planx.uk/src/routes/views/standalone.tsx b/editor.planx.uk/src/routes/views/standalone.tsx index b48367c309..8a9817795f 100644 --- a/editor.planx.uk/src/routes/views/standalone.tsx +++ b/editor.planx.uk/src/routes/views/standalone.tsx @@ -11,7 +11,7 @@ import { Flow, GlobalSettings } from "types"; import { getTeamFromDomain } from "../utils"; interface StandaloneViewData { - flows: Pick[]; + flows: Pick[]; globalSettings: GlobalSettings[]; } @@ -24,14 +24,13 @@ const standaloneView = async (req: NaviRequest) => { const teamSlug = req.params.team || (await getTeamFromDomain(window.location.hostname)); const data = await fetchDataForStandaloneView(flowSlug, teamSlug); - console.log(data); const { - flows: [{ team, settings: flowSettings }], + flows: [{ name, team, settings: flowSettings }], globalSettings, } = data; - + console.log(data); const state = useStore.getState(); - state.setFlowName(flowSlug); + state.setFlowName(data.flows[0].name); state.setGlobalSettings(globalSettings[0]); state.setFlowSettings(flowSettings); state.setTeam(team); From d3dc865f0a6b6dcfeffe32ce5591dc391a9c3f7f Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 4 Jun 2024 11:51:23 +0100 Subject: [PATCH 08/33] add setFlow to team view and remove reference to setFlowName from preview --- .../src/pages/FlowEditor/lib/store/shared.ts | 8 ++-- editor.planx.uk/src/routes/team.tsx | 37 +++++++++++++++++-- editor.planx.uk/src/routes/views/preview.tsx | 1 - 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts index 11ce61a9bb..ff71086a35 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts @@ -27,10 +27,10 @@ export interface SharedStore extends Store.Store { flowName, flowStatus, }: { - id: string; - flow: Store.flow; - flowSlug: string; - flowName: string; + id?: string; + flow?: Store.flow; + flowSlug?: string; + flowName?: string; flowStatus?: FlowStatus; }) => void; wasVisited: (id: Store.nodeId) => boolean; diff --git a/editor.planx.uk/src/routes/team.tsx b/editor.planx.uk/src/routes/team.tsx index 83ae2229b7..3a2994e767 100644 --- a/editor.planx.uk/src/routes/team.tsx +++ b/editor.planx.uk/src/routes/team.tsx @@ -1,5 +1,15 @@ +import { FlowGraph } from "@opensystemslab/planx-core/types"; +import axios from "axios"; import gql from "graphql-tag"; -import { compose, lazy, mount, route, withData, withView } from "navi"; +import { + compose, + lazy, + mount, + NotFoundError, + route, + withData, + withView, +} from "navi"; import React from "react"; import { client } from "../lib/graphql"; @@ -66,8 +76,16 @@ const routes = compose( }); } - useStore.getState().setFlowSlug(slug); - useStore.getState().setFlowName(flow.name); + const stateFlowID = useStore.getState().id; + + const flowData = await fetchDraftFlattenedFlowData(flow.id); + + useStore.getState().setFlow({ + id: stateFlowID, + flow: flowData, + flowName: flow.name, + flowSlug: slug, + }); await useStore.getState().connectTo(flow.id); } @@ -78,4 +96,17 @@ const routes = compose( }), ); +const fetchDraftFlattenedFlowData = async ( + flowId: string, +): Promise => { + const url = `${process.env.REACT_APP_API_URL}/flows/${flowId}/flatten-data?draft=true`; + try { + const { data } = await axios.get(url); + return data; + } catch (error) { + console.log(error); + throw new NotFoundError(); + } +}; + export default routes; diff --git a/editor.planx.uk/src/routes/views/preview.tsx b/editor.planx.uk/src/routes/views/preview.tsx index c9514004cb..95ee2ff145 100644 --- a/editor.planx.uk/src/routes/views/preview.tsx +++ b/editor.planx.uk/src/routes/views/preview.tsx @@ -29,7 +29,6 @@ export const previewView = async (req: NaviRequest) => { const state = useStore.getState(); state.setFlow({ id: flow.id, flow: flowData, flowSlug, flowName: flow.name }); - state.setFlowName(flow.name); state.setGlobalSettings(data.globalSettings[0]); state.setFlowSettings(flow.settings); state.setTeam(flow.team); From 2ddec9617ea53dcde0025a3831d64b0d55751a9f Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 4 Jun 2024 15:10:05 +0100 Subject: [PATCH 09/33] remove setFlowName and a console.log --- editor.planx.uk/src/routes/views/draft.tsx | 1 - editor.planx.uk/src/routes/views/standalone.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/editor.planx.uk/src/routes/views/draft.tsx b/editor.planx.uk/src/routes/views/draft.tsx index 4bfbb1fbe4..9f1d6a2570 100644 --- a/editor.planx.uk/src/routes/views/draft.tsx +++ b/editor.planx.uk/src/routes/views/draft.tsx @@ -33,7 +33,6 @@ export const draftView = async (req: NaviRequest) => { const state = useStore.getState(); state.setFlow({ id: flow.id, flow: flowData, flowSlug, flowName: flow.name }); - state.setFlowName(flow.name); state.setGlobalSettings(data.globalSettings[0]); state.setFlowSettings(flow.settings); state.setTeam(flow.team); diff --git a/editor.planx.uk/src/routes/views/standalone.tsx b/editor.planx.uk/src/routes/views/standalone.tsx index 8a9817795f..5212c41b38 100644 --- a/editor.planx.uk/src/routes/views/standalone.tsx +++ b/editor.planx.uk/src/routes/views/standalone.tsx @@ -28,7 +28,6 @@ const standaloneView = async (req: NaviRequest) => { flows: [{ name, team, settings: flowSettings }], globalSettings, } = data; - console.log(data); const state = useStore.getState(); state.setFlowName(data.flows[0].name); state.setGlobalSettings(globalSettings[0]); From fb2ff5e2a3c165d1f55216d0640f021ede30606a Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 4 Jun 2024 15:14:31 +0100 Subject: [PATCH 10/33] console log removal --- editor.planx.uk/src/routes/views/draft.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/editor.planx.uk/src/routes/views/draft.tsx b/editor.planx.uk/src/routes/views/draft.tsx index 9f1d6a2570..5860824a5f 100644 --- a/editor.planx.uk/src/routes/views/draft.tsx +++ b/editor.planx.uk/src/routes/views/draft.tsx @@ -37,8 +37,6 @@ export const draftView = async (req: NaviRequest) => { state.setFlowSettings(flow.settings); state.setTeam(flow.team); - console.log(flow.name); - return ( From da2966c4ff6afb940beb1747eab723485975340e Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 5 Jun 2024 14:33:44 +0100 Subject: [PATCH 11/33] removing console logs --- editor.planx.uk/src/@planx/components/Pay/Editor.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/Pay/Editor.tsx b/editor.planx.uk/src/@planx/components/Pay/Editor.tsx index 18e5631c18..423d37a44e 100644 --- a/editor.planx.uk/src/@planx/components/Pay/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Pay/Editor.tsx @@ -137,7 +137,6 @@ export type Props = EditorProps; const Component: React.FC = (props: Props) => { const [flowName] = useStore((store) => [store.flowName]); - console.log(flowName); const initialValues: Pay = { title: props.node?.data?.title || "Pay for your application", bannerTitle: @@ -189,8 +188,6 @@ const Component: React.FC = (props: Props) => { } }; - console.log(flowName); - return ( initialValues={initialValues} From 40035cd75252394e548b97224f2c2714ef7cda62 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Mon, 10 Jun 2024 09:30:44 +0100 Subject: [PATCH 12/33] rever team changes to individually update global store --- editor.planx.uk/src/routes/team.tsx | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/editor.planx.uk/src/routes/team.tsx b/editor.planx.uk/src/routes/team.tsx index 3a2994e767..2d956b14a6 100644 --- a/editor.planx.uk/src/routes/team.tsx +++ b/editor.planx.uk/src/routes/team.tsx @@ -76,16 +76,8 @@ const routes = compose( }); } - const stateFlowID = useStore.getState().id; - - const flowData = await fetchDraftFlattenedFlowData(flow.id); - - useStore.getState().setFlow({ - id: stateFlowID, - flow: flowData, - flowName: flow.name, - flowSlug: slug, - }); + useStore.getState().setFlowName(flow.name); + useStore.getState().setFlowSlug(slug); await useStore.getState().connectTo(flow.id); } @@ -96,17 +88,4 @@ const routes = compose( }), ); -const fetchDraftFlattenedFlowData = async ( - flowId: string, -): Promise => { - const url = `${process.env.REACT_APP_API_URL}/flows/${flowId}/flatten-data?draft=true`; - try { - const { data } = await axios.get(url); - return data; - } catch (error) { - console.log(error); - throw new NotFoundError(); - } -}; - export default routes; From d093df0e0ec160890ae27a48c62af7092d2b5ff8 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Mon, 10 Jun 2024 13:44:34 +0100 Subject: [PATCH 13/33] attempt: add flowName to flow context in e2e testing --- e2e/tests/api-driven/src/permissions/queries/flows.ts | 2 +- e2e/tests/ui-driven/src/context.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/e2e/tests/api-driven/src/permissions/queries/flows.ts b/e2e/tests/api-driven/src/permissions/queries/flows.ts index 9db7a43379..4f2215939b 100644 --- a/e2e/tests/api-driven/src/permissions/queries/flows.ts +++ b/e2e/tests/api-driven/src/permissions/queries/flows.ts @@ -16,7 +16,7 @@ export const UPDATE_FLOW_QUERY = gql` mutation UpdateFlowE2E($team1FlowId: uuid!) { result: update_flows_by_pk( pk_columns: { id: $team1FlowId } - _set: { slug: "new-slug" } + _set: { slug: "new-slug", name: "new Name" } ) { id } diff --git a/e2e/tests/ui-driven/src/context.ts b/e2e/tests/ui-driven/src/context.ts index b9369b6e02..13743a157b 100644 --- a/e2e/tests/ui-driven/src/context.ts +++ b/e2e/tests/ui-driven/src/context.ts @@ -25,6 +25,7 @@ export interface Context { id?: string; publishedId?: number; slug: string; + name?:string; data?: object; }; sessionIds?: string[]; @@ -67,11 +68,13 @@ export async function setUpTestContext( if ( context.flow?.slug && context.flow?.data && + context.flow?.name && context.team?.id && context.user?.id ) { context.flow.id = await $admin.flow.create({ slug: context.flow.slug, + name: context.flow.name, teamId: context.team.id, data: context.flow!.data!, status: "online", @@ -167,6 +170,7 @@ export async function findSessionId( limit: 1 ) { id + name } } `, From d0aec62902a52221f876e73f62070a6ebdabd85e Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Mon, 10 Jun 2024 14:11:04 +0100 Subject: [PATCH 14/33] add planx-core latest commit hash --- api.planx.uk/package.json | 2 +- e2e/tests/api-driven/package.json | 2 +- e2e/tests/ui-driven/package.json | 2 +- editor.planx.uk/package.json | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api.planx.uk/package.json b/api.planx.uk/package.json index 38ec0ab6de..d089ee7276 100644 --- a/api.planx.uk/package.json +++ b/api.planx.uk/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "@airbrake/node": "^2.1.8", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#60b2ec7", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#5b8c840", "@types/isomorphic-fetch": "^0.0.36", "adm-zip": "^0.5.10", "aws-sdk": "^2.1467.0", diff --git a/e2e/tests/api-driven/package.json b/e2e/tests/api-driven/package.json index c0ae3c9cb8..92eaafff95 100644 --- a/e2e/tests/api-driven/package.json +++ b/e2e/tests/api-driven/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@cucumber/cucumber": "^9.3.0", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#60b2ec7", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#5b8c840", "axios": "^1.6.8", "dotenv": "^16.3.1", "dotenv-expand": "^10.0.0", diff --git a/e2e/tests/ui-driven/package.json b/e2e/tests/ui-driven/package.json index 4b957fec96..30cf3a65b1 100644 --- a/e2e/tests/ui-driven/package.json +++ b/e2e/tests/ui-driven/package.json @@ -8,7 +8,7 @@ "postinstall": "./install-dependencies.sh" }, "dependencies": { - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#60b2ec7", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#5b8c840", "axios": "^1.6.8", "dotenv": "^16.3.1", "eslint": "^8.56.0", diff --git a/editor.planx.uk/package.json b/editor.planx.uk/package.json index 89af7f88c9..38c0449911 100644 --- a/editor.planx.uk/package.json +++ b/editor.planx.uk/package.json @@ -13,7 +13,7 @@ "@mui/material": "^5.15.2", "@mui/utils": "^5.15.2", "@opensystemslab/map": "^0.8.2", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#60b2ec7", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#5b8c840", "@tiptap/core": "^2.4.0", "@tiptap/extension-bold": "^2.0.3", "@tiptap/extension-bubble-menu": "^2.1.13", @@ -222,4 +222,4 @@ "follow-redirects@<1.15.4": ">=1.15.4" } } -} \ No newline at end of file +} From 32a3998cc657c47b71c19a873d4dab3008a7cfcb Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Mon, 10 Jun 2024 14:23:52 +0100 Subject: [PATCH 15/33] update create flow functions to include test flowName --- e2e/tests/api-driven/src/invite-to-pay/helpers.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/tests/api-driven/src/invite-to-pay/helpers.ts b/e2e/tests/api-driven/src/invite-to-pay/helpers.ts index 302be5dd57..4a856b1b77 100644 --- a/e2e/tests/api-driven/src/invite-to-pay/helpers.ts +++ b/e2e/tests/api-driven/src/invite-to-pay/helpers.ts @@ -45,6 +45,7 @@ export async function buildITPFlow({ const flowId: string = await $admin.flow.create({ teamId, slug: `test-invite-to-pay-flow-with-send-to-${destination.toLowerCase()}`, + name: `Test invite to pay flow with send to ${destination}`, status: "online", data: flowGraph, }); From a986712937c038a09d425704b136d84a1c92e8ab Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Mon, 10 Jun 2024 14:31:52 +0100 Subject: [PATCH 16/33] install new dependencies from planx-core changes --- api.planx.uk/pnpm-lock.yaml | 40 ++++++++++------------ e2e/tests/api-driven/pnpm-lock.yaml | 40 ++++++++++------------ e2e/tests/ui-driven/pnpm-lock.yaml | 40 ++++++++++------------ editor.planx.uk/pnpm-lock.yaml | 51 ++++++++++++++++++++++------- 4 files changed, 93 insertions(+), 78 deletions(-) diff --git a/api.planx.uk/pnpm-lock.yaml b/api.planx.uk/pnpm-lock.yaml index 89ec048f12..91194d1167 100644 --- a/api.planx.uk/pnpm-lock.yaml +++ b/api.planx.uk/pnpm-lock.yaml @@ -12,8 +12,8 @@ dependencies: specifier: ^2.1.8 version: 2.1.8 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#9bebbd9 - version: github.com/theopensystemslab/planx-core/9bebbd9 + specifier: git+https://github.com/theopensystemslab/planx-core#5b8c840 + version: github.com/theopensystemslab/planx-core/5b8c840 '@types/isomorphic-fetch': specifier: ^0.0.36 version: 0.0.36 @@ -2324,7 +2324,7 @@ packages: - supports-color dev: false - /ajv-formats@2.1.1(ajv@8.15.0): + /ajv-formats@2.1.1(ajv@8.16.0): resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==} peerDependencies: ajv: ^8.0.0 @@ -2332,7 +2332,7 @@ packages: ajv: optional: true dependencies: - ajv: 8.15.0 + ajv: 8.16.0 dev: false /ajv@6.12.6: @@ -2343,13 +2343,13 @@ packages: json-schema-traverse: 0.4.1 uri-js: 4.4.1 - /ajv@8.15.0: - resolution: {integrity: sha512-15BTtQUOsSrmHCy+B4VnAiJAJxJ8IFgu6fcjFQF3jQYZ78nLSQthlFg4ehp+NLIyfvFgOlxNsjKIEhydtFPVHQ==} + /ajv@8.16.0: + resolution: {integrity: sha512-F0twR8U1ZU67JIEtekUcLkXkoO5mMMmgGD8sK/xUFzJ805jxHQl92hImFAqqXMyMYjSPOyUPAwHYhB72g5sTXw==} dependencies: fast-deep-equal: 3.1.3 - fast-uri: 2.3.0 json-schema-traverse: 1.0.0 require-from-string: 2.0.2 + uri-js: 4.4.1 dev: false /ansi-escapes@4.3.2: @@ -4100,10 +4100,6 @@ packages: resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==} dev: true - /fast-uri@2.3.0: - resolution: {integrity: sha512-eel5UKGn369gGEWOqBShmFJWfq/xSJvsgDzgLYC845GneayWvXBf0lJCBn5qTABfewy1ZDPoaR5OZCP+kssfuw==} - dev: false - /fast-url-parser@1.1.3: resolution: {integrity: sha512-5jOCVXADYNuRkKFzNJ0dCCewsZiYo0dz8QNYljkOpFC6r2U4OBmKtvm/Tsuh4w1YYdDqDb31a8TVhBJ2OJKdqQ==} dependencies: @@ -5623,7 +5619,7 @@ packages: mkdirp: 3.0.1 mz: 2.7.0 node-fetch: 3.3.2 - prettier: 3.3.0 + prettier: 3.3.1 dev: false /json-schema-traverse@0.4.1: @@ -6674,8 +6670,8 @@ packages: hasBin: true dev: true - /prettier@3.3.0: - resolution: {integrity: sha512-J9odKxERhCQ10OC2yb93583f6UnYutOeiV5i0zEDS7UGTdUt0u+y8erxl3lBKvwo/JHyyoEdXjwp4dke9oyZ/g==} + /prettier@3.3.1: + resolution: {integrity: sha512-7CAwy5dRsxs8PHXT3twixW9/OEll8MLE0VRPCJyl7CkS6VHGPSlsVaWTiASPTyGyYRyApxlaWTzwUxVNrhcwDg==} engines: {node: '>=14'} hasBin: true dev: false @@ -7875,8 +7871,8 @@ packages: engines: {node: '>=16'} dev: false - /type-fest@4.18.3: - resolution: {integrity: sha512-Q08/0IrpvM+NMY9PA2rti9Jb+JejTddwmwmVQGskAlhtcrw1wsRzoR6ode6mR+OAabNa75w/dxedSUY2mlphaQ==} + /type-fest@4.20.0: + resolution: {integrity: sha512-MBh+PHUHHisjXf4tlx0CFWoMdjx8zCMLJHOjnV1prABYZFHqtFOyauCIK2/7w4oIfwkF8iNhLtnJEfVY2vn3iw==} engines: {node: '>=16'} dev: false @@ -8305,8 +8301,8 @@ packages: resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} dev: false - github.com/theopensystemslab/planx-core/9bebbd9: - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/9bebbd9} + github.com/theopensystemslab/planx-core/5b8c840: + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/5b8c840} name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true @@ -8316,8 +8312,8 @@ packages: '@emotion/styled': 11.11.5(@emotion/react@11.11.4)(react@18.3.1) '@mui/material': 5.15.18(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(react-dom@18.3.1)(react@18.3.1) '@types/geojson': 7946.0.14 - ajv: 8.15.0 - ajv-formats: 2.1.1(ajv@8.15.0) + ajv: 8.16.0 + ajv-formats: 2.1.1(ajv@8.16.0) cheerio: 1.0.0-rc.12 copyfiles: 2.4.1 docx: 8.5.0 @@ -8328,10 +8324,10 @@ packages: json-schema-to-typescript: 14.0.5 lodash: 4.17.21 marked: 12.0.2 - prettier: 3.3.0 + prettier: 3.3.1 react: 18.3.1 react-dom: 18.3.1(react@18.3.1) - type-fest: 4.18.3 + type-fest: 4.20.0 uuid: 9.0.1 zod: 3.23.8 transitivePeerDependencies: diff --git a/e2e/tests/api-driven/pnpm-lock.yaml b/e2e/tests/api-driven/pnpm-lock.yaml index 6725026776..7e5cbd89a9 100644 --- a/e2e/tests/api-driven/pnpm-lock.yaml +++ b/e2e/tests/api-driven/pnpm-lock.yaml @@ -9,8 +9,8 @@ dependencies: specifier: ^9.3.0 version: 9.3.0 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#9bebbd9 - version: github.com/theopensystemslab/planx-core/9bebbd9 + specifier: git+https://github.com/theopensystemslab/planx-core#5b8c840 + version: github.com/theopensystemslab/planx-core/5b8c840 axios: specifier: ^1.6.8 version: 1.6.8 @@ -780,7 +780,7 @@ packages: engines: {node: '>=0.4.0'} hasBin: true - /ajv-formats@2.1.1(ajv@8.15.0): + /ajv-formats@2.1.1(ajv@8.16.0): resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==} peerDependencies: ajv: ^8.0.0 @@ -788,7 +788,7 @@ packages: ajv: optional: true dependencies: - ajv: 8.15.0 + ajv: 8.16.0 dev: false /ajv@6.12.6: @@ -800,13 +800,13 @@ packages: uri-js: 4.4.1 dev: false - /ajv@8.15.0: - resolution: {integrity: sha512-15BTtQUOsSrmHCy+B4VnAiJAJxJ8IFgu6fcjFQF3jQYZ78nLSQthlFg4ehp+NLIyfvFgOlxNsjKIEhydtFPVHQ==} + /ajv@8.16.0: + resolution: {integrity: sha512-F0twR8U1ZU67JIEtekUcLkXkoO5mMMmgGD8sK/xUFzJ805jxHQl92hImFAqqXMyMYjSPOyUPAwHYhB72g5sTXw==} dependencies: fast-deep-equal: 3.1.3 - fast-uri: 2.3.0 json-schema-traverse: 1.0.0 require-from-string: 2.0.2 + uri-js: 4.4.1 dev: false /ansi-regex@4.1.1: @@ -1454,10 +1454,6 @@ packages: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} dev: false - /fast-uri@2.3.0: - resolution: {integrity: sha512-eel5UKGn369gGEWOqBShmFJWfq/xSJvsgDzgLYC845GneayWvXBf0lJCBn5qTABfewy1ZDPoaR5OZCP+kssfuw==} - dev: false - /fast-xml-parser@4.4.0: resolution: {integrity: sha512-kLY3jFlwIYwBNDojclKsNAC12sfD6NwW74QB2CoNGPvtVxjliYehVunB3HYyNi+n4Tt1dAcgwYvmKF/Z18flqg==} hasBin: true @@ -1829,7 +1825,7 @@ packages: mkdirp: 3.0.1 mz: 2.7.0 node-fetch: 3.3.2 - prettier: 3.3.0 + prettier: 3.3.1 dev: false /json-schema-traverse@0.4.1: @@ -2292,8 +2288,8 @@ packages: engines: {node: '>= 0.8.0'} dev: false - /prettier@3.3.0: - resolution: {integrity: sha512-J9odKxERhCQ10OC2yb93583f6UnYutOeiV5i0zEDS7UGTdUt0u+y8erxl3lBKvwo/JHyyoEdXjwp4dke9oyZ/g==} + /prettier@3.3.1: + resolution: {integrity: sha512-7CAwy5dRsxs8PHXT3twixW9/OEll8MLE0VRPCJyl7CkS6VHGPSlsVaWTiASPTyGyYRyApxlaWTzwUxVNrhcwDg==} engines: {node: '>=14'} hasBin: true dev: false @@ -2736,8 +2732,8 @@ packages: engines: {node: '>=10'} dev: false - /type-fest@4.18.3: - resolution: {integrity: sha512-Q08/0IrpvM+NMY9PA2rti9Jb+JejTddwmwmVQGskAlhtcrw1wsRzoR6ode6mR+OAabNa75w/dxedSUY2mlphaQ==} + /type-fest@4.20.0: + resolution: {integrity: sha512-MBh+PHUHHisjXf4tlx0CFWoMdjx8zCMLJHOjnV1prABYZFHqtFOyauCIK2/7w4oIfwkF8iNhLtnJEfVY2vn3iw==} engines: {node: '>=16'} dev: false @@ -2940,8 +2936,8 @@ packages: resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} dev: false - github.com/theopensystemslab/planx-core/9bebbd9: - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/9bebbd9} + github.com/theopensystemslab/planx-core/5b8c840: + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/5b8c840} name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true @@ -2951,8 +2947,8 @@ packages: '@emotion/styled': 11.11.5(@emotion/react@11.11.4)(react@18.3.1) '@mui/material': 5.15.18(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(react-dom@18.3.1)(react@18.3.1) '@types/geojson': 7946.0.14 - ajv: 8.15.0 - ajv-formats: 2.1.1(ajv@8.15.0) + ajv: 8.16.0 + ajv-formats: 2.1.1(ajv@8.16.0) cheerio: 1.0.0-rc.12 copyfiles: 2.4.1 docx: 8.5.0 @@ -2963,10 +2959,10 @@ packages: json-schema-to-typescript: 14.0.5 lodash: 4.17.21 marked: 12.0.2 - prettier: 3.3.0 + prettier: 3.3.1 react: 18.3.1 react-dom: 18.3.1(react@18.3.1) - type-fest: 4.18.3 + type-fest: 4.20.0 uuid: 9.0.1 zod: 3.23.8 transitivePeerDependencies: diff --git a/e2e/tests/ui-driven/pnpm-lock.yaml b/e2e/tests/ui-driven/pnpm-lock.yaml index f7521951db..23b37e734a 100644 --- a/e2e/tests/ui-driven/pnpm-lock.yaml +++ b/e2e/tests/ui-driven/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#9bebbd9 - version: github.com/theopensystemslab/planx-core/9bebbd9 + specifier: git+https://github.com/theopensystemslab/planx-core#5b8c840 + version: github.com/theopensystemslab/planx-core/5b8c840 axios: specifier: ^1.6.8 version: 1.6.8 @@ -601,7 +601,7 @@ packages: engines: {node: '>=0.4.0'} hasBin: true - /ajv-formats@2.1.1(ajv@8.15.0): + /ajv-formats@2.1.1(ajv@8.16.0): resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==} peerDependencies: ajv: ^8.0.0 @@ -609,7 +609,7 @@ packages: ajv: optional: true dependencies: - ajv: 8.15.0 + ajv: 8.16.0 dev: false /ajv@6.12.6: @@ -629,13 +629,13 @@ packages: uri-js: 4.4.1 dev: false - /ajv@8.15.0: - resolution: {integrity: sha512-15BTtQUOsSrmHCy+B4VnAiJAJxJ8IFgu6fcjFQF3jQYZ78nLSQthlFg4ehp+NLIyfvFgOlxNsjKIEhydtFPVHQ==} + /ajv@8.16.0: + resolution: {integrity: sha512-F0twR8U1ZU67JIEtekUcLkXkoO5mMMmgGD8sK/xUFzJ805jxHQl92hImFAqqXMyMYjSPOyUPAwHYhB72g5sTXw==} dependencies: fast-deep-equal: 3.1.3 - fast-uri: 2.3.0 json-schema-traverse: 1.0.0 require-from-string: 2.0.2 + uri-js: 4.4.1 dev: false /ansi-align@3.0.1: @@ -1348,10 +1348,6 @@ packages: /fast-levenshtein@2.0.6: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} - /fast-uri@2.3.0: - resolution: {integrity: sha512-eel5UKGn369gGEWOqBShmFJWfq/xSJvsgDzgLYC845GneayWvXBf0lJCBn5qTABfewy1ZDPoaR5OZCP+kssfuw==} - dev: false - /fast-url-parser@1.1.3: resolution: {integrity: sha512-5jOCVXADYNuRkKFzNJ0dCCewsZiYo0dz8QNYljkOpFC6r2U4OBmKtvm/Tsuh4w1YYdDqDb31a8TVhBJ2OJKdqQ==} dependencies: @@ -1707,7 +1703,7 @@ packages: mkdirp: 3.0.1 mz: 2.7.0 node-fetch: 3.3.2 - prettier: 3.3.0 + prettier: 3.3.1 dev: false /json-schema-traverse@0.4.1: @@ -2149,8 +2145,8 @@ packages: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} - /prettier@3.3.0: - resolution: {integrity: sha512-J9odKxERhCQ10OC2yb93583f6UnYutOeiV5i0zEDS7UGTdUt0u+y8erxl3lBKvwo/JHyyoEdXjwp4dke9oyZ/g==} + /prettier@3.3.1: + resolution: {integrity: sha512-7CAwy5dRsxs8PHXT3twixW9/OEll8MLE0VRPCJyl7CkS6VHGPSlsVaWTiASPTyGyYRyApxlaWTzwUxVNrhcwDg==} engines: {node: '>=14'} hasBin: true dev: false @@ -2533,8 +2529,8 @@ packages: engines: {node: '>=12.20'} dev: false - /type-fest@4.18.3: - resolution: {integrity: sha512-Q08/0IrpvM+NMY9PA2rti9Jb+JejTddwmwmVQGskAlhtcrw1wsRzoR6ode6mR+OAabNa75w/dxedSUY2mlphaQ==} + /type-fest@4.20.0: + resolution: {integrity: sha512-MBh+PHUHHisjXf4tlx0CFWoMdjx8zCMLJHOjnV1prABYZFHqtFOyauCIK2/7w4oIfwkF8iNhLtnJEfVY2vn3iw==} engines: {node: '>=16'} dev: false @@ -2688,8 +2684,8 @@ packages: resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} dev: false - github.com/theopensystemslab/planx-core/9bebbd9: - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/9bebbd9} + github.com/theopensystemslab/planx-core/5b8c840: + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/5b8c840} name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true @@ -2699,8 +2695,8 @@ packages: '@emotion/styled': 11.11.5(@emotion/react@11.11.4)(react@18.3.1) '@mui/material': 5.15.18(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(react-dom@18.3.1)(react@18.3.1) '@types/geojson': 7946.0.14 - ajv: 8.15.0 - ajv-formats: 2.1.1(ajv@8.15.0) + ajv: 8.16.0 + ajv-formats: 2.1.1(ajv@8.16.0) cheerio: 1.0.0-rc.12 copyfiles: 2.4.1 docx: 8.5.0 @@ -2711,10 +2707,10 @@ packages: json-schema-to-typescript: 14.0.5 lodash: 4.17.21 marked: 12.0.2 - prettier: 3.3.0 + prettier: 3.3.1 react: 18.3.1 react-dom: 18.3.1(react@18.3.1) - type-fest: 4.18.3 + type-fest: 4.20.0 uuid: 9.0.1 zod: 3.23.8 transitivePeerDependencies: diff --git a/editor.planx.uk/pnpm-lock.yaml b/editor.planx.uk/pnpm-lock.yaml index 03374bfb2c..0c82366c43 100644 --- a/editor.planx.uk/pnpm-lock.yaml +++ b/editor.planx.uk/pnpm-lock.yaml @@ -41,8 +41,8 @@ dependencies: specifier: ^0.8.2 version: 0.8.2 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#9bebbd9 - version: github.com/theopensystemslab/planx-core/9bebbd9(@types/react@18.2.45) + specifier: git+https://github.com/theopensystemslab/planx-core#5b8c840 + version: github.com/theopensystemslab/planx-core/5b8c840(@types/react@18.2.45) '@tiptap/core': specifier: ^2.4.0 version: 2.4.0(@tiptap/pm@2.0.3) @@ -8970,6 +8970,17 @@ packages: dependencies: ajv: 8.15.0 + /ajv-formats@2.1.1(ajv@8.16.0): + resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==} + peerDependencies: + ajv: ^8.0.0 + peerDependenciesMeta: + ajv: + optional: true + dependencies: + ajv: 8.16.0 + dev: false + /ajv-keywords@3.5.2(ajv@6.12.6): resolution: {integrity: sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==} peerDependencies: @@ -9001,6 +9012,15 @@ packages: json-schema-traverse: 1.0.0 require-from-string: 2.0.2 + /ajv@8.16.0: + resolution: {integrity: sha512-F0twR8U1ZU67JIEtekUcLkXkoO5mMMmgGD8sK/xUFzJ805jxHQl92hImFAqqXMyMYjSPOyUPAwHYhB72g5sTXw==} + dependencies: + fast-deep-equal: 3.1.3 + json-schema-traverse: 1.0.0 + require-from-string: 2.0.2 + uri-js: 4.4.1 + dev: false + /ansi-escapes@4.3.2: resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} engines: {node: '>=8'} @@ -14901,7 +14921,7 @@ packages: mkdirp: 3.0.1 mz: 2.7.0 node-fetch: 3.3.2 - prettier: 3.3.0 + prettier: 3.3.1 dev: false /json-schema-traverse@0.4.1: @@ -17442,6 +17462,13 @@ packages: resolution: {integrity: sha512-J9odKxERhCQ10OC2yb93583f6UnYutOeiV5i0zEDS7UGTdUt0u+y8erxl3lBKvwo/JHyyoEdXjwp4dke9oyZ/g==} engines: {node: '>=14'} hasBin: true + dev: true + + /prettier@3.3.1: + resolution: {integrity: sha512-7CAwy5dRsxs8PHXT3twixW9/OEll8MLE0VRPCJyl7CkS6VHGPSlsVaWTiASPTyGyYRyApxlaWTzwUxVNrhcwDg==} + engines: {node: '>=14'} + hasBin: true + dev: false /pretty-bytes@5.6.0: resolution: {integrity: sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==} @@ -20431,8 +20458,8 @@ packages: engines: {node: '>=16'} dev: false - /type-fest@4.18.3: - resolution: {integrity: sha512-Q08/0IrpvM+NMY9PA2rti9Jb+JejTddwmwmVQGskAlhtcrw1wsRzoR6ode6mR+OAabNa75w/dxedSUY2mlphaQ==} + /type-fest@4.20.0: + resolution: {integrity: sha512-MBh+PHUHHisjXf4tlx0CFWoMdjx8zCMLJHOjnV1prABYZFHqtFOyauCIK2/7w4oIfwkF8iNhLtnJEfVY2vn3iw==} engines: {node: '>=16'} dev: false @@ -21605,9 +21632,9 @@ packages: use-sync-external-store: 1.2.0(react@18.2.0) dev: false - github.com/theopensystemslab/planx-core/9bebbd9(@types/react@18.2.45): - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/9bebbd9} - id: github.com/theopensystemslab/planx-core/9bebbd9 + github.com/theopensystemslab/planx-core/5b8c840(@types/react@18.2.45): + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/5b8c840} + id: github.com/theopensystemslab/planx-core/5b8c840 name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true @@ -21617,8 +21644,8 @@ packages: '@emotion/styled': 11.11.5(@emotion/react@11.11.4)(@types/react@18.2.45)(react@18.3.1) '@mui/material': 5.15.2(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(@types/react@18.2.45)(react-dom@18.3.1)(react@18.3.1) '@types/geojson': 7946.0.14 - ajv: 8.15.0 - ajv-formats: 2.1.1(ajv@8.15.0) + ajv: 8.16.0 + ajv-formats: 2.1.1(ajv@8.16.0) cheerio: 1.0.0-rc.12 copyfiles: 2.4.1 docx: 8.5.0 @@ -21629,10 +21656,10 @@ packages: json-schema-to-typescript: 14.0.5 lodash: 4.17.21 marked: 12.0.2 - prettier: 3.3.0 + prettier: 3.3.1 react: 18.3.1 react-dom: 18.3.1(react@18.3.1) - type-fest: 4.18.3 + type-fest: 4.20.0 uuid: 9.0.1 zod: 3.23.8 transitivePeerDependencies: From e3cc2ff2fd3129bd37479475625b44ebc70ae5ab Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Mon, 10 Jun 2024 14:41:03 +0100 Subject: [PATCH 17/33] fix: add name variable for create flow calls --- e2e/tests/api-driven/src/flowStatusHistory/steps.ts | 2 +- e2e/tests/api-driven/src/permissions/helpers.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/e2e/tests/api-driven/src/flowStatusHistory/steps.ts b/e2e/tests/api-driven/src/flowStatusHistory/steps.ts index af93d5a3f0..a42736b6e7 100644 --- a/e2e/tests/api-driven/src/flowStatusHistory/steps.ts +++ b/e2e/tests/api-driven/src/flowStatusHistory/steps.ts @@ -19,7 +19,7 @@ Before("@flow-status-history", async function () { }); Given("a flow exists", async function () { - const flowId = await createFlow({ teamId: this.teamId, slug: "test-flow" }); + const flowId = await createFlow({ teamId: this.teamId, slug: "test-flow", name:"Test Flow" }); assert.ok(flowId, "flowId is not defined"); diff --git a/e2e/tests/api-driven/src/permissions/helpers.ts b/e2e/tests/api-driven/src/permissions/helpers.ts index c191c0cfd9..94b669c4f3 100644 --- a/e2e/tests/api-driven/src/permissions/helpers.ts +++ b/e2e/tests/api-driven/src/permissions/helpers.ts @@ -35,6 +35,7 @@ export const setup = async () => { const team1FlowId = await createFlow({ teamId: teamId1, slug: "team-1-flow", + name: "Team 1 Flow" }); const user2Id = await createUser({ @@ -44,6 +45,8 @@ export const setup = async () => { const team2FlowId = await createFlow({ teamId: teamId2, slug: "team-2-flow", + name: "Team 2 Flow" + }); const world = { From 79162a3c532a6fefd307288ab4ed3078f1d6bc56 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 11 Jun 2024 09:38:58 +0100 Subject: [PATCH 18/33] format change --- e2e/tests/ui-driven/src/context.ts | 50 +++++++++++++++--------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/e2e/tests/ui-driven/src/context.ts b/e2e/tests/ui-driven/src/context.ts index 13743a157b..9fe467e513 100644 --- a/e2e/tests/ui-driven/src/context.ts +++ b/e2e/tests/ui-driven/src/context.ts @@ -25,7 +25,7 @@ export interface Context { id?: string; publishedId?: number; slug: string; - name?:string; + name?: string; data?: object; }; sessionIds?: string[]; @@ -49,7 +49,7 @@ export const contextDefaults: Context = { }; export async function setUpTestContext( - initialContext: Context, + initialContext: Context ): Promise { const $admin = getCoreDomainClient(); const context: Context = { ...initialContext }; @@ -68,7 +68,7 @@ export async function setUpTestContext( if ( context.flow?.slug && context.flow?.data && - context.flow?.name && + context.flow?.name && context.team?.id && context.user?.id ) { @@ -118,7 +118,7 @@ export function generateAuthenticationToken(userId: string) { "x-hasura-user-id": `${userId}`, }, }, - process.env.JWT_SECRET, + process.env.JWT_SECRET ); } @@ -128,7 +128,7 @@ export function getCoreDomainClient(): CoreDomainClient { const API = process.env.HASURA_GRAPHQL_URL!.replace( "${HASURA_PROXY_PORT}", - process.env.HASURA_PROXY_PORT!, + process.env.HASURA_PROXY_PORT! ); const SECRET = process.env.HASURA_GRAPHQL_ADMIN_SECRET!; return new CoreDomainClient({ @@ -143,7 +143,7 @@ export function getGraphQLClient(): GraphQLClient { export async function findSessionId( adminGQLClient: GraphQLClient, - context, + context ): Promise { // get the flow id which may have a session const flowResponse: { flows: { id: string }[] } = @@ -153,7 +153,7 @@ export async function findSessionId( id } }`, - { slug: context.flow?.slug }, + { slug: context.flow?.slug } ); if (!flowResponse.flows.length || !flowResponse.flows[0].id) { return; @@ -174,7 +174,7 @@ export async function findSessionId( } } `, - { flowId, email: context.user?.email }, + { flowId, email: context.user?.email } ); if (response.lowcal_sessions.length && response.lowcal_sessions[0].id) { return response.lowcal_sessions[0].id; @@ -190,7 +190,7 @@ async function deleteSession(adminGQLClient: GraphQLClient, context) { id } }`, - { sessionId }, + { sessionId } ); } } @@ -203,14 +203,14 @@ async function deleteSession(adminGQLClient: GraphQLClient, context) { id } }`, - { sessionId }, + { sessionId } ); } } async function deletePublishedFlow( adminGQLClient: GraphQLClient, - context: Context, + context: Context ) { if (context.flow?.publishedId) { log(`deleting published flow ${context.flow?.publishedId}`); @@ -220,7 +220,7 @@ async function deletePublishedFlow( id } }`, - { publishedFlowId: context.flow?.publishedId }, + { publishedFlowId: context.flow?.publishedId } ); } } @@ -234,7 +234,7 @@ async function deleteFlow(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { flowId: context.flow?.id }, + { flowId: context.flow?.id } ); } else if (context.flow?.slug) { // try deleting via slug (when cleaning up from a previously failed test) @@ -244,11 +244,11 @@ async function deleteFlow(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { slug: context.flow?.slug }, + { slug: context.flow?.slug } ); if (response.flows.length && response.flows[0].id) { log( - `deleting flow ${context.flow?.slug} flowId: ${response.flows[0].id}`, + `deleting flow ${context.flow?.slug} flowId: ${response.flows[0].id}` ); await adminGQLClient.request( `mutation DeleteTestFlow( $flowId: uuid!) { @@ -256,7 +256,7 @@ async function deleteFlow(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { flowId: response.flows[0].id }, + { flowId: response.flows[0].id } ); } } @@ -271,7 +271,7 @@ async function deleteUser(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { userId: context.user?.id }, + { userId: context.user?.id } ); } else if (context.user?.email) { // try deleting via email (when cleaning up from a previously failed test) @@ -281,11 +281,11 @@ async function deleteUser(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { email: context.user?.email }, + { email: context.user?.email } ); if (response.users.length && response.users[0].id) { log( - `deleting user ${context.user?.email} userId: ${response.users[0].id}`, + `deleting user ${context.user?.email} userId: ${response.users[0].id}` ); await adminGQLClient.request( `mutation DeleteTestUser($userId: Int!) { @@ -293,7 +293,7 @@ async function deleteUser(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { userId: response.users[0].id }, + { userId: response.users[0].id } ); } } @@ -308,7 +308,7 @@ async function deleteTeam(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { teamId: context.team?.id }, + { teamId: context.team?.id } ); } else if (context.team?.slug) { // try deleting via slug (when cleaning up from a previously failed test) @@ -318,11 +318,11 @@ async function deleteTeam(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { slug: context.team?.slug }, + { slug: context.team?.slug } ); if (response.teams.length && response.teams[0].id) { log( - `deleting team ${context.team?.slug} teamId: ${response.teams[0].id}`, + `deleting team ${context.team?.slug} teamId: ${response.teams[0].id}` ); await adminGQLClient.request( `mutation DeleteTestTeam( $teamId: Int!) { @@ -330,7 +330,7 @@ async function deleteTeam(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { teamId: response.teams[0].id }, + { teamId: response.teams[0].id } ); } } @@ -355,7 +355,7 @@ async function setupGovPaySecret($admin: CoreDomainClient, context: Context) { { team_id: context.team.id, staging_govpay_secret: process.env.GOV_UK_PAY_SECRET_E2E, - }, + } ); } catch (error) { throw Error("Failed to setup GovPay secret for E2E team"); From ca7b46fc829a8658eb300534d7569d4c6e362b2a Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 11 Jun 2024 10:05:52 +0100 Subject: [PATCH 19/33] prettier changes for e2e testing --- e2e/tests/api-driven/src/flowStatusHistory/steps.ts | 6 +++++- e2e/tests/api-driven/src/permissions/helpers.ts | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/e2e/tests/api-driven/src/flowStatusHistory/steps.ts b/e2e/tests/api-driven/src/flowStatusHistory/steps.ts index a42736b6e7..798c4e9b87 100644 --- a/e2e/tests/api-driven/src/flowStatusHistory/steps.ts +++ b/e2e/tests/api-driven/src/flowStatusHistory/steps.ts @@ -19,7 +19,11 @@ Before("@flow-status-history", async function () { }); Given("a flow exists", async function () { - const flowId = await createFlow({ teamId: this.teamId, slug: "test-flow", name:"Test Flow" }); + const flowId = await createFlow({ + teamId: this.teamId, + slug: "test-flow", + name: "Test Flow", + }); assert.ok(flowId, "flowId is not defined"); diff --git a/e2e/tests/api-driven/src/permissions/helpers.ts b/e2e/tests/api-driven/src/permissions/helpers.ts index 94b669c4f3..521523c540 100644 --- a/e2e/tests/api-driven/src/permissions/helpers.ts +++ b/e2e/tests/api-driven/src/permissions/helpers.ts @@ -35,7 +35,7 @@ export const setup = async () => { const team1FlowId = await createFlow({ teamId: teamId1, slug: "team-1-flow", - name: "Team 1 Flow" + name: "Team 1 Flow", }); const user2Id = await createUser({ @@ -45,8 +45,7 @@ export const setup = async () => { const team2FlowId = await createFlow({ teamId: teamId2, slug: "team-2-flow", - name: "Team 2 Flow" - + name: "Team 2 Flow", }); const world = { From 4a96a7b0b28e6cb1e6953bc75972a050cc8f113a Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 11 Jun 2024 10:12:01 +0100 Subject: [PATCH 20/33] extra prettier commit for missed files --- e2e/tests/ui-driven/src/context.ts | 46 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/e2e/tests/ui-driven/src/context.ts b/e2e/tests/ui-driven/src/context.ts index 9fe467e513..dacd6247ae 100644 --- a/e2e/tests/ui-driven/src/context.ts +++ b/e2e/tests/ui-driven/src/context.ts @@ -49,7 +49,7 @@ export const contextDefaults: Context = { }; export async function setUpTestContext( - initialContext: Context + initialContext: Context, ): Promise { const $admin = getCoreDomainClient(); const context: Context = { ...initialContext }; @@ -118,7 +118,7 @@ export function generateAuthenticationToken(userId: string) { "x-hasura-user-id": `${userId}`, }, }, - process.env.JWT_SECRET + process.env.JWT_SECRET, ); } @@ -128,7 +128,7 @@ export function getCoreDomainClient(): CoreDomainClient { const API = process.env.HASURA_GRAPHQL_URL!.replace( "${HASURA_PROXY_PORT}", - process.env.HASURA_PROXY_PORT! + process.env.HASURA_PROXY_PORT!, ); const SECRET = process.env.HASURA_GRAPHQL_ADMIN_SECRET!; return new CoreDomainClient({ @@ -143,7 +143,7 @@ export function getGraphQLClient(): GraphQLClient { export async function findSessionId( adminGQLClient: GraphQLClient, - context + context, ): Promise { // get the flow id which may have a session const flowResponse: { flows: { id: string }[] } = @@ -153,7 +153,7 @@ export async function findSessionId( id } }`, - { slug: context.flow?.slug } + { slug: context.flow?.slug }, ); if (!flowResponse.flows.length || !flowResponse.flows[0].id) { return; @@ -174,7 +174,7 @@ export async function findSessionId( } } `, - { flowId, email: context.user?.email } + { flowId, email: context.user?.email }, ); if (response.lowcal_sessions.length && response.lowcal_sessions[0].id) { return response.lowcal_sessions[0].id; @@ -190,7 +190,7 @@ async function deleteSession(adminGQLClient: GraphQLClient, context) { id } }`, - { sessionId } + { sessionId }, ); } } @@ -203,14 +203,14 @@ async function deleteSession(adminGQLClient: GraphQLClient, context) { id } }`, - { sessionId } + { sessionId }, ); } } async function deletePublishedFlow( adminGQLClient: GraphQLClient, - context: Context + context: Context, ) { if (context.flow?.publishedId) { log(`deleting published flow ${context.flow?.publishedId}`); @@ -220,7 +220,7 @@ async function deletePublishedFlow( id } }`, - { publishedFlowId: context.flow?.publishedId } + { publishedFlowId: context.flow?.publishedId }, ); } } @@ -234,7 +234,7 @@ async function deleteFlow(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { flowId: context.flow?.id } + { flowId: context.flow?.id }, ); } else if (context.flow?.slug) { // try deleting via slug (when cleaning up from a previously failed test) @@ -244,11 +244,11 @@ async function deleteFlow(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { slug: context.flow?.slug } + { slug: context.flow?.slug }, ); if (response.flows.length && response.flows[0].id) { log( - `deleting flow ${context.flow?.slug} flowId: ${response.flows[0].id}` + `deleting flow ${context.flow?.slug} flowId: ${response.flows[0].id}`, ); await adminGQLClient.request( `mutation DeleteTestFlow( $flowId: uuid!) { @@ -256,7 +256,7 @@ async function deleteFlow(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { flowId: response.flows[0].id } + { flowId: response.flows[0].id }, ); } } @@ -271,7 +271,7 @@ async function deleteUser(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { userId: context.user?.id } + { userId: context.user?.id }, ); } else if (context.user?.email) { // try deleting via email (when cleaning up from a previously failed test) @@ -281,11 +281,11 @@ async function deleteUser(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { email: context.user?.email } + { email: context.user?.email }, ); if (response.users.length && response.users[0].id) { log( - `deleting user ${context.user?.email} userId: ${response.users[0].id}` + `deleting user ${context.user?.email} userId: ${response.users[0].id}`, ); await adminGQLClient.request( `mutation DeleteTestUser($userId: Int!) { @@ -293,7 +293,7 @@ async function deleteUser(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { userId: response.users[0].id } + { userId: response.users[0].id }, ); } } @@ -308,7 +308,7 @@ async function deleteTeam(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { teamId: context.team?.id } + { teamId: context.team?.id }, ); } else if (context.team?.slug) { // try deleting via slug (when cleaning up from a previously failed test) @@ -318,11 +318,11 @@ async function deleteTeam(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { slug: context.team?.slug } + { slug: context.team?.slug }, ); if (response.teams.length && response.teams[0].id) { log( - `deleting team ${context.team?.slug} teamId: ${response.teams[0].id}` + `deleting team ${context.team?.slug} teamId: ${response.teams[0].id}`, ); await adminGQLClient.request( `mutation DeleteTestTeam( $teamId: Int!) { @@ -330,7 +330,7 @@ async function deleteTeam(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { teamId: response.teams[0].id } + { teamId: response.teams[0].id }, ); } } @@ -355,7 +355,7 @@ async function setupGovPaySecret($admin: CoreDomainClient, context: Context) { { team_id: context.team.id, staging_govpay_secret: process.env.GOV_UK_PAY_SECRET_E2E, - } + }, ); } catch (error) { throw Error("Failed to setup GovPay secret for E2E team"); From f233dd0af2adc30cec9ae1581e3ea3d85e6db97f Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 11 Jun 2024 10:31:12 +0100 Subject: [PATCH 21/33] remove redundant name change --- e2e/tests/ui-driven/src/context.ts | 47 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/e2e/tests/ui-driven/src/context.ts b/e2e/tests/ui-driven/src/context.ts index dacd6247ae..4dd9bc6308 100644 --- a/e2e/tests/ui-driven/src/context.ts +++ b/e2e/tests/ui-driven/src/context.ts @@ -49,7 +49,7 @@ export const contextDefaults: Context = { }; export async function setUpTestContext( - initialContext: Context, + initialContext: Context ): Promise { const $admin = getCoreDomainClient(); const context: Context = { ...initialContext }; @@ -118,7 +118,7 @@ export function generateAuthenticationToken(userId: string) { "x-hasura-user-id": `${userId}`, }, }, - process.env.JWT_SECRET, + process.env.JWT_SECRET ); } @@ -128,7 +128,7 @@ export function getCoreDomainClient(): CoreDomainClient { const API = process.env.HASURA_GRAPHQL_URL!.replace( "${HASURA_PROXY_PORT}", - process.env.HASURA_PROXY_PORT!, + process.env.HASURA_PROXY_PORT! ); const SECRET = process.env.HASURA_GRAPHQL_ADMIN_SECRET!; return new CoreDomainClient({ @@ -143,7 +143,7 @@ export function getGraphQLClient(): GraphQLClient { export async function findSessionId( adminGQLClient: GraphQLClient, - context, + context ): Promise { // get the flow id which may have a session const flowResponse: { flows: { id: string }[] } = @@ -153,7 +153,7 @@ export async function findSessionId( id } }`, - { slug: context.flow?.slug }, + { slug: context.flow?.slug } ); if (!flowResponse.flows.length || !flowResponse.flows[0].id) { return; @@ -170,11 +170,10 @@ export async function findSessionId( limit: 1 ) { id - name } } `, - { flowId, email: context.user?.email }, + { flowId, email: context.user?.email } ); if (response.lowcal_sessions.length && response.lowcal_sessions[0].id) { return response.lowcal_sessions[0].id; @@ -190,7 +189,7 @@ async function deleteSession(adminGQLClient: GraphQLClient, context) { id } }`, - { sessionId }, + { sessionId } ); } } @@ -203,14 +202,14 @@ async function deleteSession(adminGQLClient: GraphQLClient, context) { id } }`, - { sessionId }, + { sessionId } ); } } async function deletePublishedFlow( adminGQLClient: GraphQLClient, - context: Context, + context: Context ) { if (context.flow?.publishedId) { log(`deleting published flow ${context.flow?.publishedId}`); @@ -220,7 +219,7 @@ async function deletePublishedFlow( id } }`, - { publishedFlowId: context.flow?.publishedId }, + { publishedFlowId: context.flow?.publishedId } ); } } @@ -234,7 +233,7 @@ async function deleteFlow(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { flowId: context.flow?.id }, + { flowId: context.flow?.id } ); } else if (context.flow?.slug) { // try deleting via slug (when cleaning up from a previously failed test) @@ -244,11 +243,11 @@ async function deleteFlow(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { slug: context.flow?.slug }, + { slug: context.flow?.slug } ); if (response.flows.length && response.flows[0].id) { log( - `deleting flow ${context.flow?.slug} flowId: ${response.flows[0].id}`, + `deleting flow ${context.flow?.slug} flowId: ${response.flows[0].id}` ); await adminGQLClient.request( `mutation DeleteTestFlow( $flowId: uuid!) { @@ -256,7 +255,7 @@ async function deleteFlow(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { flowId: response.flows[0].id }, + { flowId: response.flows[0].id } ); } } @@ -271,7 +270,7 @@ async function deleteUser(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { userId: context.user?.id }, + { userId: context.user?.id } ); } else if (context.user?.email) { // try deleting via email (when cleaning up from a previously failed test) @@ -281,11 +280,11 @@ async function deleteUser(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { email: context.user?.email }, + { email: context.user?.email } ); if (response.users.length && response.users[0].id) { log( - `deleting user ${context.user?.email} userId: ${response.users[0].id}`, + `deleting user ${context.user?.email} userId: ${response.users[0].id}` ); await adminGQLClient.request( `mutation DeleteTestUser($userId: Int!) { @@ -293,7 +292,7 @@ async function deleteUser(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { userId: response.users[0].id }, + { userId: response.users[0].id } ); } } @@ -308,7 +307,7 @@ async function deleteTeam(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { teamId: context.team?.id }, + { teamId: context.team?.id } ); } else if (context.team?.slug) { // try deleting via slug (when cleaning up from a previously failed test) @@ -318,11 +317,11 @@ async function deleteTeam(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { slug: context.team?.slug }, + { slug: context.team?.slug } ); if (response.teams.length && response.teams[0].id) { log( - `deleting team ${context.team?.slug} teamId: ${response.teams[0].id}`, + `deleting team ${context.team?.slug} teamId: ${response.teams[0].id}` ); await adminGQLClient.request( `mutation DeleteTestTeam( $teamId: Int!) { @@ -330,7 +329,7 @@ async function deleteTeam(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { teamId: response.teams[0].id }, + { teamId: response.teams[0].id } ); } } @@ -355,7 +354,7 @@ async function setupGovPaySecret($admin: CoreDomainClient, context: Context) { { team_id: context.team.id, staging_govpay_secret: process.env.GOV_UK_PAY_SECRET_E2E, - }, + } ); } catch (error) { throw Error("Failed to setup GovPay secret for E2E team"); From 20a0cc156c3729efb6e754ef92fcb8e4e661c0ed Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 11 Jun 2024 10:37:22 +0100 Subject: [PATCH 22/33] run prettier on context changes --- e2e/tests/ui-driven/src/context.ts | 46 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/e2e/tests/ui-driven/src/context.ts b/e2e/tests/ui-driven/src/context.ts index 4dd9bc6308..daa07095c3 100644 --- a/e2e/tests/ui-driven/src/context.ts +++ b/e2e/tests/ui-driven/src/context.ts @@ -49,7 +49,7 @@ export const contextDefaults: Context = { }; export async function setUpTestContext( - initialContext: Context + initialContext: Context, ): Promise { const $admin = getCoreDomainClient(); const context: Context = { ...initialContext }; @@ -118,7 +118,7 @@ export function generateAuthenticationToken(userId: string) { "x-hasura-user-id": `${userId}`, }, }, - process.env.JWT_SECRET + process.env.JWT_SECRET, ); } @@ -128,7 +128,7 @@ export function getCoreDomainClient(): CoreDomainClient { const API = process.env.HASURA_GRAPHQL_URL!.replace( "${HASURA_PROXY_PORT}", - process.env.HASURA_PROXY_PORT! + process.env.HASURA_PROXY_PORT!, ); const SECRET = process.env.HASURA_GRAPHQL_ADMIN_SECRET!; return new CoreDomainClient({ @@ -143,7 +143,7 @@ export function getGraphQLClient(): GraphQLClient { export async function findSessionId( adminGQLClient: GraphQLClient, - context + context, ): Promise { // get the flow id which may have a session const flowResponse: { flows: { id: string }[] } = @@ -153,7 +153,7 @@ export async function findSessionId( id } }`, - { slug: context.flow?.slug } + { slug: context.flow?.slug }, ); if (!flowResponse.flows.length || !flowResponse.flows[0].id) { return; @@ -173,7 +173,7 @@ export async function findSessionId( } } `, - { flowId, email: context.user?.email } + { flowId, email: context.user?.email }, ); if (response.lowcal_sessions.length && response.lowcal_sessions[0].id) { return response.lowcal_sessions[0].id; @@ -189,7 +189,7 @@ async function deleteSession(adminGQLClient: GraphQLClient, context) { id } }`, - { sessionId } + { sessionId }, ); } } @@ -202,14 +202,14 @@ async function deleteSession(adminGQLClient: GraphQLClient, context) { id } }`, - { sessionId } + { sessionId }, ); } } async function deletePublishedFlow( adminGQLClient: GraphQLClient, - context: Context + context: Context, ) { if (context.flow?.publishedId) { log(`deleting published flow ${context.flow?.publishedId}`); @@ -219,7 +219,7 @@ async function deletePublishedFlow( id } }`, - { publishedFlowId: context.flow?.publishedId } + { publishedFlowId: context.flow?.publishedId }, ); } } @@ -233,7 +233,7 @@ async function deleteFlow(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { flowId: context.flow?.id } + { flowId: context.flow?.id }, ); } else if (context.flow?.slug) { // try deleting via slug (when cleaning up from a previously failed test) @@ -243,11 +243,11 @@ async function deleteFlow(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { slug: context.flow?.slug } + { slug: context.flow?.slug }, ); if (response.flows.length && response.flows[0].id) { log( - `deleting flow ${context.flow?.slug} flowId: ${response.flows[0].id}` + `deleting flow ${context.flow?.slug} flowId: ${response.flows[0].id}`, ); await adminGQLClient.request( `mutation DeleteTestFlow( $flowId: uuid!) { @@ -255,7 +255,7 @@ async function deleteFlow(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { flowId: response.flows[0].id } + { flowId: response.flows[0].id }, ); } } @@ -270,7 +270,7 @@ async function deleteUser(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { userId: context.user?.id } + { userId: context.user?.id }, ); } else if (context.user?.email) { // try deleting via email (when cleaning up from a previously failed test) @@ -280,11 +280,11 @@ async function deleteUser(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { email: context.user?.email } + { email: context.user?.email }, ); if (response.users.length && response.users[0].id) { log( - `deleting user ${context.user?.email} userId: ${response.users[0].id}` + `deleting user ${context.user?.email} userId: ${response.users[0].id}`, ); await adminGQLClient.request( `mutation DeleteTestUser($userId: Int!) { @@ -292,7 +292,7 @@ async function deleteUser(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { userId: response.users[0].id } + { userId: response.users[0].id }, ); } } @@ -307,7 +307,7 @@ async function deleteTeam(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { teamId: context.team?.id } + { teamId: context.team?.id }, ); } else if (context.team?.slug) { // try deleting via slug (when cleaning up from a previously failed test) @@ -317,11 +317,11 @@ async function deleteTeam(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { slug: context.team?.slug } + { slug: context.team?.slug }, ); if (response.teams.length && response.teams[0].id) { log( - `deleting team ${context.team?.slug} teamId: ${response.teams[0].id}` + `deleting team ${context.team?.slug} teamId: ${response.teams[0].id}`, ); await adminGQLClient.request( `mutation DeleteTestTeam( $teamId: Int!) { @@ -329,7 +329,7 @@ async function deleteTeam(adminGQLClient: GraphQLClient, context: Context) { id } }`, - { teamId: response.teams[0].id } + { teamId: response.teams[0].id }, ); } } @@ -354,7 +354,7 @@ async function setupGovPaySecret($admin: CoreDomainClient, context: Context) { { team_id: context.team.id, staging_govpay_secret: process.env.GOV_UK_PAY_SECRET_E2E, - } + }, ); } catch (error) { throw Error("Failed to setup GovPay secret for E2E team"); From fd9166136342b641131991e8250a7c7dd00eb531 Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Tue, 11 Jun 2024 18:09:09 +0200 Subject: [PATCH 23/33] fix: make flow name required and update all contexts for passing e2e tests (#3268) --- e2e/tests/ui-driven/src/context.ts | 2 +- e2e/tests/ui-driven/src/invite-to-pay/agent.spec.ts | 1 + e2e/tests/ui-driven/src/invite-to-pay/nominee.spec.ts | 1 + e2e/tests/ui-driven/src/pay.spec.ts | 1 + e2e/tests/ui-driven/src/save-and-return.spec.ts | 1 + e2e/tests/ui-driven/src/sections.spec.ts | 1 + 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/e2e/tests/ui-driven/src/context.ts b/e2e/tests/ui-driven/src/context.ts index daa07095c3..f2ccb89479 100644 --- a/e2e/tests/ui-driven/src/context.ts +++ b/e2e/tests/ui-driven/src/context.ts @@ -25,7 +25,7 @@ export interface Context { id?: string; publishedId?: number; slug: string; - name?: string; + name: string; data?: object; }; sessionIds?: string[]; diff --git a/e2e/tests/ui-driven/src/invite-to-pay/agent.spec.ts b/e2e/tests/ui-driven/src/invite-to-pay/agent.spec.ts index a31a1cfb53..7442170cf2 100644 --- a/e2e/tests/ui-driven/src/invite-to-pay/agent.spec.ts +++ b/e2e/tests/ui-driven/src/invite-to-pay/agent.spec.ts @@ -21,6 +21,7 @@ let context: Context = { ...contextDefaults, flow: { slug: "invite-to-pay-test", + name: "Invite to pay test", data: inviteToPayFlow, }, sessionIds: [], // used to collect and clean up sessions diff --git a/e2e/tests/ui-driven/src/invite-to-pay/nominee.spec.ts b/e2e/tests/ui-driven/src/invite-to-pay/nominee.spec.ts index d200fc05bb..db126996e9 100644 --- a/e2e/tests/ui-driven/src/invite-to-pay/nominee.spec.ts +++ b/e2e/tests/ui-driven/src/invite-to-pay/nominee.spec.ts @@ -18,6 +18,7 @@ let context: Context = { ...contextDefaults, flow: { slug: "invite-to-pay-test", + name: "Invite to pay test", data: inviteToPayFlow, }, sessionIds: [], // used to collect and clean up sessions diff --git a/e2e/tests/ui-driven/src/pay.spec.ts b/e2e/tests/ui-driven/src/pay.spec.ts index c5974ae55d..c630746073 100644 --- a/e2e/tests/ui-driven/src/pay.spec.ts +++ b/e2e/tests/ui-driven/src/pay.spec.ts @@ -23,6 +23,7 @@ let context: Context = { ...contextDefaults, flow: { slug: "pay-test", + name: "Pay test", data: payFlow, }, sessionIds: [], // used to collect and clean up sessions diff --git a/e2e/tests/ui-driven/src/save-and-return.spec.ts b/e2e/tests/ui-driven/src/save-and-return.spec.ts index 0188ef8624..162615bad5 100644 --- a/e2e/tests/ui-driven/src/save-and-return.spec.ts +++ b/e2e/tests/ui-driven/src/save-and-return.spec.ts @@ -24,6 +24,7 @@ test.describe("Save and return", () => { ...contextDefaults, flow: { slug: "e2e-save-and-return-test-flow", + name: "E2E Save and Return test flow", data: simpleSendFlow, }, }; diff --git a/e2e/tests/ui-driven/src/sections.spec.ts b/e2e/tests/ui-driven/src/sections.spec.ts index c9189eb6eb..2a44985e8a 100644 --- a/e2e/tests/ui-driven/src/sections.spec.ts +++ b/e2e/tests/ui-driven/src/sections.spec.ts @@ -38,6 +38,7 @@ test.describe("Section statuses", () => { ...contextDefaults, flow: { slug: "sections-test-flow", + name: "Sections test flow", data: flow, }, }; From 57f8a81cf20a171d0c6874d9c20c54bc6c7d6657 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 12 Jun 2024 14:39:35 +0100 Subject: [PATCH 24/33] add name to copy flow --- api.planx.uk/helpers.ts | 36 +++++++++++-------- .../modules/flows/copyFlow/controller.ts | 6 ++-- .../modules/flows/copyFlow/service.ts | 6 ++-- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/api.planx.uk/helpers.ts b/api.planx.uk/helpers.ts index 6bbcf5b71e..33e094b5b5 100644 --- a/api.planx.uk/helpers.ts +++ b/api.planx.uk/helpers.ts @@ -6,6 +6,7 @@ import { $public, getClient } from "./client"; export interface FlowData { slug: string; + name: string; data: Flow["data"]; team_id: number; team: { slug: string }; @@ -28,6 +29,7 @@ const getFlowData = async (id: string): Promise => { flow: flows_by_pk(id: $id) { slug data + name team_id team { slug @@ -45,7 +47,7 @@ const getFlowData = async (id: string): Promise => { } } `, - { id }, + { id } ); if (!flow) throw Error(`Unable to get flow with id ${id}`); @@ -62,9 +64,10 @@ interface InsertFlow { const insertFlow = async ( teamId: number, slug: string, + name: string, flowData: Flow["data"], creatorId?: number, - copiedFrom?: Flow["id"], + copiedFrom?: Flow["id"] ) => { const { client: $client } = getClient(); try { @@ -75,6 +78,7 @@ const insertFlow = async ( mutation InsertFlow( $team_id: Int! $slug: String! + $name: String! $data: jsonb = {} $creator_id: Int $copied_from: uuid @@ -83,6 +87,7 @@ const insertFlow = async ( object: { team_id: $team_id slug: $slug + name: $name data: $data version: 1 creator_id: $creator_id @@ -96,17 +101,18 @@ const insertFlow = async ( { team_id: teamId, slug: slug, + name: name, data: flowData, creator_id: creatorId, copied_from: copiedFrom, - }, + } ); await createAssociatedOperation(id); return { id }; } catch (error) { throw Error( - `User ${creatorId} failed to insert flow to teamId ${teamId}. Please check permissions. Error: ${error}`, + `User ${creatorId} failed to insert flow to teamId ${teamId}. Please check permissions. Error: ${error}` ); } }; @@ -126,7 +132,7 @@ const createAssociatedOperation = async (flowId: Flow["id"]) => { `, { flow_id: flowId, - }, + } ); return data?.operation; @@ -144,7 +150,7 @@ interface PublishedFlows { // Get the most recent version of a published flow's data (flattened, with external portal nodes) const getMostRecentPublishedFlow = async ( - id: string, + id: string ): Promise => { const { flow } = await $public.client.request( gql` @@ -159,7 +165,7 @@ const getMostRecentPublishedFlow = async ( } } `, - { id }, + { id } ); const mostRecent = flow?.publishedFlows?.[0]?.data; @@ -167,7 +173,7 @@ const getMostRecentPublishedFlow = async ( }; const getMostRecentPublishedFlowVersion = async ( - id: string, + id: string ): Promise => { const { flow } = await $public.client.request( gql` @@ -182,7 +188,7 @@ const getMostRecentPublishedFlowVersion = async ( } } `, - { id }, + { id } ); const mostRecent = flow?.publishedFlows?.[0]?.id; @@ -198,7 +204,7 @@ const dataMerged = async ( id: string, ob: { [key: string]: Node } = {}, isPortal = false, - draftDataOnly = false, + draftDataOnly = false ): Promise => { // get the primary draft flow data, including its' latest published version const response = await getFlowData(id); @@ -211,7 +217,7 @@ const dataMerged = async ( data = publishedFlows[0].data; } else { throw new Error( - `Publish flow ${team.slug}/${slug} before proceeding. All flows used as external portals must be published.`, + `Publish flow ${team.slug}/${slug} before proceeding. All flows used as external portals must be published.` ); } } @@ -262,7 +268,7 @@ const dataMerged = async ( // ** this is a final/separate step because older snapshots can be nested in _already_ flattened data (eg not picked up as ComponentType.ExternalPortal above) if (!draftDataOnly) { for (const [nodeId, node] of Object.entries(ob).filter( - ([_nodeId, node]) => node.data?.publishedFlowId, + ([_nodeId, node]) => node.data?.publishedFlowId )) { const mostRecentPublishedFlowId = await getMostRecentPublishedFlowVersion(nodeId); @@ -281,7 +287,7 @@ const dataMerged = async ( const getChildren = ( node: Node, originalFlow: Flow["data"], - newFlow: Flow["data"], + newFlow: Flow["data"] ): Flow["data"] => { if (node.edges) { node.edges.forEach((edgeId) => { @@ -300,7 +306,7 @@ const getChildren = ( */ const makeUniqueFlow = ( flowData: Flow["data"], - replaceValue: string, + replaceValue: string ): Flow["data"] => { const charactersToReplace = replaceValue.length; @@ -308,7 +314,7 @@ const makeUniqueFlow = ( // if this node has edges, rename them (includes _root.edges) if (flowData[node]["edges"]) { const newEdges = flowData[node]["edges"]?.map( - (edge) => edge.slice(0, -charactersToReplace) + replaceValue, + (edge) => edge.slice(0, -charactersToReplace) + replaceValue ); delete flowData[node]["edges"]; flowData[node]["edges"] = newEdges; diff --git a/api.planx.uk/modules/flows/copyFlow/controller.ts b/api.planx.uk/modules/flows/copyFlow/controller.ts index 0f8918995c..0744de34a7 100644 --- a/api.planx.uk/modules/flows/copyFlow/controller.ts +++ b/api.planx.uk/modules/flows/copyFlow/controller.ts @@ -29,7 +29,7 @@ export type CopyFlowController = ValidatedRequestHandler< export const copyFlowController: CopyFlowController = async ( _req, res, - next, + next ) => { try { const { flowId } = res.locals.parsedReq.params; @@ -37,7 +37,7 @@ export const copyFlowController: CopyFlowController = async ( const { flow, uniqueFlowData } = await copyFlow( flowId, replaceValue, - insert, + insert ); res.status(200).send({ @@ -48,7 +48,7 @@ export const copyFlowController: CopyFlowController = async ( }); } catch (error) { return next( - new ServerError({ message: `Failed to copy flow. Error: ${error}` }), + new ServerError({ message: `Failed to copy flow. Error: ${error}` }) ); } }; diff --git a/api.planx.uk/modules/flows/copyFlow/service.ts b/api.planx.uk/modules/flows/copyFlow/service.ts index 6cf7ef8fbf..79aee602b5 100644 --- a/api.planx.uk/modules/flows/copyFlow/service.ts +++ b/api.planx.uk/modules/flows/copyFlow/service.ts @@ -4,7 +4,7 @@ import { userContext } from "../../auth/middleware"; const copyFlow = async ( flowId: string, replaceValue: string, - insert: boolean, + insert: boolean ) => { // Fetch the original flow const flow = await getFlowData(flowId); @@ -15,6 +15,7 @@ const copyFlow = async ( // Check if copied flow data should be inserted into `flows` table, or just returned for reference if (insert) { const newSlug = flow.slug + "-copy"; + const newName = flow.name + " (copy)"; const creatorId = userContext.getStore()?.user?.sub; if (!creatorId) throw Error("User details missing from request"); @@ -22,9 +23,10 @@ const copyFlow = async ( await insertFlow( flow.team_id, newSlug, + newName, uniqueFlowData, parseInt(creatorId), - flowId, + flowId ); } From 866509ee5380074039aa50a7a70551130fa4a939 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 12 Jun 2024 16:06:53 +0100 Subject: [PATCH 25/33] ternary for using slug if name doesn't exist --- editor.planx.uk/src/pages/Team.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor.planx.uk/src/pages/Team.tsx b/editor.planx.uk/src/pages/Team.tsx index d530c235f8..56e4e4086f 100644 --- a/editor.planx.uk/src/pages/Team.tsx +++ b/editor.planx.uk/src/pages/Team.tsx @@ -193,7 +193,7 @@ const FlowItem: React.FC = ({ - {flow.name} + {flow.name ? flow.name : flow.slug} {formatLastEditMessage( From d60a4a8d871ac3aaf302ea86d9894ea78d1c200e Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 12 Jun 2024 16:13:23 +0100 Subject: [PATCH 26/33] run prettier on file changes --- api.planx.uk/modules/flows/copyFlow/controller.ts | 6 +++--- api.planx.uk/modules/flows/copyFlow/service.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api.planx.uk/modules/flows/copyFlow/controller.ts b/api.planx.uk/modules/flows/copyFlow/controller.ts index 0744de34a7..0f8918995c 100644 --- a/api.planx.uk/modules/flows/copyFlow/controller.ts +++ b/api.planx.uk/modules/flows/copyFlow/controller.ts @@ -29,7 +29,7 @@ export type CopyFlowController = ValidatedRequestHandler< export const copyFlowController: CopyFlowController = async ( _req, res, - next + next, ) => { try { const { flowId } = res.locals.parsedReq.params; @@ -37,7 +37,7 @@ export const copyFlowController: CopyFlowController = async ( const { flow, uniqueFlowData } = await copyFlow( flowId, replaceValue, - insert + insert, ); res.status(200).send({ @@ -48,7 +48,7 @@ export const copyFlowController: CopyFlowController = async ( }); } catch (error) { return next( - new ServerError({ message: `Failed to copy flow. Error: ${error}` }) + new ServerError({ message: `Failed to copy flow. Error: ${error}` }), ); } }; diff --git a/api.planx.uk/modules/flows/copyFlow/service.ts b/api.planx.uk/modules/flows/copyFlow/service.ts index 79aee602b5..68e31f46e8 100644 --- a/api.planx.uk/modules/flows/copyFlow/service.ts +++ b/api.planx.uk/modules/flows/copyFlow/service.ts @@ -4,7 +4,7 @@ import { userContext } from "../../auth/middleware"; const copyFlow = async ( flowId: string, replaceValue: string, - insert: boolean + insert: boolean, ) => { // Fetch the original flow const flow = await getFlowData(flowId); @@ -26,7 +26,7 @@ const copyFlow = async ( newName, uniqueFlowData, parseInt(creatorId), - flowId + flowId, ); } From 3ba46d41d3b011ed46b07222230b17a00eecc459 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 12 Jun 2024 16:15:27 +0100 Subject: [PATCH 27/33] ran prettier on changes --- api.planx.uk/helpers.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/api.planx.uk/helpers.ts b/api.planx.uk/helpers.ts index 33e094b5b5..3433f5a9cd 100644 --- a/api.planx.uk/helpers.ts +++ b/api.planx.uk/helpers.ts @@ -47,7 +47,7 @@ const getFlowData = async (id: string): Promise => { } } `, - { id } + { id }, ); if (!flow) throw Error(`Unable to get flow with id ${id}`); @@ -67,7 +67,7 @@ const insertFlow = async ( name: string, flowData: Flow["data"], creatorId?: number, - copiedFrom?: Flow["id"] + copiedFrom?: Flow["id"], ) => { const { client: $client } = getClient(); try { @@ -105,14 +105,14 @@ const insertFlow = async ( data: flowData, creator_id: creatorId, copied_from: copiedFrom, - } + }, ); await createAssociatedOperation(id); return { id }; } catch (error) { throw Error( - `User ${creatorId} failed to insert flow to teamId ${teamId}. Please check permissions. Error: ${error}` + `User ${creatorId} failed to insert flow to teamId ${teamId}. Please check permissions. Error: ${error}`, ); } }; @@ -132,7 +132,7 @@ const createAssociatedOperation = async (flowId: Flow["id"]) => { `, { flow_id: flowId, - } + }, ); return data?.operation; @@ -150,7 +150,7 @@ interface PublishedFlows { // Get the most recent version of a published flow's data (flattened, with external portal nodes) const getMostRecentPublishedFlow = async ( - id: string + id: string, ): Promise => { const { flow } = await $public.client.request( gql` @@ -165,7 +165,7 @@ const getMostRecentPublishedFlow = async ( } } `, - { id } + { id }, ); const mostRecent = flow?.publishedFlows?.[0]?.data; @@ -173,7 +173,7 @@ const getMostRecentPublishedFlow = async ( }; const getMostRecentPublishedFlowVersion = async ( - id: string + id: string, ): Promise => { const { flow } = await $public.client.request( gql` @@ -188,7 +188,7 @@ const getMostRecentPublishedFlowVersion = async ( } } `, - { id } + { id }, ); const mostRecent = flow?.publishedFlows?.[0]?.id; @@ -204,7 +204,7 @@ const dataMerged = async ( id: string, ob: { [key: string]: Node } = {}, isPortal = false, - draftDataOnly = false + draftDataOnly = false, ): Promise => { // get the primary draft flow data, including its' latest published version const response = await getFlowData(id); @@ -217,7 +217,7 @@ const dataMerged = async ( data = publishedFlows[0].data; } else { throw new Error( - `Publish flow ${team.slug}/${slug} before proceeding. All flows used as external portals must be published.` + `Publish flow ${team.slug}/${slug} before proceeding. All flows used as external portals must be published.`, ); } } @@ -268,7 +268,7 @@ const dataMerged = async ( // ** this is a final/separate step because older snapshots can be nested in _already_ flattened data (eg not picked up as ComponentType.ExternalPortal above) if (!draftDataOnly) { for (const [nodeId, node] of Object.entries(ob).filter( - ([_nodeId, node]) => node.data?.publishedFlowId + ([_nodeId, node]) => node.data?.publishedFlowId, )) { const mostRecentPublishedFlowId = await getMostRecentPublishedFlowVersion(nodeId); @@ -287,7 +287,7 @@ const dataMerged = async ( const getChildren = ( node: Node, originalFlow: Flow["data"], - newFlow: Flow["data"] + newFlow: Flow["data"], ): Flow["data"] => { if (node.edges) { node.edges.forEach((edgeId) => { @@ -306,7 +306,7 @@ const getChildren = ( */ const makeUniqueFlow = ( flowData: Flow["data"], - replaceValue: string + replaceValue: string, ): Flow["data"] => { const charactersToReplace = replaceValue.length; @@ -314,7 +314,7 @@ const makeUniqueFlow = ( // if this node has edges, rename them (includes _root.edges) if (flowData[node]["edges"]) { const newEdges = flowData[node]["edges"]?.map( - (edge) => edge.slice(0, -charactersToReplace) + replaceValue + (edge) => edge.slice(0, -charactersToReplace) + replaceValue, ); delete flowData[node]["edges"]; flowData[node]["edges"] = newEdges; From 2f2091398a4ffed86268842325040df537d824dc Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 12 Jun 2024 17:13:33 +0100 Subject: [PATCH 28/33] replacing name with slug if name is null --- editor.planx.uk/src/pages/Team.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor.planx.uk/src/pages/Team.tsx b/editor.planx.uk/src/pages/Team.tsx index 56e4e4086f..c30f27ef95 100644 --- a/editor.planx.uk/src/pages/Team.tsx +++ b/editor.planx.uk/src/pages/Team.tsx @@ -193,7 +193,7 @@ const FlowItem: React.FC = ({ - {flow.name ? flow.name : flow.slug} + {flow.name === null ? flow.slug : flow.name} {formatLastEditMessage( From 93bb0d1e2ac711c6f7460297fc55244bb508dc53 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 12 Jun 2024 17:16:46 +0100 Subject: [PATCH 29/33] replacing name with slug if name is null --- editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts index ff71086a35..601e446c79 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts @@ -112,6 +112,9 @@ export const sharedStore: StateCreator< }, setFlowName(flowName) { + if (flowName === null) { + set({ flowName: this.flowSlug }); + } set({ flowName }); }, From 2a8f40b4adfa4adad5185b4fa65f46334d80c7f4 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 12 Jun 2024 17:18:19 +0100 Subject: [PATCH 30/33] replacing name with slug if name is null --- editor.planx.uk/src/routes/views/preview.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/editor.planx.uk/src/routes/views/preview.tsx b/editor.planx.uk/src/routes/views/preview.tsx index 95ee2ff145..6f25ac2370 100644 --- a/editor.planx.uk/src/routes/views/preview.tsx +++ b/editor.planx.uk/src/routes/views/preview.tsx @@ -28,7 +28,12 @@ export const previewView = async (req: NaviRequest) => { const flowData = await fetchFlattenedFlowData(flow.id); const state = useStore.getState(); - state.setFlow({ id: flow.id, flow: flowData, flowSlug, flowName: flow.name }); + state.setFlow({ + id: flow.id, + flow: flowData, + flowSlug, + flowName: flow.name === null ? flowSlug : flow.name, + }); state.setGlobalSettings(data.globalSettings[0]); state.setFlowSettings(flow.settings); state.setTeam(flow.team); From 6fc88422bdc855be283f1ed171124e6a4163f8ce Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 12 Jun 2024 17:23:24 +0100 Subject: [PATCH 31/33] replacing name with slug if name is null --- editor.planx.uk/src/routes/views/published.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor.planx.uk/src/routes/views/published.tsx b/editor.planx.uk/src/routes/views/published.tsx index 9570675577..9b2d07112c 100644 --- a/editor.planx.uk/src/routes/views/published.tsx +++ b/editor.planx.uk/src/routes/views/published.tsx @@ -49,7 +49,7 @@ export const publishedView = async (req: NaviRequest) => { flow: publishedFlow, flowSlug, flowStatus: flow.status, - flowName: flow.name, + flowName: flow.name == null ? flowSlug : flow.name, }); state.setGlobalSettings(data.globalSettings[0]); state.setFlowSettings(flow.settings); From 7d828e960c293ed3483f0be46c7ce39a3182dc03 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 12 Jun 2024 17:30:01 +0100 Subject: [PATCH 32/33] replacing name with slug if name is null --- editor.planx.uk/src/routes/views/published.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor.planx.uk/src/routes/views/published.tsx b/editor.planx.uk/src/routes/views/published.tsx index 9b2d07112c..9570675577 100644 --- a/editor.planx.uk/src/routes/views/published.tsx +++ b/editor.planx.uk/src/routes/views/published.tsx @@ -49,7 +49,7 @@ export const publishedView = async (req: NaviRequest) => { flow: publishedFlow, flowSlug, flowStatus: flow.status, - flowName: flow.name == null ? flowSlug : flow.name, + flowName: flow.name, }); state.setGlobalSettings(data.globalSettings[0]); state.setFlowSettings(flow.settings); From cbed3a00448c2436f52bf58f612ffed377a5f288 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Thu, 13 Jun 2024 09:09:52 +0100 Subject: [PATCH 33/33] revert changes to switch out flow name for slug when name is null --- editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts | 3 --- editor.planx.uk/src/pages/Team.tsx | 2 +- editor.planx.uk/src/routes/views/preview.tsx | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts index 601e446c79..ff71086a35 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/shared.ts @@ -112,9 +112,6 @@ export const sharedStore: StateCreator< }, setFlowName(flowName) { - if (flowName === null) { - set({ flowName: this.flowSlug }); - } set({ flowName }); }, diff --git a/editor.planx.uk/src/pages/Team.tsx b/editor.planx.uk/src/pages/Team.tsx index c30f27ef95..d530c235f8 100644 --- a/editor.planx.uk/src/pages/Team.tsx +++ b/editor.planx.uk/src/pages/Team.tsx @@ -193,7 +193,7 @@ const FlowItem: React.FC = ({ - {flow.name === null ? flow.slug : flow.name} + {flow.name} {formatLastEditMessage( diff --git a/editor.planx.uk/src/routes/views/preview.tsx b/editor.planx.uk/src/routes/views/preview.tsx index 6f25ac2370..49346eb542 100644 --- a/editor.planx.uk/src/routes/views/preview.tsx +++ b/editor.planx.uk/src/routes/views/preview.tsx @@ -32,7 +32,7 @@ export const previewView = async (req: NaviRequest) => { id: flow.id, flow: flowData, flowSlug, - flowName: flow.name === null ? flowSlug : flow.name, + flowName: flow.name, }); state.setGlobalSettings(data.globalSettings[0]); state.setFlowSettings(flow.settings);