From 9845e50887930d7f1b88269d7c38449f010910b6 Mon Sep 17 00:00:00 2001 From: Yousef Moazzam Date: Mon, 10 Aug 2026 12:55:04 +0100 Subject: [PATCH] Add workflow running status subscription test --- .../components/workflows/WorkflowStatus.tsx | 10 +-- .../tomography/tests/WorkflowStatus.test.tsx | 61 +++++++++++++++++++ 2 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 frontend/tomography/tests/WorkflowStatus.test.tsx diff --git a/frontend/tomography/src/components/workflows/WorkflowStatus.tsx b/frontend/tomography/src/components/workflows/WorkflowStatus.tsx index 4af3b8d..17e3d21 100644 --- a/frontend/tomography/src/components/workflows/WorkflowStatus.tsx +++ b/frontend/tomography/src/components/workflows/WorkflowStatus.tsx @@ -20,7 +20,7 @@ import type { WorkflowStatusSubscriptionSubscriptionVariables, } from "./__generated__/WorkflowStatus.generated"; -const WORKFLOW_STATUS_SUBSCRIPTION: TypedDocumentNode< +export const WORKFLOW_STATUS_SUBSCRIPTION: TypedDocumentNode< WorkflowStatusSubscriptionSubscription, WorkflowStatusSubscriptionSubscriptionVariables > = gql` @@ -38,8 +38,6 @@ const WORKFLOW_STATUS_SUBSCRIPTION: TypedDocumentNode< id name status - depends - dependencies stepType artifacts { name @@ -56,8 +54,6 @@ const WORKFLOW_STATUS_SUBSCRIPTION: TypedDocumentNode< id name status - depends - dependencies stepType artifacts { name @@ -74,8 +70,6 @@ const WORKFLOW_STATUS_SUBSCRIPTION: TypedDocumentNode< id name status - depends - dependencies stepType artifacts { name @@ -92,8 +86,6 @@ const WORKFLOW_STATUS_SUBSCRIPTION: TypedDocumentNode< id name status - depends - dependencies stepType artifacts { name diff --git a/frontend/tomography/tests/WorkflowStatus.test.tsx b/frontend/tomography/tests/WorkflowStatus.test.tsx new file mode 100644 index 0000000..24ec043 --- /dev/null +++ b/frontend/tomography/tests/WorkflowStatus.test.tsx @@ -0,0 +1,61 @@ +import React from "react"; +import { expect, test } from "vitest"; +import { render, screen } from "@testing-library/react"; +import { MockedProvider } from "@apollo/client/testing/react"; +import WorkflowStatus, { + WORKFLOW_STATUS_SUBSCRIPTION, +} from "../src/components/workflows/WorkflowStatus"; + +const WORKFLOW_NAME = "httomo-cor-sweep-abcde"; +const VISIT = { proposalCode: "cm", proposalNumber: 40628, number: 3 }; + +const mocks = [ + { + request: { + query: WORKFLOW_STATUS_SUBSCRIPTION, + variables: { + name: WORKFLOW_NAME, + visit: VISIT, + }, + }, + result: { + data: { + workflow: { + status: { + __typename: "WorkflowRunningStatus", + startTime: "", + message: "Workflow is running", + tasks: [ + { + id: 0, + name: "task-0", + status: "WorkflowRunningStatus", + stepType: "Pod", + artifacts: [ + { + name: "some-artifact", + url: "https://some-artifact", + mimeType: "image/png", + }, + ], + }, + ], + }, + }, + }, + }, + }, +]; + +test("running workflow status from subscription displays running in status chip", async () => { + render( + + + + ); + + expect(await screen.findByText("Running")).toBeDefined(); +});