chore: catch up Storybook preview, coverage, and story hygiene
Stories were throwing without AuthModal/CreateFlow providers, autodocs was a no-op, and several DS/create-flow screens had no stories.
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { PublishedStakeholdersManagePanel } from "../../app/(app)/create/screens/select/PublishedStakeholdersManagePanel";
|
||||
|
||||
function StakeholdersFetchMock({ children }) {
|
||||
const origRef = useRef(undefined);
|
||||
if (origRef.current === undefined) {
|
||||
origRef.current = globalThis.fetch;
|
||||
globalThis.fetch = async (input, init) => {
|
||||
const url =
|
||||
typeof input === "string"
|
||||
? input
|
||||
: input instanceof URL
|
||||
? input.href
|
||||
: input.url;
|
||||
if (url.includes("/stakeholders")) {
|
||||
if (init?.method && init.method !== "GET") {
|
||||
return new Response(JSON.stringify({ ok: true }), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
}
|
||||
return new Response(JSON.stringify({ stakeholders: [] }), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
}
|
||||
return origRef.current(input, init);
|
||||
};
|
||||
}
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (origRef.current) {
|
||||
globalThis.fetch = origRef.current;
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
return children;
|
||||
}
|
||||
|
||||
export default {
|
||||
title: "Pages/Create Flow/Published stakeholders",
|
||||
component: PublishedStakeholdersManagePanel,
|
||||
parameters: {
|
||||
layout: "fullscreen",
|
||||
docs: {
|
||||
description: {
|
||||
component:
|
||||
"Manage invites on a published rule. Fetch is stubbed empty in this story.",
|
||||
},
|
||||
},
|
||||
},
|
||||
decorators: [
|
||||
(Story) => (
|
||||
<StakeholdersFetchMock>
|
||||
<div className="min-h-screen bg-[var(--color-surface-default-primary)] p-8">
|
||||
<Story />
|
||||
</div>
|
||||
</StakeholdersFetchMock>
|
||||
),
|
||||
],
|
||||
};
|
||||
|
||||
export const Default = {
|
||||
args: {
|
||||
ruleId: "storybook-rule",
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user