From 7b1e792a5c7ee6d2b1a7b2c4ac5d3bacdc21c99e Mon Sep 17 00:00:00 2001 From: Devin Villarosa Date: Fri, 27 Dec 2024 14:00:48 -0800 Subject: [PATCH] moving mocks to a central area --- ...y-limits-create-or-edit-dialog.stories.tsx | 6 +- ...-concurrency-limits-data-table.stories.tsx | 7 +- ...ncurrency-limits-delete-dialog.stories.tsx | 6 +- ...urrency-limit-active-task-runs.stories.tsx | 9 +- ...-run-concurrency-limit-details.stories.tsx | 2 +- ...k-run-concurrency-limit-header.stories.tsx | 7 +- ...-concurrency-limits-data-table.stories.tsx | 7 +- ...ncurrency-limits-delete-dialog.stories.tsx | 6 +- ...concurrency-limit-reset-dialog.stories.tsx | 6 +- .../ui/run-card/run-card.stories.tsx | 10 +- .../hooks/global-concurrency-limits.test.ts | 52 ++--- .../task-run-concurrency-limits.test.tsx | 182 ++---------------- .../utils => }/mocks/create-fake-flow-run.ts | 0 .../utils => }/mocks/create-fake-flow.ts | 0 .../create-fake-global-concurrency-limit.ts | 0 .../utils => }/mocks/create-fake-state.ts | 0 .../create-fake-take-run-concurrency-limit.ts | 0 .../utils => }/mocks/create-fake-task-run.ts | 0 ui-v2/src/mocks/index.ts | 6 + ui-v2/src/storybook/utils/index.ts | 7 - 20 files changed, 61 insertions(+), 252 deletions(-) rename ui-v2/src/{storybook/utils => }/mocks/create-fake-flow-run.ts (100%) rename ui-v2/src/{storybook/utils => }/mocks/create-fake-flow.ts (100%) rename ui-v2/src/{storybook/utils => }/mocks/create-fake-global-concurrency-limit.ts (100%) rename ui-v2/src/{storybook/utils => }/mocks/create-fake-state.ts (100%) rename ui-v2/src/{storybook/utils => }/mocks/create-fake-take-run-concurrency-limit.ts (100%) rename ui-v2/src/{storybook/utils => }/mocks/create-fake-task-run.ts (100%) create mode 100644 ui-v2/src/mocks/index.ts diff --git a/ui-v2/src/components/concurrency/global-concurrency-limits/global-concurrency-limits-create-or-edit-dialog/global-concurrency-limits-create-or-edit-dialog.stories.tsx b/ui-v2/src/components/concurrency/global-concurrency-limits/global-concurrency-limits-create-or-edit-dialog/global-concurrency-limits-create-or-edit-dialog.stories.tsx index b1d648b8fbbb..b0cc2f9ee464 100644 --- a/ui-v2/src/components/concurrency/global-concurrency-limits/global-concurrency-limits-create-or-edit-dialog/global-concurrency-limits-create-or-edit-dialog.stories.tsx +++ b/ui-v2/src/components/concurrency/global-concurrency-limits/global-concurrency-limits-create-or-edit-dialog/global-concurrency-limits-create-or-edit-dialog.stories.tsx @@ -1,7 +1,5 @@ -import { - createFakeGlobalConcurrencyLimit, - reactQueryDecorator, -} from "@/storybook/utils"; +import { createFakeGlobalConcurrencyLimit } from "@/mocks"; +import { reactQueryDecorator } from "@/storybook/utils"; import type { Meta, StoryObj } from "@storybook/react"; import { fn } from "@storybook/test"; import { GlobalConcurrencyLimitsCreateOrEditDialog } from "./global-concurrency-limits-create-or-edit-dialog"; diff --git a/ui-v2/src/components/concurrency/global-concurrency-limits/global-concurrency-limits-data-table/global-concurrency-limits-data-table.stories.tsx b/ui-v2/src/components/concurrency/global-concurrency-limits/global-concurrency-limits-data-table/global-concurrency-limits-data-table.stories.tsx index 08b27cf793e2..0f490e7192fb 100644 --- a/ui-v2/src/components/concurrency/global-concurrency-limits/global-concurrency-limits-data-table/global-concurrency-limits-data-table.stories.tsx +++ b/ui-v2/src/components/concurrency/global-concurrency-limits/global-concurrency-limits-data-table/global-concurrency-limits-data-table.stories.tsx @@ -1,8 +1,5 @@ -import { - createFakeGlobalConcurrencyLimit, - reactQueryDecorator, - toastDecorator, -} from "@/storybook/utils"; +import { createFakeGlobalConcurrencyLimit } from "@/mocks"; +import { reactQueryDecorator, toastDecorator } from "@/storybook/utils"; import type { Meta, StoryObj } from "@storybook/react"; import { fn } from "@storybook/test"; import { Table as GlobalConcurrencyLimitsDataTable } from "./global-concurrency-limits-data-table"; diff --git a/ui-v2/src/components/concurrency/global-concurrency-limits/global-concurrency-limits-delete-dialog/global-concurrency-limits-delete-dialog.stories.tsx b/ui-v2/src/components/concurrency/global-concurrency-limits/global-concurrency-limits-delete-dialog/global-concurrency-limits-delete-dialog.stories.tsx index 98ed01714926..9a383286d5ff 100644 --- a/ui-v2/src/components/concurrency/global-concurrency-limits/global-concurrency-limits-delete-dialog/global-concurrency-limits-delete-dialog.stories.tsx +++ b/ui-v2/src/components/concurrency/global-concurrency-limits/global-concurrency-limits-delete-dialog/global-concurrency-limits-delete-dialog.stories.tsx @@ -1,7 +1,5 @@ -import { - createFakeGlobalConcurrencyLimit, - reactQueryDecorator, -} from "@/storybook/utils"; +import { createFakeGlobalConcurrencyLimit } from "@/mocks"; +import { reactQueryDecorator } from "@/storybook/utils"; import type { Meta, StoryObj } from "@storybook/react"; import { fn } from "@storybook/test"; import { GlobalConcurrencyLimitsDeleteDialog } from "./global-concurrency-limits-delete-dialog"; diff --git a/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limit-active-task-runs/task-run-concurrency-limit-active-task-runs.stories.tsx b/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limit-active-task-runs/task-run-concurrency-limit-active-task-runs.stories.tsx index 3b2b18a5769b..9382eb623cb0 100644 --- a/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limit-active-task-runs/task-run-concurrency-limit-active-task-runs.stories.tsx +++ b/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limit-active-task-runs/task-run-concurrency-limit-active-task-runs.stories.tsx @@ -1,12 +1,7 @@ +import { createFakeFlow, createFakeFlowRun, createFakeTaskRun } from "@/mocks"; +import { routerDecorator } from "@/storybook/utils"; import type { Meta, StoryObj } from "@storybook/react"; -import { - createFakeFlow, - createFakeFlowRun, - createFakeTaskRun, - routerDecorator, -} from "@/storybook/utils"; - import { TaskRunConcurrencyLimitActiveTaskRuns } from "./task-run-concurrency-limit-active-task-runs"; const MOCK_DATA = [ diff --git a/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limit-details/task-run-concurrency-limit-details.stories.tsx b/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limit-details/task-run-concurrency-limit-details.stories.tsx index 50ffa97467d8..92543ee5567c 100644 --- a/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limit-details/task-run-concurrency-limit-details.stories.tsx +++ b/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limit-details/task-run-concurrency-limit-details.stories.tsx @@ -1,4 +1,4 @@ -import { createFakeTaskRunConcurrencyLimit } from "@/storybook/utils"; +import { createFakeTaskRunConcurrencyLimit } from "@/mocks"; import type { Meta, StoryObj } from "@storybook/react"; import { TaskRunConcurrencyLimitDetails } from "./task-run-concurrency-limit-details"; diff --git a/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limit-header/task-run-concurrency-limit-header.stories.tsx b/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limit-header/task-run-concurrency-limit-header.stories.tsx index f67f06081a5d..465309a04514 100644 --- a/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limit-header/task-run-concurrency-limit-header.stories.tsx +++ b/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limit-header/task-run-concurrency-limit-header.stories.tsx @@ -1,8 +1,5 @@ -import { - createFakeTaskRunConcurrencyLimit, - routerDecorator, - toastDecorator, -} from "@/storybook/utils"; +import { createFakeTaskRunConcurrencyLimit } from "@/mocks"; +import { routerDecorator, toastDecorator } from "@/storybook/utils"; import type { Meta, StoryObj } from "@storybook/react"; import { fn } from "@storybook/test"; diff --git a/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limits-data-table/task-run-concurrency-limits-data-table.stories.tsx b/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limits-data-table/task-run-concurrency-limits-data-table.stories.tsx index b210b6648154..e3c23a5160e2 100644 --- a/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limits-data-table/task-run-concurrency-limits-data-table.stories.tsx +++ b/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limits-data-table/task-run-concurrency-limits-data-table.stories.tsx @@ -1,8 +1,5 @@ -import { - createFakeTaskRunConcurrencyLimit, - routerDecorator, - toastDecorator, -} from "@/storybook/utils"; +import { createFakeTaskRunConcurrencyLimit } from "@/mocks"; +import { routerDecorator, toastDecorator } from "@/storybook/utils"; import type { Meta, StoryObj } from "@storybook/react"; import { fn } from "@storybook/test"; import { Table as TaskRunConcurrencyLimitsDataTable } from "./task-run-concurrency-limits-data-table"; diff --git a/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limits-delete-dialog/task-run-concurrency-limits-delete-dialog.stories.tsx b/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limits-delete-dialog/task-run-concurrency-limits-delete-dialog.stories.tsx index be9f881c2d73..1b15b12cf447 100644 --- a/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limits-delete-dialog/task-run-concurrency-limits-delete-dialog.stories.tsx +++ b/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limits-delete-dialog/task-run-concurrency-limits-delete-dialog.stories.tsx @@ -1,7 +1,5 @@ -import { - createFakeTaskRunConcurrencyLimit, - reactQueryDecorator, -} from "@/storybook/utils"; +import { createFakeTaskRunConcurrencyLimit } from "@/mocks"; +import { reactQueryDecorator } from "@/storybook/utils"; import type { Meta, StoryObj } from "@storybook/react"; import { fn } from "@storybook/test"; import { TaskRunConcurrencyLimitsDeleteDialog } from "./task-run-concurrency-limits-delete-dialog"; diff --git a/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limits-reset-dialog/task-run-concurrency-limit-reset-dialog.stories.tsx b/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limits-reset-dialog/task-run-concurrency-limit-reset-dialog.stories.tsx index cf6578b3888d..4fbe049046dc 100644 --- a/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limits-reset-dialog/task-run-concurrency-limit-reset-dialog.stories.tsx +++ b/ui-v2/src/components/concurrency/task-run-concurrency-limits/task-run-concurrency-limits-reset-dialog/task-run-concurrency-limit-reset-dialog.stories.tsx @@ -1,7 +1,5 @@ -import { - createFakeTaskRunConcurrencyLimit, - reactQueryDecorator, -} from "@/storybook/utils"; +import { createFakeTaskRunConcurrencyLimit } from "@/mocks"; +import { reactQueryDecorator } from "@/storybook/utils"; import type { Meta, StoryObj } from "@storybook/react"; import { fn } from "@storybook/test"; import { TaskRunConcurrencyLimitsResetDialog } from "./task-run-concurrency-limits-reset-dialog"; diff --git a/ui-v2/src/components/ui/run-card/run-card.stories.tsx b/ui-v2/src/components/ui/run-card/run-card.stories.tsx index 40e861224968..1ea779b7e871 100644 --- a/ui-v2/src/components/ui/run-card/run-card.stories.tsx +++ b/ui-v2/src/components/ui/run-card/run-card.stories.tsx @@ -1,12 +1,6 @@ +import { createFakeFlow, createFakeFlowRun, createFakeTaskRun } from "@/mocks"; +import { routerDecorator } from "@/storybook/utils"; import type { Meta, StoryObj } from "@storybook/react"; - -import { - createFakeFlow, - createFakeFlowRun, - createFakeTaskRun, - routerDecorator, -} from "@/storybook/utils"; - import { RunCard } from "./run-card"; const meta: Meta = { diff --git a/ui-v2/src/hooks/global-concurrency-limits.test.ts b/ui-v2/src/hooks/global-concurrency-limits.test.ts index 8b98bcc09960..16780f1f00a7 100644 --- a/ui-v2/src/hooks/global-concurrency-limits.test.ts +++ b/ui-v2/src/hooks/global-concurrency-limits.test.ts @@ -4,6 +4,7 @@ import { createWrapper, server } from "@tests/utils"; import { http, HttpResponse } from "msw"; import { describe, expect, it } from "vitest"; +import { createFakeGlobalConcurrencyLimit } from "@/mocks"; import { type GlobalConcurrencyLimit, queryKeyFactory, @@ -14,18 +15,10 @@ import { } from "./global-concurrency-limits"; describe("global concurrency limits hooks", () => { - const seedGlobalConcurrencyLimits = () => [ - { - id: "0", - created: "2021-01-01T00:00:00Z", - updated: "2021-01-01T00:00:00Z", - active: false, - name: "global concurrency limit 0", - limit: 0, - active_slots: 0, - slot_decay_per_second: 0, - }, - ]; + const MOCK_DATA = createFakeGlobalConcurrencyLimit({ + id: "0", + }); + const seedData = () => [MOCK_DATA]; const mockFetchGlobalConcurrencyLimitsAPI = ( globalConcurrencyLimits: Array, @@ -50,7 +43,7 @@ describe("global concurrency limits hooks", () => { */ it("is stores list data into the appropriate list query when using useQuery()", async () => { // ------------ Mock API requests when cache is empty - const mockList = seedGlobalConcurrencyLimits(); + const mockList = seedData(); mockFetchGlobalConcurrencyLimitsAPI(mockList); // ------------ Initialize hooks to test @@ -73,16 +66,11 @@ describe("global concurrency limits hooks", () => { const queryClient = new QueryClient(); // ------------ Mock API requests after queries are invalidated - const mockData = seedGlobalConcurrencyLimits().filter( - (limit) => limit.id !== ID_TO_DELETE, - ); + const mockData = seedData().filter((limit) => limit.id !== ID_TO_DELETE); mockFetchGlobalConcurrencyLimitsAPI(mockData); // ------------ Initialize cache - queryClient.setQueryData( - queryKeyFactory.list(filter), - seedGlobalConcurrencyLimits(), - ); + queryClient.setQueryData(queryKeyFactory.list(filter), seedData()); // ------------ Initialize hooks to test const { result: useListGlobalConcurrencyLimitsResult } = renderHook( @@ -129,23 +117,16 @@ describe("global concurrency limits hooks", () => { }; // ------------ Mock API requests after queries are invalidated - const NEW_LIMIT_DATA = { - ...MOCK_NEW_LIMIT, + const NEW_LIMIT_DATA = createFakeGlobalConcurrencyLimit({ id: MOCK_NEW_LIMIT_ID, - created: "2021-01-01T00:00:00Z", - updated: "2021-01-01T00:00:00Z", - active_slots: 0, - slot_decay_per_second: 0, - }; + ...MOCK_NEW_LIMIT, + }); - const mockData = [...seedGlobalConcurrencyLimits(), NEW_LIMIT_DATA]; + const mockData = [...seedData(), NEW_LIMIT_DATA]; mockFetchGlobalConcurrencyLimitsAPI(mockData); // ------------ Initialize cache - queryClient.setQueryData( - queryKeyFactory.list(filter), - seedGlobalConcurrencyLimits(), - ); + queryClient.setQueryData(queryKeyFactory.list(filter), seedData()); // ------------ Initialize hooks to test const { result: useListGlobalConcurrencyLimitsResult } = renderHook( @@ -201,17 +182,14 @@ describe("global concurrency limits hooks", () => { }; // ------------ Mock API requests after queries are invalidated - const mockData = seedGlobalConcurrencyLimits().map((limit) => + const mockData = seedData().map((limit) => limit.id === MOCK_UPDATE_LIMIT_ID ? UPDATED_LIMIT : limit, ); mockFetchGlobalConcurrencyLimitsAPI(mockData); // ------------ Initialize cache - queryClient.setQueryData( - queryKeyFactory.list(filter), - seedGlobalConcurrencyLimits(), - ); + queryClient.setQueryData(queryKeyFactory.list(filter), seedData()); // ------------ Initialize hooks to test const { result: useListGlobalConcurrencyLimitsResult } = renderHook( diff --git a/ui-v2/src/hooks/task-run-concurrency-limits.test.tsx b/ui-v2/src/hooks/task-run-concurrency-limits.test.tsx index 58529dce8b20..b328c25dfba0 100644 --- a/ui-v2/src/hooks/task-run-concurrency-limits.test.tsx +++ b/ui-v2/src/hooks/task-run-concurrency-limits.test.tsx @@ -1,4 +1,10 @@ import { components } from "@/api/prefect"; +import { + createFakeFlow, + createFakeFlowRun, + createFakeTaskRun, + createFakeTaskRunConcurrencyLimit, +} from "@/mocks"; import { QueryClient, useSuspenseQuery } from "@tanstack/react-query"; import { act, renderHook, waitFor } from "@testing-library/react"; import { createWrapper, server } from "@tests/utils"; @@ -16,16 +22,11 @@ import { } from "./task-run-concurrency-limits"; describe("task run concurrency limits hooks", () => { - const seedData = () => [ - { - id: "0", - created: "2021-01-01T00:00:00Z", - updated: "2021-01-01T00:00:00Z", - tag: "my tag 0", - concurrency_limit: 1, - active_slots: ["task_0"], - }, - ]; + const MOCK_TASK_RUN_CONCURRENCY_LIMIT = createFakeTaskRunConcurrencyLimit({ + id: "0", + tag: "my tag 0", + }); + const seedData = () => [MOCK_TASK_RUN_CONCURRENCY_LIMIT]; const mockFetchDetailsAPI = (data: TaskRunConcurrencyLimit) => { server.use( @@ -145,11 +146,9 @@ describe("task run concurrency limits hooks", () => { it("useCreateTaskRunConcurrencyLimit() invalidates cache and fetches updated value", async () => { const queryClient = new QueryClient(); const MOCK_NEW_DATA_ID = "1"; - const MOCK_NEW_DATA = { - tag: "my tag 1", - concurrency_limit: 2, - active_slots: [], - }; + const MOCK_NEW_DATA = createFakeTaskRunConcurrencyLimit({ + id: MOCK_NEW_DATA_ID, + }); // ------------ Mock API requests after queries are invalidated const NEW_LIMIT_DATA = { @@ -250,159 +249,20 @@ describe("task run concurrency limits hooks", () => { }); describe("buildConcurrenyLimitDetailsActiveRunsQuery()", () => { - const seedData = () => ({ + const MOCK_DATA = createFakeTaskRunConcurrencyLimit({ id: "0", - created: "2021-01-01T00:00:00Z", - updated: "2021-01-01T00:00:00Z", tag: "my tag 0", concurrency_limit: 1, active_slots: ["task_0"], }); - - const MOCK_TASK_RUNS: Array = [ - { - id: "task_0", - created: "2024-12-18T19:07:44.837299Z", - updated: "2024-12-18T19:07:45.019000Z", - name: "hello-task-a0c", - flow_run_id: "3f1093f1-c349-47f1-becf-111999ac9351", - task_key: "say_hello-6b199e75", - dynamic_key: "a0c05e3b-4129-4e6d-bcf9-8b6d289aa4c0", - cache_key: null, - cache_expiration: null, - task_version: null, - empirical_policy: { - max_retries: 0, - retry_delay_seconds: 0, - retries: 0, - retry_delay: 0, - retry_jitter_factor: null, - }, - tags: ["tag1", "test1", "onboarding", "test", "test2"], - labels: {}, - state_id: "050b3aa3-c085-44da-bada-a6a239ca617b", - task_inputs: { - name: [], - }, - state_type: "RUNNING", - state_name: "Running", - run_count: 1, - flow_run_run_count: 1, - expected_start_time: "2024-12-18T19:07:44.786401Z", - next_scheduled_start_time: null, - start_time: "2024-12-18T19:07:44.791572Z", - end_time: null, - total_run_time: 0, - estimated_run_time: 0.901001, - estimated_start_time_delta: 0.005171, - state: { - id: "050b3aa3-c085-44da-bada-a6a239ca617b", - type: "RUNNING", - name: "Running", - timestamp: "2024-12-18T19:07:44.791572Z", - message: "", - data: null, - state_details: { - flow_run_id: "3f1093f1-c349-47f1-becf-111999ac9351", - task_run_id: "652d0799-8e73-4b2d-8428-e60b070d0a97", - child_flow_run_id: null, - scheduled_time: null, - cache_key: null, - cache_expiration: null, - deferred: false, - untrackable_result: false, - pause_timeout: null, - pause_reschedule: false, - pause_key: null, - run_input_keyset: null, - refresh_cache: null, - retriable: null, - transition_id: null, - task_parameters_id: null, - }, - }, - }, + const seedData = () => MOCK_DATA; + const MOCK_TASK_RUNS = [ + createFakeTaskRun({ id: "task_0", flow_run_id: "flow_run_0" }), ]; - - const MOCK_FLOW_RUNS: Array = [ - { - id: "3f1093f1-c349-47f1-becf-111999ac9351", - created: "2024-12-18T19:07:44.726912Z", - updated: "2024-12-18T19:07:49.473000Z", - name: "authentic-cockatoo", - flow_id: "5d8df4c9-d846-45b6-a5bc-55f0cb264bd2", - state_id: "2298e945-6e3f-4def-ba97-1276937d3ef3", - deployment_id: null, - deployment_version: null, - work_queue_id: null, - work_queue_name: null, - flow_version: "e22328439175aef5dfcba6aa44a4c392", - parameters: {}, - idempotency_key: null, - context: {}, - empirical_policy: { - max_retries: 0, - retry_delay_seconds: 0.0, - retries: 0, - retry_delay: 0, - pause_keys: [], - resuming: false, - retry_type: null, - }, - tags: [], - labels: { "prefect.flow.id": "5d8df4c9-d846-45b6-a5bc-55f0cb264bd2" }, - parent_task_run_id: null, - state_type: "COMPLETED", - state_name: "Completed", - run_count: 1, - expected_start_time: "2024-12-18T19:07:44.726851Z", - next_scheduled_start_time: null, - start_time: "2024-12-18T19:07:44.750254Z", - end_time: "2024-12-18T19:07:49.458237Z", - total_run_time: 4.707983, - estimated_run_time: 4.707983, - estimated_start_time_delta: 0.023403, - auto_scheduled: false, - infrastructure_document_id: null, - infrastructure_pid: null, - created_by: null, - state: { - id: "2298e945-6e3f-4def-ba97-1276937d3ef3", - type: "COMPLETED", - name: "Completed", - timestamp: "2024-12-18T19:07:49.458237Z", - message: null, - data: null, - state_details: { - flow_run_id: "3f1093f1-c349-47f1-becf-111999ac9351", - task_run_id: null, - child_flow_run_id: null, - scheduled_time: null, - cache_key: null, - cache_expiration: null, - deferred: null, - untrackable_result: true, - pause_timeout: null, - pause_reschedule: false, - pause_key: null, - run_input_keyset: null, - refresh_cache: null, - retriable: null, - transition_id: "c0ae12f9-d2a0-459a-8a2d-947fe7cebf46", - task_parameters_id: null, - }, - }, - job_variables: {}, - }, + const MOCK_FLOW_RUNS = [ + createFakeFlowRun({ id: "flow_run_0", flow_id: "flow_0" }), ]; - const MOCK_FLOW: components["schemas"]["Flow"] = { - id: "5d8df4c9-d846-45b6-a5bc-55f0cb264bd2", - created: "2024-12-10T21:50:18.315610Z", - updated: "2024-12-10T21:50:18.315612Z", - name: "hello-universe", - tags: [], - labels: {}, - }; + const MOCK_FLOW = createFakeFlow({ id: "flow_0" }); const mockFetchDetailsAPI = (data: TaskRunConcurrencyLimit) => { server.use( diff --git a/ui-v2/src/storybook/utils/mocks/create-fake-flow-run.ts b/ui-v2/src/mocks/create-fake-flow-run.ts similarity index 100% rename from ui-v2/src/storybook/utils/mocks/create-fake-flow-run.ts rename to ui-v2/src/mocks/create-fake-flow-run.ts diff --git a/ui-v2/src/storybook/utils/mocks/create-fake-flow.ts b/ui-v2/src/mocks/create-fake-flow.ts similarity index 100% rename from ui-v2/src/storybook/utils/mocks/create-fake-flow.ts rename to ui-v2/src/mocks/create-fake-flow.ts diff --git a/ui-v2/src/storybook/utils/mocks/create-fake-global-concurrency-limit.ts b/ui-v2/src/mocks/create-fake-global-concurrency-limit.ts similarity index 100% rename from ui-v2/src/storybook/utils/mocks/create-fake-global-concurrency-limit.ts rename to ui-v2/src/mocks/create-fake-global-concurrency-limit.ts diff --git a/ui-v2/src/storybook/utils/mocks/create-fake-state.ts b/ui-v2/src/mocks/create-fake-state.ts similarity index 100% rename from ui-v2/src/storybook/utils/mocks/create-fake-state.ts rename to ui-v2/src/mocks/create-fake-state.ts diff --git a/ui-v2/src/storybook/utils/mocks/create-fake-take-run-concurrency-limit.ts b/ui-v2/src/mocks/create-fake-take-run-concurrency-limit.ts similarity index 100% rename from ui-v2/src/storybook/utils/mocks/create-fake-take-run-concurrency-limit.ts rename to ui-v2/src/mocks/create-fake-take-run-concurrency-limit.ts diff --git a/ui-v2/src/storybook/utils/mocks/create-fake-task-run.ts b/ui-v2/src/mocks/create-fake-task-run.ts similarity index 100% rename from ui-v2/src/storybook/utils/mocks/create-fake-task-run.ts rename to ui-v2/src/mocks/create-fake-task-run.ts diff --git a/ui-v2/src/mocks/index.ts b/ui-v2/src/mocks/index.ts new file mode 100644 index 000000000000..c6d943a7e4d1 --- /dev/null +++ b/ui-v2/src/mocks/index.ts @@ -0,0 +1,6 @@ +export { createFakeFlow } from "./create-fake-flow"; +export { createFakeFlowRun } from "./create-fake-flow-run"; +export { createFakeTaskRun } from "./create-fake-task-run"; +export { createFakeState } from "./create-fake-state"; +export { createFakeTaskRunConcurrencyLimit } from "./create-fake-take-run-concurrency-limit"; +export { createFakeGlobalConcurrencyLimit } from "./create-fake-global-concurrency-limit"; diff --git a/ui-v2/src/storybook/utils/index.ts b/ui-v2/src/storybook/utils/index.ts index 89700e00880d..47e59e86809f 100644 --- a/ui-v2/src/storybook/utils/index.ts +++ b/ui-v2/src/storybook/utils/index.ts @@ -1,10 +1,3 @@ export { routerDecorator } from "./router-decorator"; export { reactQueryDecorator } from "./react-query-decorator"; export { toastDecorator } from "./toast-decorator"; - -export { createFakeFlow } from "./mocks/create-fake-flow"; -export { createFakeFlowRun } from "./mocks/create-fake-flow-run"; -export { createFakeTaskRun } from "./mocks/create-fake-task-run"; -export { createFakeState } from "./mocks/create-fake-state"; -export { createFakeTaskRunConcurrencyLimit } from "./mocks/create-fake-take-run-concurrency-limit"; -export { createFakeGlobalConcurrencyLimit } from "./mocks/create-fake-global-concurrency-limit";