diff --git a/e2e/tests/api-driven/src/flowStatusHistory/flowStatusHistory.feature b/e2e/tests/api-driven/src/flowStatusHistory/flowStatusHistory.feature index 701b0f4d3a..95cf70321b 100644 --- a/e2e/tests/api-driven/src/flowStatusHistory/flowStatusHistory.feature +++ b/e2e/tests/api-driven/src/flowStatusHistory/flowStatusHistory.feature @@ -2,13 +2,13 @@ Feature: Flow status history @regression @flow-status-history Scenario: Creating a flow - When a new flow is added - Then the status of the flow is online by default + Given a flow exists + Then the status of the flow is offline by default And a flow_status_history record is created @regression @flow-status-history Scenario: Updating a flow - When a new flow is added - And the flow status is changed to offline + Given a flow exists + When the flow status is changed to online Then the open flow_status_history record is updated And a new flow_status_history record is created \ No newline at end of file diff --git a/e2e/tests/api-driven/src/flowStatusHistory/steps.ts b/e2e/tests/api-driven/src/flowStatusHistory/steps.ts index 38cf000668..bd36d3e407 100644 --- a/e2e/tests/api-driven/src/flowStatusHistory/steps.ts +++ b/e2e/tests/api-driven/src/flowStatusHistory/steps.ts @@ -1,4 +1,4 @@ -import { When, Then, World, After, Before } from "@cucumber/cucumber"; +import { When, Then, World, After, Before, Given } from "@cucumber/cucumber"; import assert from "assert"; import { cleanup, getFlowStatus, getFlowStatusHistory, setup } from "./helpers"; import { createFlow } from "../globalHelpers"; @@ -18,7 +18,7 @@ Before("@flow-status-history", async function () { this.teamId = teamId; }); -When("a new flow is added", async function () { +Given("a flow exists", async function () { const flowId = await createFlow({ teamId: this.teamId, slug: "test-flow" }); assert.ok(flowId, "flowId is not defined"); @@ -26,13 +26,13 @@ When("a new flow is added", async function () { this.flowId = flowId; }); -Then("the status of the flow is online by default", async function () { +Then("the status of the flow is offline by default", async function () { const status = await getFlowStatus(this.flowId); assert.equal( status, - "online", - `Flow status is ${status} - it should be "online"`, + "offline", + `Flow status is ${status} - it should be "offline"`, ); }); @@ -52,8 +52,8 @@ Then("a flow_status_history record is created", async function () { assert.ok(flowStatusHistory[0], "flow_status_history record not created"); assert.equal( flowStatusHistory[0].status, - "online", - `Flow status is ${flowStatusHistory[0].status} - it should be "online"`, + "offline", + `Flow status is ${flowStatusHistory[0].status} - it should be "offline"`, ); assert.notEqual( flowStatusHistory[0].eventStart, @@ -67,16 +67,16 @@ Then("a flow_status_history record is created", async function () { ); }); -When("the flow status is changed to offline", async function () { +When("the flow status is changed to online", async function () { const flow = await $admin.flow.setStatus({ flow: { id: this.flowId }, - status: "offline", + status: "online", }); assert.ok(flow, "Flow not defined after setStatus()"); assert.equal( flow.status, - "offline", - `Flow status is ${flow.status} - it should be "offline`, + "online", + `Flow status is ${flow.status} - it should be "online`, ); }); @@ -94,8 +94,8 @@ Then("a new flow_status_history record is created", async function () { assert.ok(flowStatusHistory[1], "flow_status_history record not created"); assert.equal( flowStatusHistory[1].status, - "online", - `Flow status is ${flowStatusHistory[1].status} - it should be "online"`, + "offline", + `Flow status is ${flowStatusHistory[1].status} - it should be "offline"`, ); assert.notEqual( flowStatusHistory[1].eventStart, diff --git a/hasura.planx.uk/migrations/1715954131936_create_table_public_flow_status_enum/up.sql b/hasura.planx.uk/migrations/1715954131936_create_table_public_flow_status_enum/up.sql index b8666c1f42..14176cc170 100644 --- a/hasura.planx.uk/migrations/1715954131936_create_table_public_flow_status_enum/up.sql +++ b/hasura.planx.uk/migrations/1715954131936_create_table_public_flow_status_enum/up.sql @@ -12,7 +12,7 @@ INSERT INTO "public"."flow_status_enum"("value", "comment") VALUES (E'offline', -- Add flow.status column alter table "public"."flows" add column "status" text - not null default 'online'; + not null default 'offline'; alter table "public"."flows" add constraint "flows_status_fkey" @@ -37,7 +37,7 @@ CREATE TABLE "public"."flow_status_history" ( COMMENT ON TABLE "public"."flow_status_history" IS E'Temporal table to track the status of a flow over time'; -- Populate initial table values --- All flows have had status "online" since they were created +-- All existing flows have had status "online" since they were created INSERT INTO flow_status_history (flow_id, status, event_start) SELECT id, 'online', created_at FROM flows;