From deefde71aaa8c683325494c3adabcc2fb6eda8fd Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Mon, 2 Dec 2024 12:44:19 +0000 Subject: [PATCH] add new comments and changes --- e2e/tests/ui-driven/src/create-flow.spec.ts | 4 + e2e/tests/ui-driven/src/helpers/context.ts | 153 +------------------- 2 files changed, 5 insertions(+), 152 deletions(-) diff --git a/e2e/tests/ui-driven/src/create-flow.spec.ts b/e2e/tests/ui-driven/src/create-flow.spec.ts index 2f83e90e85..f681ad01de 100644 --- a/e2e/tests/ui-driven/src/create-flow.spec.ts +++ b/e2e/tests/ui-driven/src/create-flow.spec.ts @@ -208,17 +208,21 @@ test.describe("Flow creation, publish and preview", () => { answers[1], ]); + // We are publishing the Ext Portal service and turning it online await publishService(page); await turnServiceOnline(page); + // We switch back to the original service await navigateToService(page, serviceProps.slug); + // Add our ext portal to the middle of the service await createExternalPortal(page, page.locator("li:nth-child(6)")); await expect( page.getByRole("link", { name: "E2E/an-external-portal-service" }), ).toBeVisible(); + // publish the changes we've made to the original service await publishService(page); }); diff --git a/e2e/tests/ui-driven/src/helpers/context.ts b/e2e/tests/ui-driven/src/helpers/context.ts index 6db53a36dd..792a99a1ed 100644 --- a/e2e/tests/ui-driven/src/helpers/context.ts +++ b/e2e/tests/ui-driven/src/helpers/context.ts @@ -2,8 +2,7 @@ import { CoreDomainClient } from "@opensystemslab/planx-core"; import { GraphQLClient, gql } from "graphql-request"; import { sign } from "jsonwebtoken"; import assert from "node:assert"; -import { log } from "./globalHelpers"; -import { Flow, TestContext } from "./types"; +import { TestContext } from "./types"; export const contextDefaults: TestContext = { user: { @@ -159,156 +158,6 @@ export async function findSessionId( } } -async function deleteSession(adminGQLClient: GraphQLClient, context) { - if (context.sessionIds) { - for (const sessionId of context.sessionIds) { - await adminGQLClient.request( - `mutation DeleteTestSession( $sessionId: uuid!) { - delete_lowcal_sessions_by_pk(id: $sessionId) { - id - } - }`, - { sessionId }, - ); - } - } - const sessionId = await findSessionId(adminGQLClient, context); - if (sessionId) { - log(`deleting session id: ${sessionId}`); - await adminGQLClient.request( - `mutation DeleteTestSession( $sessionId: uuid!) { - delete_lowcal_sessions_by_pk(id: $sessionId) { - id - } - }`, - { sessionId }, - ); - } -} - -async function deletePublishedFlow(adminGQLClient: GraphQLClient, flow: Flow) { - if (flow?.publishedId) { - log(`deleting published flow ${flow?.publishedId}`); - await adminGQLClient.request( - `mutation DeleteTestPublishedFlow( $publishedFlowId: Int!) { - delete_published_flows_by_pk(id: $publishedFlowId) { - id - } - }`, - { publishedFlowId: flow?.publishedId }, - ); - } -} - -async function deleteFlow(adminGQLClient: GraphQLClient, flow: Flow) { - if (flow?.id) { - log(`deleting flow ${flow?.id}`); - await adminGQLClient.request( - `mutation DeleteTestFlow($flowId: uuid!) { - delete_flows_by_pk(id: $flowId) { - id - } - }`, - { flowId: flow?.id }, - ); - } else if (flow?.slug) { - // try deleting via slug (when cleaning up from a previously failed test) - const response: { flows: { id: string }[] } = await adminGQLClient.request( - `query GetFlowBySlug($slug: String!) { - flows(where: {slug: {_eq: $slug}}) { - id - } - }`, - { slug: flow?.slug }, - ); - if (response.flows.length && response.flows[0].id) { - log(`deleting flow ${flow?.slug} flowId: ${response.flows[0].id}`); - await adminGQLClient.request( - `mutation DeleteTestFlow( $flowId: uuid!) { - delete_flows_by_pk(id: $flowId) { - id - } - }`, - { flowId: response.flows[0].id }, - ); - } - } -} - -async function deleteUser(adminGQLClient: GraphQLClient, context: TestContext) { - if (context.user?.id) { - log(`deleting user ${context.user?.id}`); - await adminGQLClient.request( - `mutation DeleteTestUser($userId: Int!) { - delete_users_by_pk(id: $userId) { - id - } - }`, - { userId: context.user?.id }, - ); - } else if (context.user?.email) { - // try deleting via email (when cleaning up from a previously failed test) - const response: { users: { id: number }[] } = await adminGQLClient.request( - `query GetUserByEmail($email: String!) { - users(where: {email: {_eq: $email}}) { - id - } - }`, - { email: context.user?.email }, - ); - if (response.users.length && response.users[0].id) { - log( - `deleting user ${context.user?.email} userId: ${response.users[0].id}`, - ); - await adminGQLClient.request( - `mutation DeleteTestUser($userId: Int!) { - delete_users_by_pk(id: $userId) { - id - } - }`, - { userId: response.users[0].id }, - ); - } - } -} - -async function deleteTeam(adminGQLClient: GraphQLClient, context: TestContext) { - if (context.team?.id) { - log(`deleting team ${context.team?.id}`); - await adminGQLClient.request( - `mutation DeleteTestTeam( $teamId: Int!) { - delete_teams_by_pk(id: $teamId) { - id - } - }`, - { teamId: context.team?.id }, - ); - } else if (context.team?.slug) { - // try deleting via slug (when cleaning up from a previously failed test) - const response: { teams: { id: number }[] } = await adminGQLClient.request( - `query GetTeamBySlug( $slug: String!) { - teams(where: {slug: {_eq: $slug}}) { - id - } - }`, - { slug: context.team?.slug }, - ); - if (response.teams.length && response.teams[0].id) { - log( - `deleting team ${context.team?.slug} teamId: ${response.teams[0].id}`, - ); - await adminGQLClient.request( - `mutation DeleteTestTeam( $teamId: Int!) { - delete_teams_by_pk(id: $teamId) { - id - } - }`, - { teamId: response.teams[0].id }, - ); - } - } -} - async function setupGovPaySecret( $admin: CoreDomainClient, context: TestContext,