|
| 1 | +import type { Meta, StoryObj } from "@storybook/react"; |
| 2 | +import { HttpResponse, http } from "msw"; |
| 3 | +import { createFakeWorkPool } from "@/mocks/create-fake-work-pool"; |
| 4 | +import { |
| 5 | + reactQueryDecorator, |
| 6 | + routerDecorator, |
| 7 | + toastDecorator, |
| 8 | +} from "@/storybook/utils"; |
| 9 | +import { WorkPoolEditForm } from "./work-pool-edit-form"; |
| 10 | + |
| 11 | +const meta: Meta<typeof WorkPoolEditForm> = { |
| 12 | + title: "Components/WorkPools/WorkPoolEditForm", |
| 13 | + component: WorkPoolEditForm, |
| 14 | + decorators: [reactQueryDecorator, routerDecorator, toastDecorator], |
| 15 | + parameters: { |
| 16 | + layout: "padded", |
| 17 | + }, |
| 18 | +}; |
| 19 | + |
| 20 | +export default meta; |
| 21 | +type Story = StoryObj<typeof WorkPoolEditForm>; |
| 22 | + |
| 23 | +export const Default: Story = { |
| 24 | + args: { |
| 25 | + workPool: createFakeWorkPool({ |
| 26 | + name: "my-work-pool", |
| 27 | + description: "A work pool for running flow runs", |
| 28 | + concurrency_limit: 10, |
| 29 | + type: "process", |
| 30 | + }), |
| 31 | + }, |
| 32 | + parameters: { |
| 33 | + msw: { |
| 34 | + handlers: [ |
| 35 | + http.patch("http://localhost:4200/api/work_pools/:name", () => { |
| 36 | + return new HttpResponse(null, { status: 204 }); |
| 37 | + }), |
| 38 | + ], |
| 39 | + }, |
| 40 | + }, |
| 41 | +}; |
| 42 | + |
| 43 | +export const WithNullDescription: Story = { |
| 44 | + args: { |
| 45 | + workPool: createFakeWorkPool({ |
| 46 | + name: "no-description-pool", |
| 47 | + description: null, |
| 48 | + concurrency_limit: 5, |
| 49 | + type: "docker", |
| 50 | + }), |
| 51 | + }, |
| 52 | + parameters: { |
| 53 | + msw: { |
| 54 | + handlers: [ |
| 55 | + http.patch("http://localhost:4200/api/work_pools/:name", () => { |
| 56 | + return new HttpResponse(null, { status: 204 }); |
| 57 | + }), |
| 58 | + ], |
| 59 | + }, |
| 60 | + }, |
| 61 | +}; |
| 62 | + |
| 63 | +export const WithNullConcurrencyLimit: Story = { |
| 64 | + args: { |
| 65 | + workPool: createFakeWorkPool({ |
| 66 | + name: "unlimited-pool", |
| 67 | + description: "A pool with unlimited concurrency", |
| 68 | + concurrency_limit: null, |
| 69 | + type: "kubernetes", |
| 70 | + }), |
| 71 | + }, |
| 72 | + parameters: { |
| 73 | + msw: { |
| 74 | + handlers: [ |
| 75 | + http.patch("http://localhost:4200/api/work_pools/:name", () => { |
| 76 | + return new HttpResponse(null, { status: 204 }); |
| 77 | + }), |
| 78 | + ], |
| 79 | + }, |
| 80 | + }, |
| 81 | +}; |
| 82 | + |
| 83 | +export const WithLongDescription: Story = { |
| 84 | + args: { |
| 85 | + workPool: createFakeWorkPool({ |
| 86 | + name: "detailed-pool", |
| 87 | + description: |
| 88 | + "This is a very detailed description of the work pool that explains its purpose, configuration, and usage guidelines. It spans multiple lines to demonstrate how the textarea handles longer content. The pool is configured for high-throughput batch processing workloads.", |
| 89 | + concurrency_limit: 100, |
| 90 | + type: "process", |
| 91 | + }), |
| 92 | + }, |
| 93 | + parameters: { |
| 94 | + msw: { |
| 95 | + handlers: [ |
| 96 | + http.patch("http://localhost:4200/api/work_pools/:name", () => { |
| 97 | + return new HttpResponse(null, { status: 204 }); |
| 98 | + }), |
| 99 | + ], |
| 100 | + }, |
| 101 | + }, |
| 102 | +}; |
| 103 | + |
| 104 | +export const SuccessResponse: Story = { |
| 105 | + args: { |
| 106 | + workPool: createFakeWorkPool({ |
| 107 | + name: "success-pool", |
| 108 | + description: "Test successful update", |
| 109 | + concurrency_limit: 10, |
| 110 | + type: "process", |
| 111 | + }), |
| 112 | + }, |
| 113 | + parameters: { |
| 114 | + msw: { |
| 115 | + handlers: [ |
| 116 | + http.patch("http://localhost:4200/api/work_pools/:name", () => { |
| 117 | + return new HttpResponse(null, { status: 204 }); |
| 118 | + }), |
| 119 | + ], |
| 120 | + }, |
| 121 | + }, |
| 122 | +}; |
| 123 | + |
| 124 | +export const ErrorResponse: Story = { |
| 125 | + args: { |
| 126 | + workPool: createFakeWorkPool({ |
| 127 | + name: "error-pool", |
| 128 | + description: "Test error handling", |
| 129 | + concurrency_limit: 10, |
| 130 | + type: "process", |
| 131 | + }), |
| 132 | + }, |
| 133 | + parameters: { |
| 134 | + msw: { |
| 135 | + handlers: [ |
| 136 | + http.patch("http://localhost:4200/api/work_pools/:name", () => { |
| 137 | + return HttpResponse.json( |
| 138 | + { detail: "Work pool not found" }, |
| 139 | + { status: 404 }, |
| 140 | + ); |
| 141 | + }), |
| 142 | + ], |
| 143 | + }, |
| 144 | + }, |
| 145 | +}; |
| 146 | + |
| 147 | +export const KubernetesWorkPool: Story = { |
| 148 | + args: { |
| 149 | + workPool: createFakeWorkPool({ |
| 150 | + name: "production-k8s-pool", |
| 151 | + description: "Kubernetes work pool for production deployments", |
| 152 | + concurrency_limit: 50, |
| 153 | + type: "kubernetes", |
| 154 | + }), |
| 155 | + }, |
| 156 | + parameters: { |
| 157 | + msw: { |
| 158 | + handlers: [ |
| 159 | + http.patch("http://localhost:4200/api/work_pools/:name", () => { |
| 160 | + return new HttpResponse(null, { status: 204 }); |
| 161 | + }), |
| 162 | + ], |
| 163 | + }, |
| 164 | + }, |
| 165 | +}; |
| 166 | + |
| 167 | +export const DockerWorkPool: Story = { |
| 168 | + args: { |
| 169 | + workPool: createFakeWorkPool({ |
| 170 | + name: "docker-dev-pool", |
| 171 | + description: "Docker work pool for development", |
| 172 | + concurrency_limit: 20, |
| 173 | + type: "docker", |
| 174 | + }), |
| 175 | + }, |
| 176 | + parameters: { |
| 177 | + msw: { |
| 178 | + handlers: [ |
| 179 | + http.patch("http://localhost:4200/api/work_pools/:name", () => { |
| 180 | + return new HttpResponse(null, { status: 204 }); |
| 181 | + }), |
| 182 | + ], |
| 183 | + }, |
| 184 | + }, |
| 185 | +}; |
0 commit comments