diff --git a/api.planx.uk/helpers.ts b/api.planx.uk/helpers.ts index d2d3c9a44a..856e670194 100644 --- a/api.planx.uk/helpers.ts +++ b/api.planx.uk/helpers.ts @@ -1,10 +1,12 @@ -import { gql } from "graphql-request"; -import capitalize from "lodash/capitalize.js"; -import type { Flow, Node } from "./types.js"; import type { FlowGraph } from "@opensystemslab/planx-core/types"; import { ComponentType } from "@opensystemslab/planx-core/types"; +import { gql } from "graphql-request"; +import capitalize from "lodash/capitalize.js"; + import { $public, getClient } from "./client/index.js"; import { userContext } from "./modules/auth/middleware.js"; +import { publishFlow } from "./modules/flows/publish/service.js"; +import type { Flow, Node } from "./types.js"; export interface FlowData { slug: string; @@ -63,7 +65,7 @@ interface InsertFlow { } // Insert a new flow into the `flows` table -const insertFlow = async ( +const createFlow = async ( teamId: number, slug: string, name: string, @@ -109,6 +111,8 @@ const insertFlow = async ( ); await createAssociatedOperation(id); + await publishFlow(id, "Created flow"); + return { id }; } catch (error) { throw Error( @@ -357,7 +361,7 @@ export { dataMerged, getChildren, makeUniqueFlow, - insertFlow, + createFlow, isLiveEnv, getFormattedEnvironment, }; diff --git a/api.planx.uk/modules/flows/copyFlow/copyFlow.test.ts b/api.planx.uk/modules/flows/copyFlow/copyFlow.test.ts index 1afaf5d9eb..3daa98f586 100644 --- a/api.planx.uk/modules/flows/copyFlow/copyFlow.test.ts +++ b/api.planx.uk/modules/flows/copyFlow/copyFlow.test.ts @@ -36,6 +36,30 @@ beforeEach(() => { }, }, }); + + queryMock.mockQuery({ + name: "GetMostRecentPublishedFlow", + matchOnVariables: false, + data: { + flow: { + publishedFlows: [ + { + data: mockFlowData, + }, + ], + }, + }, + }); + + queryMock.mockQuery({ + name: "PublishFlow", + matchOnVariables: false, + data: { + publishedFlow: { + data: mockFlowData, + }, + }, + }); }); const auth = authHeader({ role: "teamEditor" }); diff --git a/api.planx.uk/modules/flows/copyFlow/service.ts b/api.planx.uk/modules/flows/copyFlow/service.ts index 163fbae852..8d5a976ed1 100644 --- a/api.planx.uk/modules/flows/copyFlow/service.ts +++ b/api.planx.uk/modules/flows/copyFlow/service.ts @@ -1,4 +1,4 @@ -import { makeUniqueFlow, getFlowData, insertFlow } from "../../../helpers.js"; +import { makeUniqueFlow, getFlowData, createFlow } from "../../../helpers.js"; const copyFlow = async ( flowId: string, @@ -17,7 +17,7 @@ const copyFlow = async ( const newName = flow.name + " (copy)"; // Insert the flow and an associated operation - await insertFlow(flow.team_id, newSlug, newName, uniqueFlowData, flowId); + await createFlow(flow.team_id, newSlug, newName, uniqueFlowData, flowId); } return { flow, uniqueFlowData }; diff --git a/api.planx.uk/package.json b/api.planx.uk/package.json index 1b415ee4f5..9e62bbe9a3 100644 --- a/api.planx.uk/package.json +++ b/api.planx.uk/package.json @@ -13,7 +13,7 @@ "@airbrake/node": "^2.1.8", "@aws-sdk/client-s3": "^3.696.0", "@aws-sdk/s3-request-presigner": "^3.701.0", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#03de3e0", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#db49201", "@types/isomorphic-fetch": "^0.0.36", "adm-zip": "^0.5.10", "axios": "^1.7.4", diff --git a/api.planx.uk/pnpm-lock.yaml b/api.planx.uk/pnpm-lock.yaml index 25443277db..0012180d78 100644 --- a/api.planx.uk/pnpm-lock.yaml +++ b/api.planx.uk/pnpm-lock.yaml @@ -21,8 +21,8 @@ dependencies: specifier: ^3.701.0 version: 3.701.0 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#03de3e0 - version: github.com/theopensystemslab/planx-core/03de3e0(@types/react@19.0.7) + specifier: git+https://github.com/theopensystemslab/planx-core#db49201 + version: github.com/theopensystemslab/planx-core/db49201(@types/react@19.0.7) '@types/isomorphic-fetch': specifier: ^0.0.36 version: 0.0.36 @@ -1947,39 +1947,6 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: false - /@floating-ui/core@1.6.9: - resolution: {integrity: sha512-uMXCuQ3BItDUbAMhIXw7UPXRfAlOAvZzdK9BWpE60MCn+Svt3aLn9jsPTi/WNGlRUu2uI0v5S7JiIUsbsvh3fw==} - dependencies: - '@floating-ui/utils': 0.2.9 - dev: false - - /@floating-ui/dom@1.6.13: - resolution: {integrity: sha512-umqzocjDgNRGTuO7Q8CU32dkHkECqI8ZdMZ5Swb6QAM0t5rnlrN3lGo1hdpscRd3WS8T6DKYK4ephgIH9iRh3w==} - dependencies: - '@floating-ui/core': 1.6.9 - '@floating-ui/utils': 0.2.9 - dev: false - - /@floating-ui/react-dom@2.1.2(react-dom@18.3.1)(react@18.3.1): - resolution: {integrity: sha512-06okr5cgPzMNBy+Ycse2A6udMi4bqwW/zgBF/rwjcNqWkyr82Mcg8b0vjX8OJpZFy/FKjJmw6wV7t44kK6kW7A==} - peerDependencies: - react: '>=16.8.0' - react-dom: '>=16.8.0' - peerDependenciesMeta: - react: - optional: true - react-dom: - optional: true - dependencies: - '@floating-ui/dom': 1.6.13 - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - dev: false - - /@floating-ui/utils@0.2.9: - resolution: {integrity: sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg==} - dev: false - /@formatjs/ecma402-abstract@2.3.2: resolution: {integrity: sha512-6sE5nyvDloULiyOMbOTJEEgWL32w+VHkZQs8S02Lnn8Y/O5aQhjOEXwWzvR7SsBE/exxlSpY2EsWZgqHbtLatg==} dependencies: @@ -2095,33 +2062,6 @@ packages: resolution: {integrity: sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==} dev: false - /@mui/base@5.0.0-beta.60(@types/react@19.0.7)(react-dom@18.3.1)(react@18.3.1): - resolution: {integrity: sha512-w8twR3qCUI+uJHO5xDOuc1yB5l46KFbvNsTwIvEW9tQkKxVaiEFf2GAXHuvFJiHfZLqjzett6drZjghy8D1Z1A==} - engines: {node: '>=14.0.0'} - peerDependencies: - '@types/react': ^17.0.0 || ^18.0.0 - react: ^17.0.0 || ^18.0.0 - react-dom: ^17.0.0 || ^18.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - react: - optional: true - react-dom: - optional: true - dependencies: - '@babel/runtime': 7.26.0 - '@floating-ui/react-dom': 2.1.2(react-dom@18.3.1)(react@18.3.1) - '@mui/types': 7.2.21(@types/react@19.0.7) - '@mui/utils': 6.4.1(@types/react@19.0.7)(react@18.3.1) - '@popperjs/core': 2.11.8 - '@types/react': 19.0.7 - clsx: 2.1.1 - prop-types: 15.8.1 - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - dev: false - /@mui/core-downloads-tracker@5.16.14: resolution: {integrity: sha512-sbjXW+BBSvmzn61XyTMun899E7nGPTXwqD9drm1jBUAvWEhJpPFIRxwQQiATWZnd9rvdxtnhhdsDxEGWI0jxqA==} dev: false @@ -2274,28 +2214,6 @@ packages: react-is: 19.0.0 dev: false - /@mui/utils@6.4.1(@types/react@19.0.7)(react@18.3.1): - resolution: {integrity: sha512-iQUDUeYh87SvR4lVojaRaYnQix8BbRV51MxaV6MBmqthecQoxwSbS5e2wnbDJUeFxY2ppV505CiqPLtd0OWkqw==} - engines: {node: '>=14.0.0'} - peerDependencies: - '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0 - react: ^17.0.0 || ^18.0.0 || ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - react: - optional: true - dependencies: - '@babel/runtime': 7.26.0 - '@mui/types': 7.2.21(@types/react@19.0.7) - '@types/prop-types': 15.7.14 - '@types/react': 19.0.7 - clsx: 2.1.1 - prop-types: 15.8.1 - react: 18.3.1 - react-is: 19.0.0 - dev: false - /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -7755,9 +7673,9 @@ packages: resolution: {integrity: sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==} dev: false - github.com/theopensystemslab/planx-core/03de3e0(@types/react@19.0.7): - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/03de3e0} - id: github.com/theopensystemslab/planx-core/03de3e0 + github.com/theopensystemslab/planx-core/db49201(@types/react@19.0.7): + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/db49201} + id: github.com/theopensystemslab/planx-core/db49201 name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true @@ -7766,7 +7684,6 @@ packages: '@emotion/react': 11.14.0(@types/react@19.0.7)(react@18.3.1) '@emotion/styled': 11.14.0(@emotion/react@11.14.0)(@types/react@19.0.7)(react@18.3.1) '@formatjs/intl-listformat': 7.7.9 - '@mui/base': 5.0.0-beta.60(@types/react@19.0.7)(react-dom@18.3.1)(react@18.3.1) '@mui/material': 5.16.14(@emotion/react@11.14.0)(@emotion/styled@11.14.0)(@types/react@19.0.7)(react-dom@18.3.1)(react@18.3.1) ajv: 8.17.1 ajv-formats: 2.1.1(ajv@8.17.1) diff --git a/e2e/tests/api-driven/package.json b/e2e/tests/api-driven/package.json index 90cf80b744..6c10fc2e7e 100644 --- a/e2e/tests/api-driven/package.json +++ b/e2e/tests/api-driven/package.json @@ -8,7 +8,7 @@ "packageManager": "pnpm@8.6.6", "dependencies": { "@cucumber/cucumber": "^11.1.1", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#03de3e0", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#db49201", "axios": "^1.7.4", "dotenv": "^16.3.1", "dotenv-expand": "^10.0.0", diff --git a/e2e/tests/api-driven/pnpm-lock.yaml b/e2e/tests/api-driven/pnpm-lock.yaml index e0e00c31f7..92498b2ed6 100644 --- a/e2e/tests/api-driven/pnpm-lock.yaml +++ b/e2e/tests/api-driven/pnpm-lock.yaml @@ -9,8 +9,8 @@ dependencies: specifier: ^11.1.1 version: 11.1.1 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#03de3e0 - version: github.com/theopensystemslab/planx-core/03de3e0(@types/react@19.0.7) + specifier: git+https://github.com/theopensystemslab/planx-core#db49201 + version: github.com/theopensystemslab/planx-core/db49201(@types/react@19.0.7) axios: specifier: ^1.7.4 version: 1.7.4 @@ -460,34 +460,6 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: false - /@floating-ui/core@1.6.9: - resolution: {integrity: sha512-uMXCuQ3BItDUbAMhIXw7UPXRfAlOAvZzdK9BWpE60MCn+Svt3aLn9jsPTi/WNGlRUu2uI0v5S7JiIUsbsvh3fw==} - dependencies: - '@floating-ui/utils': 0.2.9 - dev: false - - /@floating-ui/dom@1.6.13: - resolution: {integrity: sha512-umqzocjDgNRGTuO7Q8CU32dkHkECqI8ZdMZ5Swb6QAM0t5rnlrN3lGo1hdpscRd3WS8T6DKYK4ephgIH9iRh3w==} - dependencies: - '@floating-ui/core': 1.6.9 - '@floating-ui/utils': 0.2.9 - dev: false - - /@floating-ui/react-dom@2.1.2(react-dom@18.3.1)(react@18.3.1): - resolution: {integrity: sha512-06okr5cgPzMNBy+Ycse2A6udMi4bqwW/zgBF/rwjcNqWkyr82Mcg8b0vjX8OJpZFy/FKjJmw6wV7t44kK6kW7A==} - peerDependencies: - react: '>=16.8.0' - react-dom: '>=16.8.0' - dependencies: - '@floating-ui/dom': 1.6.13 - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - dev: false - - /@floating-ui/utils@0.2.9: - resolution: {integrity: sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg==} - dev: false - /@formatjs/ecma402-abstract@2.3.2: resolution: {integrity: sha512-6sE5nyvDloULiyOMbOTJEEgWL32w+VHkZQs8S02Lnn8Y/O5aQhjOEXwWzvR7SsBE/exxlSpY2EsWZgqHbtLatg==} dependencies: @@ -598,29 +570,6 @@ packages: resolution: {integrity: sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==} dev: false - /@mui/base@5.0.0-beta.60(@types/react@19.0.7)(react-dom@18.3.1)(react@18.3.1): - resolution: {integrity: sha512-w8twR3qCUI+uJHO5xDOuc1yB5l46KFbvNsTwIvEW9tQkKxVaiEFf2GAXHuvFJiHfZLqjzett6drZjghy8D1Z1A==} - engines: {node: '>=14.0.0'} - peerDependencies: - '@types/react': ^17.0.0 || ^18.0.0 - react: ^17.0.0 || ^18.0.0 - react-dom: ^17.0.0 || ^18.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - dependencies: - '@babel/runtime': 7.26.0 - '@floating-ui/react-dom': 2.1.2(react-dom@18.3.1)(react@18.3.1) - '@mui/types': 7.2.21(@types/react@19.0.7) - '@mui/utils': 6.4.1(@types/react@19.0.7)(react@18.3.1) - '@popperjs/core': 2.11.8 - '@types/react': 19.0.7 - clsx: 2.1.1 - prop-types: 15.8.1 - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - dev: false - /@mui/core-downloads-tracker@5.16.14: resolution: {integrity: sha512-sbjXW+BBSvmzn61XyTMun899E7nGPTXwqD9drm1jBUAvWEhJpPFIRxwQQiATWZnd9rvdxtnhhdsDxEGWI0jxqA==} dev: false @@ -761,26 +710,6 @@ packages: react-is: 19.0.0 dev: false - /@mui/utils@6.4.1(@types/react@19.0.7)(react@18.3.1): - resolution: {integrity: sha512-iQUDUeYh87SvR4lVojaRaYnQix8BbRV51MxaV6MBmqthecQoxwSbS5e2wnbDJUeFxY2ppV505CiqPLtd0OWkqw==} - engines: {node: '>=14.0.0'} - peerDependencies: - '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0 - react: ^17.0.0 || ^18.0.0 || ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - dependencies: - '@babel/runtime': 7.26.0 - '@mui/types': 7.2.21(@types/react@19.0.7) - '@types/prop-types': 15.7.14 - '@types/react': 19.0.7 - clsx: 2.1.1 - prop-types: 15.8.1 - react: 18.3.1 - react-is: 19.0.0 - dev: false - /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -3060,9 +2989,9 @@ packages: resolution: {integrity: sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==} dev: false - github.com/theopensystemslab/planx-core/03de3e0(@types/react@19.0.7): - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/03de3e0} - id: github.com/theopensystemslab/planx-core/03de3e0 + github.com/theopensystemslab/planx-core/db49201(@types/react@19.0.7): + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/db49201} + id: github.com/theopensystemslab/planx-core/db49201 name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true @@ -3071,7 +3000,6 @@ packages: '@emotion/react': 11.14.0(@types/react@19.0.7)(react@18.3.1) '@emotion/styled': 11.14.0(@emotion/react@11.14.0)(@types/react@19.0.7)(react@18.3.1) '@formatjs/intl-listformat': 7.7.9 - '@mui/base': 5.0.0-beta.60(@types/react@19.0.7)(react-dom@18.3.1)(react@18.3.1) '@mui/material': 5.16.14(@emotion/react@11.14.0)(@emotion/styled@11.14.0)(@types/react@19.0.7)(react-dom@18.3.1)(react@18.3.1) ajv: 8.17.1 ajv-formats: 2.1.1(ajv@8.17.1) diff --git a/e2e/tests/api-driven/src/flowStatusHistory/helpers.ts b/e2e/tests/api-driven/src/flowStatusHistory/helpers.ts index f93af1213a..250a5d0b15 100644 --- a/e2e/tests/api-driven/src/flowStatusHistory/helpers.ts +++ b/e2e/tests/api-driven/src/flowStatusHistory/helpers.ts @@ -1,12 +1,13 @@ import { FlowStatus } from "@opensystemslab/planx-core/types"; import { $admin } from "../client.js"; -import { createTeam } from "../globalHelpers.js"; +import { createTeam, createUser } from "../globalHelpers.js"; import { gql } from "graphql-tag"; export const setup = async () => { const teamId = await createTeam(); + const userId = await createUser(); - const world = { teamId }; + const world = { teamId, userId }; return world; }; diff --git a/e2e/tests/api-driven/src/flowStatusHistory/steps.ts b/e2e/tests/api-driven/src/flowStatusHistory/steps.ts index abab998258..bb88a4afcf 100644 --- a/e2e/tests/api-driven/src/flowStatusHistory/steps.ts +++ b/e2e/tests/api-driven/src/flowStatusHistory/steps.ts @@ -12,6 +12,7 @@ import { $admin } from "../client.js"; export class CustomWorld extends World { teamId!: number; flowId!: string; + userId!: number; } After("@flow-status-history", async function () { @@ -19,8 +20,9 @@ After("@flow-status-history", async function () { }); Before("@flow-status-history", async function () { - const { teamId } = await setup(); + const { teamId, userId } = await setup(); this.teamId = teamId; + this.userId = userId; }); Given("a flow exists", async function () { @@ -28,6 +30,7 @@ Given("a flow exists", async function () { teamId: this.teamId, slug: "test-flow", name: "Test Flow", + userId: this.userId, }); assert.ok(flowId, "flowId is not defined"); 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 85d9db8acb..256150002d 100644 --- a/e2e/tests/api-driven/src/invite-to-pay/helpers.ts +++ b/e2e/tests/api-driven/src/invite-to-pay/helpers.ts @@ -41,7 +41,7 @@ export async function buildITPFlow({ destination: string; userId: number; teamId: number; -}): Promise<{ flowId: string; publishedFlowId: number }> { +}): Promise<{ flowId: string }> { const sendNode = sendNodeWithDestination(destination); const flowGraph: FlowGraph = { ...inviteToPayFlowGraph, @@ -51,14 +51,11 @@ export async function buildITPFlow({ 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, + status: "online", + userId, }); - const publishedFlowId = await $admin.flow.publish({ - flow: { id: flowId, data: flowGraph }, - publisherId: userId, - }); - return { flowId, publishedFlowId }; + return { flowId }; } export async function buildSessionForFlow(flowId: string): Promise { diff --git a/e2e/tests/api-driven/src/invite-to-pay/steps.ts b/e2e/tests/api-driven/src/invite-to-pay/steps.ts index 7e6aa11899..80889d9be4 100644 --- a/e2e/tests/api-driven/src/invite-to-pay/steps.ts +++ b/e2e/tests/api-driven/src/invite-to-pay/steps.ts @@ -35,7 +35,7 @@ Given( "a session with a payment request for an invite to pay flow where {string} is a send destination", { timeout: 60 * 1000 }, async function (this: CustomWorld, destination: string) { - const { flowId, publishedFlowId } = await buildITPFlow({ + const { flowId } = await buildITPFlow({ destination, teamId: this.teamId, userId: this.userId, @@ -44,10 +44,6 @@ Given( if (!this.flowId) { throw new Error("flow not found"); } - this.publishedFlowId = publishedFlowId; - if (!this.publishedFlowId) { - throw new Error("publishedFlowId not found"); - } this.sessionId = await buildSessionForFlow(this.flowId); if (!this.sessionId) { throw new Error("session not found"); diff --git a/e2e/tests/api-driven/src/permissions/helpers.ts b/e2e/tests/api-driven/src/permissions/helpers.ts index 85c24127ae..74132c7b9d 100644 --- a/e2e/tests/api-driven/src/permissions/helpers.ts +++ b/e2e/tests/api-driven/src/permissions/helpers.ts @@ -36,6 +36,7 @@ export const setup = async () => { teamId: teamId1, slug: "team-1-flow", name: "Team 1 Flow", + userId: user1Id, }); const user2Id = await createUser({ @@ -46,6 +47,7 @@ export const setup = async () => { teamId: teamId2, slug: "team-2-flow", name: "Team 2 Flow", + userId: user2Id, }); const world = { diff --git a/e2e/tests/ui-driven/package.json b/e2e/tests/ui-driven/package.json index e0d02121e1..6cb5dd3222 100644 --- a/e2e/tests/ui-driven/package.json +++ b/e2e/tests/ui-driven/package.json @@ -9,7 +9,7 @@ }, "type": "module", "dependencies": { - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#03de3e0", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#db49201", "axios": "^1.7.4", "dotenv": "^16.3.1", "eslint": "^8.56.0", diff --git a/e2e/tests/ui-driven/pnpm-lock.yaml b/e2e/tests/ui-driven/pnpm-lock.yaml index 5bb697c7c5..ba317d4700 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#03de3e0 - version: github.com/theopensystemslab/planx-core/03de3e0(@types/react@19.0.7) + specifier: git+https://github.com/theopensystemslab/planx-core#db49201 + version: github.com/theopensystemslab/planx-core/db49201(@types/react@19.0.7) axios: specifier: ^1.7.4 version: 1.7.4 @@ -318,34 +318,6 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: false - /@floating-ui/core@1.6.9: - resolution: {integrity: sha512-uMXCuQ3BItDUbAMhIXw7UPXRfAlOAvZzdK9BWpE60MCn+Svt3aLn9jsPTi/WNGlRUu2uI0v5S7JiIUsbsvh3fw==} - dependencies: - '@floating-ui/utils': 0.2.9 - dev: false - - /@floating-ui/dom@1.6.13: - resolution: {integrity: sha512-umqzocjDgNRGTuO7Q8CU32dkHkECqI8ZdMZ5Swb6QAM0t5rnlrN3lGo1hdpscRd3WS8T6DKYK4ephgIH9iRh3w==} - dependencies: - '@floating-ui/core': 1.6.9 - '@floating-ui/utils': 0.2.9 - dev: false - - /@floating-ui/react-dom@2.1.2(react-dom@18.3.1)(react@18.3.1): - resolution: {integrity: sha512-06okr5cgPzMNBy+Ycse2A6udMi4bqwW/zgBF/rwjcNqWkyr82Mcg8b0vjX8OJpZFy/FKjJmw6wV7t44kK6kW7A==} - peerDependencies: - react: '>=16.8.0' - react-dom: '>=16.8.0' - dependencies: - '@floating-ui/dom': 1.6.13 - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - dev: false - - /@floating-ui/utils@0.2.9: - resolution: {integrity: sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg==} - dev: false - /@formatjs/ecma402-abstract@2.3.2: resolution: {integrity: sha512-6sE5nyvDloULiyOMbOTJEEgWL32w+VHkZQs8S02Lnn8Y/O5aQhjOEXwWzvR7SsBE/exxlSpY2EsWZgqHbtLatg==} dependencies: @@ -448,29 +420,6 @@ packages: resolution: {integrity: sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==} dev: false - /@mui/base@5.0.0-beta.60(@types/react@19.0.7)(react-dom@18.3.1)(react@18.3.1): - resolution: {integrity: sha512-w8twR3qCUI+uJHO5xDOuc1yB5l46KFbvNsTwIvEW9tQkKxVaiEFf2GAXHuvFJiHfZLqjzett6drZjghy8D1Z1A==} - engines: {node: '>=14.0.0'} - peerDependencies: - '@types/react': ^17.0.0 || ^18.0.0 - react: ^17.0.0 || ^18.0.0 - react-dom: ^17.0.0 || ^18.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - dependencies: - '@babel/runtime': 7.26.0 - '@floating-ui/react-dom': 2.1.2(react-dom@18.3.1)(react@18.3.1) - '@mui/types': 7.2.21(@types/react@19.0.7) - '@mui/utils': 6.4.1(@types/react@19.0.7)(react@18.3.1) - '@popperjs/core': 2.11.8 - '@types/react': 19.0.7 - clsx: 2.1.1 - prop-types: 15.8.1 - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - dev: false - /@mui/core-downloads-tracker@5.16.14: resolution: {integrity: sha512-sbjXW+BBSvmzn61XyTMun899E7nGPTXwqD9drm1jBUAvWEhJpPFIRxwQQiATWZnd9rvdxtnhhdsDxEGWI0jxqA==} dev: false @@ -611,26 +560,6 @@ packages: react-is: 19.0.0 dev: false - /@mui/utils@6.4.1(@types/react@19.0.7)(react@18.3.1): - resolution: {integrity: sha512-iQUDUeYh87SvR4lVojaRaYnQix8BbRV51MxaV6MBmqthecQoxwSbS5e2wnbDJUeFxY2ppV505CiqPLtd0OWkqw==} - engines: {node: '>=14.0.0'} - peerDependencies: - '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0 - react: ^17.0.0 || ^18.0.0 || ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - dependencies: - '@babel/runtime': 7.26.0 - '@mui/types': 7.2.21(@types/react@19.0.7) - '@types/prop-types': 15.7.14 - '@types/react': 19.0.7 - clsx: 2.1.1 - prop-types: 15.8.1 - react: 18.3.1 - react-is: 19.0.0 - dev: false - /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -2614,9 +2543,9 @@ packages: resolution: {integrity: sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==} dev: false - github.com/theopensystemslab/planx-core/03de3e0(@types/react@19.0.7): - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/03de3e0} - id: github.com/theopensystemslab/planx-core/03de3e0 + github.com/theopensystemslab/planx-core/db49201(@types/react@19.0.7): + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/db49201} + id: github.com/theopensystemslab/planx-core/db49201 name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true @@ -2625,7 +2554,6 @@ packages: '@emotion/react': 11.14.0(@types/react@19.0.7)(react@18.3.1) '@emotion/styled': 11.14.0(@emotion/react@11.14.0)(@types/react@19.0.7)(react@18.3.1) '@formatjs/intl-listformat': 7.7.9 - '@mui/base': 5.0.0-beta.60(@types/react@19.0.7)(react-dom@18.3.1)(react@18.3.1) '@mui/material': 5.16.14(@emotion/react@11.14.0)(@emotion/styled@11.14.0)(@types/react@19.0.7)(react-dom@18.3.1)(react@18.3.1) ajv: 8.17.1 ajv-formats: 2.1.1(ajv@8.17.1) diff --git a/e2e/tests/ui-driven/src/create-flow.spec.ts b/e2e/tests/ui-driven/src/create-flow.spec.ts index 7c6aad1663..151438a66b 100644 --- a/e2e/tests/ui-driven/src/create-flow.spec.ts +++ b/e2e/tests/ui-driven/src/create-flow.spec.ts @@ -114,39 +114,7 @@ test.describe("Flow creation, publish and preview", () => { ]); }); - test("Cannot preview an unpublished flow", async ({ - browser, - }: { - browser: Browser; - }) => { - const page = await createAuthenticatedSession({ - browser, - userId: context.user!.id!, - }); - - await page.goto( - `/${context.team.slug}/${serviceProps.slug}/published?analytics=false`, - ); - - await expect(page.getByText("Not Found")).toBeVisible(); - }); - - test("Publish a flow", async ({ browser }) => { - const page = await createAuthenticatedSession({ - browser, - userId: context.user!.id!, - }); - - await navigateToService(page, serviceProps.slug); - await publishService(page); - - const previewLink = page.getByRole("link", { - name: "Open published service", - }); - await expect(previewLink).toBeVisible(); - }); - - test("Cannot preview an offline flow", async ({ + test("Cannot preview an offline flow (published by default)", async ({ browser, }: { browser: Browser; diff --git a/e2e/tests/ui-driven/src/helpers/context.ts b/e2e/tests/ui-driven/src/helpers/context.ts index bd3377e5ae..2f68bb7551 100644 --- a/e2e/tests/ui-driven/src/helpers/context.ts +++ b/e2e/tests/ui-driven/src/helpers/context.ts @@ -85,13 +85,7 @@ export async function setUpTestContext( teamId: context.team.id, data: context.flow.data, status: "online", - }); - context.flow.publishedId = await $admin.flow.publish({ - flow: { - id: context.flow.id, - data: context.flow.data, - }, - publisherId: context.user!.id!, + userId: context.user!.id!, }); } await setupGovPaySecret($admin, context); diff --git a/editor.planx.uk/package.json b/editor.planx.uk/package.json index 437b8916b3..842fcaaaca 100644 --- a/editor.planx.uk/package.json +++ b/editor.planx.uk/package.json @@ -15,7 +15,7 @@ "@mui/material": "^5.15.10", "@mui/utils": "^5.15.11", "@opensystemslab/map": "1.0.0-alpha.4", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#03de3e0", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#db49201", "@tiptap/core": "^2.4.0", "@tiptap/extension-bold": "^2.0.3", "@tiptap/extension-bubble-menu": "^2.1.13", diff --git a/editor.planx.uk/pnpm-lock.yaml b/editor.planx.uk/pnpm-lock.yaml index 3b81c3f130..bbfc9344a8 100644 --- a/editor.planx.uk/pnpm-lock.yaml +++ b/editor.planx.uk/pnpm-lock.yaml @@ -48,8 +48,8 @@ dependencies: specifier: 1.0.0-alpha.4 version: 1.0.0-alpha.4 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#03de3e0 - version: github.com/theopensystemslab/planx-core/03de3e0(@types/react@18.2.45) + specifier: git+https://github.com/theopensystemslab/planx-core#db49201 + version: github.com/theopensystemslab/planx-core/db49201(@types/react@18.2.45) '@tiptap/core': specifier: ^2.4.0 version: 2.4.0(@tiptap/pm@2.0.3) @@ -3345,29 +3345,6 @@ packages: react-dom: 18.2.0(react@18.2.0) dev: false - /@mui/base@5.0.0-beta.60(@types/react@18.2.45)(react-dom@18.3.1)(react@18.3.1): - resolution: {integrity: sha512-w8twR3qCUI+uJHO5xDOuc1yB5l46KFbvNsTwIvEW9tQkKxVaiEFf2GAXHuvFJiHfZLqjzett6drZjghy8D1Z1A==} - engines: {node: '>=14.0.0'} - peerDependencies: - '@types/react': ^17.0.0 || ^18.0.0 - react: ^17.0.0 || ^18.0.0 - react-dom: ^17.0.0 || ^18.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - dependencies: - '@babel/runtime': 7.26.0 - '@floating-ui/react-dom': 2.1.2(react-dom@18.3.1)(react@18.3.1) - '@mui/types': 7.2.21(@types/react@18.2.45) - '@mui/utils': 6.4.1(@types/react@18.2.45)(react@18.3.1) - '@popperjs/core': 2.11.8 - '@types/react': 18.2.45 - clsx: 2.1.1 - prop-types: 15.8.1 - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - dev: false - /@mui/core-downloads-tracker@5.16.14: resolution: {integrity: sha512-sbjXW+BBSvmzn61XyTMun899E7nGPTXwqD9drm1jBUAvWEhJpPFIRxwQQiATWZnd9rvdxtnhhdsDxEGWI0jxqA==} dev: false @@ -3739,26 +3716,6 @@ packages: react-is: 19.0.0 dev: false - /@mui/utils@6.4.1(@types/react@18.2.45)(react@18.3.1): - resolution: {integrity: sha512-iQUDUeYh87SvR4lVojaRaYnQix8BbRV51MxaV6MBmqthecQoxwSbS5e2wnbDJUeFxY2ppV505CiqPLtd0OWkqw==} - engines: {node: '>=14.0.0'} - peerDependencies: - '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0 - react: ^17.0.0 || ^18.0.0 || ^19.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - dependencies: - '@babel/runtime': 7.26.0 - '@mui/types': 7.2.21(@types/react@18.2.45) - '@types/prop-types': 15.7.14 - '@types/react': 18.2.45 - clsx: 2.1.1 - prop-types: 15.8.1 - react: 18.3.1 - react-is: 19.0.0 - dev: false - /@nicolo-ribaudo/semver-v6@6.3.3: resolution: {integrity: sha512-3Yc1fUTs69MG/uZbJlLSI3JISMn2UV2rg+1D/vROUqZyh3l6iYHCs7GMp+M40ZD7yOdDbYjJcU1oTJhrc+dGKg==} hasBin: true @@ -14695,9 +14652,9 @@ packages: use-sync-external-store: 1.2.0(react@18.2.0) dev: false - github.com/theopensystemslab/planx-core/03de3e0(@types/react@18.2.45): - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/03de3e0} - id: github.com/theopensystemslab/planx-core/03de3e0 + github.com/theopensystemslab/planx-core/db49201(@types/react@18.2.45): + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/db49201} + id: github.com/theopensystemslab/planx-core/db49201 name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true 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 8cfc715239..7022960c3b 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts @@ -347,6 +347,8 @@ export const editorStore: StateCreator< }, }); + response = await get().publishFlow(id, "Created flow"); + return newSlug; },