diff --git a/e2e/tests/api-driven/src/demo-workspace/helper.ts b/e2e/tests/api-driven/src/demo-workspace/helper.ts index 969d7cc0bc..f18a32a07b 100644 --- a/e2e/tests/api-driven/src/demo-workspace/helper.ts +++ b/e2e/tests/api-driven/src/demo-workspace/helper.ts @@ -80,42 +80,43 @@ export const createFlowFromArray = async ( client, flow: DataTableRecord, ): Promise => { - const flowId = await createFlow(client, { - teamId: Number(flow.team_id), - name: flow.name, - slug: flow.slug, - }); - return flowId; + try { + const flowId = await createFlow(client, { + teamId: Number(flow.team_id), + name: flow.name, + slug: flow.slug, + }); + return flowId; + } catch (error: any) { + console.error(`Error adding flow ${flow.slug}`, error.message); + return false; + } }; export const createFlow = async ( client, args: FlowArgs, ): Promise => { - try { - const { flow } = await client.request( - gql` - mutation InsertFlow($teamId: Int!, $slug: String!, $name: String!) { - flow: insert_flows_one( - object: { team_id: $teamId, slug: $slug, name: $name } - ) { - id - slug - creator_id - } + const { flow } = await client.request( + gql` + mutation InsertFlow($teamId: Int!, $slug: String!, $name: String!) { + flow: insert_flows_one( + object: { team_id: $teamId, slug: $slug, name: $name } + ) { + id + slug + creator_id } - `, - { - teamId: args.teamId, - slug: args.slug, - name: args.name, - }, - ); + } + `, + { + teamId: args.teamId, + slug: args.slug, + name: args.name, + }, + ); - return flow; - } catch (error) { - return false; - } + return flow; }; export async function createUser(args: Omit): Promise { diff --git a/e2e/tests/api-driven/src/demo-workspace/steps/background_steps.ts b/e2e/tests/api-driven/src/demo-workspace/steps/background_steps.ts index d85d51380b..ae33e477b6 100644 --- a/e2e/tests/api-driven/src/demo-workspace/steps/background_steps.ts +++ b/e2e/tests/api-driven/src/demo-workspace/steps/background_steps.ts @@ -86,6 +86,11 @@ Given( if (otherTeam) this.otherTeam = otherTeam; assert.ok(getTeamsArray, "Teams have not been added correctly"); + assert.equal( + getTeamsArray.length, + teamsArray.length, + "Not all teams have been added", + ); }, ); @@ -114,9 +119,12 @@ Given( assert.equal( newFlowArray.length, expectedFlowLength, - "Flows have not been added correctly", + "Not all the flows have been added", + ); + assert.ok( + newFlowArray.every((result) => result !== false), + "Flows have not been added successfully", ); - assert.ok(newFlowArray.every((result) => result !== false)); }, ); diff --git a/e2e/tests/api-driven/src/demo-workspace/steps/verification_steps.ts b/e2e/tests/api-driven/src/demo-workspace/steps/verification_steps.ts index ff5f3bd9df..dbdd10709c 100644 --- a/e2e/tests/api-driven/src/demo-workspace/steps/verification_steps.ts +++ b/e2e/tests/api-driven/src/demo-workspace/steps/verification_steps.ts @@ -4,6 +4,7 @@ import { strict as assert } from "node:assert"; import { createFlow, deleteFlow, + Flow, getFlowBySlug, updateFlow, updateTeamSettings, @@ -45,11 +46,16 @@ Then("I should not access the Other Team", async function (this) { }); Then("I should not succeed", async function (this) { - const hasSucceeded = await createFlow(this.demoClient, { - name: "Bad flow", - slug: "bad-flow", - teamId: this.insertFlowTeamId, - }); + let hasSucceeded: Flow | false; + try { + hasSucceeded = await createFlow(this.demoClient, { + name: "Bad flow", + slug: "bad-flow", + teamId: this.insertFlowTeamId, + }); + } catch (error) { + hasSucceeded = false; + } assert.ok(!hasSucceeded, "Flow was able to be created on this team"); });