Skip to content

Commit b9af1bb

Browse files
committed
fix concurrency settings w/ a single paused producer
Also fix Queue stories that depend on feature flags.
1 parent 932065b commit b9af1bb

4 files changed

Lines changed: 130 additions & 24 deletions

File tree

.storybook/preview.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const withFeatures: Decorator = (StoryFn, context) => {
2626
// Default features with story-specific overrides
2727
const features = {
2828
hasProducerTable: true,
29+
producerQueries: true,
2930
...context.parameters?.features,
3031
};
3132

src/components/QueueDetail.stories.tsx

Lines changed: 122 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useFeatures } from "@contexts/Features.hook";
12
import { type Producer } from "@services/producers";
23
import { type ConcurrencyConfig } from "@services/queues";
34
import { Meta, StoryObj } from "@storybook/react-vite";
@@ -88,25 +89,25 @@ export const QueueNotFound: Story = {
8889
},
8990
};
9091

91-
// Active queue with no producers (features disabled)
92-
export const ActiveQueueWithoutPro: Story = {
93-
args: {
94-
producers: [],
95-
queue: queueFactory.active().build(),
96-
},
97-
parameters: {
98-
features: {
99-
hasProducerTable: false,
100-
},
101-
},
102-
};
103-
10492
// Active queue with no producers (features enabled)
10593
export const ActiveQueueNoProducers: Story = {
10694
args: {
10795
producers: [],
10896
queue: queueFactory.active().build(),
10997
},
98+
parameters: {
99+
mockData: [
100+
{
101+
hook: useFeatures,
102+
mockValue: {
103+
features: {
104+
hasProducerTable: true,
105+
producerQueries: true,
106+
},
107+
},
108+
},
109+
],
110+
},
110111
};
111112

112113
// Paused queue with no producers
@@ -115,6 +116,19 @@ export const PausedQueueNoProducers: Story = {
115116
producers: [],
116117
queue: queueFactory.paused().build(),
117118
},
119+
parameters: {
120+
mockData: [
121+
{
122+
hook: useFeatures,
123+
mockValue: {
124+
features: {
125+
hasProducerTable: true,
126+
producerQueries: true,
127+
},
128+
},
129+
},
130+
],
131+
},
118132
};
119133

120134
// Active queue with producers
@@ -123,6 +137,19 @@ export const ActiveQueueWithProducers: Story = {
123137
producers: createProducers(5, "test-queue"),
124138
queue: queueFactory.active().build(),
125139
},
140+
parameters: {
141+
mockData: [
142+
{
143+
hook: useFeatures,
144+
mockValue: {
145+
features: {
146+
hasProducerTable: true,
147+
producerQueries: true,
148+
},
149+
},
150+
},
151+
],
152+
},
126153
};
127154

128155
// Paused queue with some paused producers
@@ -131,31 +158,110 @@ export const PausedQueueWithMixedProducers: Story = {
131158
producers: createProducers(5, "test-queue", { paused: true }),
132159
queue: queueFactory.paused().build(),
133160
},
161+
parameters: {
162+
mockData: [
163+
{
164+
hook: useFeatures,
165+
mockValue: {
166+
features: {
167+
hasProducerTable: true,
168+
producerQueries: true,
169+
},
170+
},
171+
},
172+
],
173+
},
134174
};
135175

136176
// Queue with concurrency settings
137-
export const QueueWithConcurrencySettings: Story = {
177+
export const WithConcurrencySettings: Story = {
138178
args: {
139179
producers: createProducers(3, "test-queue", { withConcurrency: true }),
140180
queue: queueFactory.withConcurrency().build(),
141181
},
182+
parameters: {
183+
features: {
184+
hasProducerTable: true,
185+
producerQueries: true,
186+
},
187+
},
142188
};
143189

144190
// Queue with inconsistent producer concurrency settings
145-
export const QueueWithInconsistentConcurrency: Story = {
191+
export const InconsistentConcurrency: Story = {
146192
args: {
147193
producers: createProducers(3, "test-queue", {
148194
inconsistentConcurrency: true,
149195
withConcurrency: true,
150196
}),
151197
queue: queueFactory.withConcurrency().build(),
152198
},
199+
parameters: {
200+
mockData: [
201+
{
202+
hook: useFeatures,
203+
mockValue: {
204+
features: {
205+
hasProducerTable: true,
206+
producerQueries: true,
207+
},
208+
},
209+
},
210+
],
211+
},
153212
};
154213

155214
// Queue with many producers
156-
export const QueueWithManyProducers: Story = {
215+
export const ManyProducers: Story = {
157216
args: {
158217
producers: createProducers(20, "test-queue", { paused: true }),
159218
queue: queueFactory.active().build(),
160219
},
220+
parameters: {
221+
mockData: [
222+
{
223+
hook: useFeatures,
224+
mockValue: {
225+
features: {
226+
hasProducerTable: true,
227+
producerQueries: true,
228+
},
229+
},
230+
},
231+
],
232+
},
233+
};
234+
235+
// Queue with single paused producer (should not show concurrency warning)
236+
export const SinglePausedProducer: Story = {
237+
args: {
238+
producers: createProducers(1, "test-queue", { paused: true }),
239+
queue: queueFactory.active().build(),
240+
},
241+
parameters: {
242+
mockData: [
243+
{
244+
hook: useFeatures,
245+
mockValue: {
246+
features: {
247+
hasProducerTable: true,
248+
producerQueries: true,
249+
},
250+
},
251+
},
252+
],
253+
},
254+
};
255+
256+
// Pro features disabled
257+
export const WithoutPro: Story = {
258+
args: {
259+
producers: [],
260+
queue: queueFactory.active().build(),
261+
},
262+
parameters: {
263+
features: {
264+
hasProducerTable: false,
265+
},
266+
},
161267
};

src/components/QueueDetail.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,13 @@ const ConcurrencySettings = ({
251251

252252
const producerConcurrencyStatus = useMemo(() => {
253253
if (!producers || producers.length === 0)
254-
return { config: null, consistent: false };
254+
return { config: null, consistent: true };
255255

256256
// Filter out paused producers
257257
const activeProducers = producers.filter((p) => !p.pausedAt);
258258

259-
// If there are no active producers, return null config
260-
if (activeProducers.length === 0)
261-
return { config: null, consistent: false };
259+
// If there are no active producers, return null config but consider it consistent
260+
if (activeProducers.length === 0) return { config: null, consistent: true };
262261

263262
const firstProducer = activeProducers[0];
264263
const allSame = activeProducers.every((p) => {

src/services/features.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ describe("apiFeaturesToFeatures", () => {
77
const apiFeatures = {
88
extensions: {
99
durable_periodic_jobs: true,
10-
producer_queries: true,
11-
workflow_queries: true,
1210
has_client_table: true,
1311
has_producer_table: true,
1412
has_workflows: true,
13+
producer_queries: true,
14+
workflow_queries: true,
1515
},
1616
job_list_hide_args_by_default: true,
1717
} as const;
@@ -34,11 +34,11 @@ describe("apiFeaturesToFeatures", () => {
3434
const apiFeatures = {
3535
extensions: {
3636
durable_periodic_jobs: false,
37-
producer_queries: false,
38-
workflow_queries: false,
3937
has_client_table: false,
4038
has_producer_table: false,
4139
has_workflows: false,
40+
producer_queries: false,
41+
workflow_queries: false,
4242
},
4343
job_list_hide_args_by_default: false,
4444
} as const;

0 commit comments

Comments
 (0)