Skip to content

Commit

Permalink
fix: Change to offline by default
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed May 21, 2024
1 parent 3856c52 commit 8dc5368
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 13 additions & 13 deletions e2e/tests/api-driven/src/flowStatusHistory/steps.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -18,21 +18,21 @@ Before<CustomWorld>("@flow-status-history", async function () {
this.teamId = teamId;
});

When<CustomWorld>("a new flow is added", async function () {
Given<CustomWorld>("a flow exists", async function () {
const flowId = await createFlow({ teamId: this.teamId, slug: "test-flow" });

assert.ok(flowId, "flowId is not defined");

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"`,
);
});

Expand All @@ -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,
Expand All @@ -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`,
);
});

Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand Down

0 comments on commit 8dc5368

Please sign in to comment.