Skip to content

Commit d67bea7

Browse files
authored
fix(storybook): Add story with OpenApiAdmin (#614)
1 parent 46f97bd commit d67bea7

File tree

4 files changed

+45
-29
lines changed

4 files changed

+45
-29
lines changed

api/config/packages/api_platform.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ api_platform:
66
include_type: true
77
formats:
88
jsonld: ['application/ld+json']
9+
json: ["application/json"]
910
docs_formats:
1011
jsonld: ['application/ld+json']
1112
jsonopenapi: ['application/vnd.openapi+json']

src/stories/Basic.stories.ts

-26
This file was deleted.

src/stories/Basic.stories.tsx

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React from 'react';
2+
import type { Meta, StoryObj } from '@storybook/react';
3+
import { within } from '@storybook/test';
4+
import { HydraAdmin, type HydraAdminProps } from '../hydra';
5+
import { OpenApiAdmin } from '../openapi';
6+
7+
/**
8+
* # Basic `<HydraAdmin>` component
9+
* The `<HydraAdmin>` component without any parameter.
10+
*/
11+
const Basic = ({ entrypoint }: BasicProps) => (
12+
<HydraAdmin entrypoint={entrypoint} />
13+
);
14+
15+
interface BasicProps extends Pick<HydraAdminProps, 'entrypoint'> {}
16+
17+
const meta = {
18+
title: 'Admin/Basic',
19+
component: Basic,
20+
parameters: {
21+
layout: 'fullscreen',
22+
},
23+
} satisfies Meta<typeof Basic>;
24+
25+
export default meta;
26+
27+
type Story = StoryObj<typeof meta>;
28+
29+
export const Hydra: Story = {
30+
play: async ({ canvasElement }) => {
31+
const canvas = within(canvasElement);
32+
await canvas.findByText('Greetings');
33+
},
34+
args: {
35+
entrypoint: process.env.ENTRYPOINT,
36+
},
37+
};
38+
39+
export const OpenApi = () => (
40+
<OpenApiAdmin
41+
entrypoint={process.env.ENTRYPOINT}
42+
docEntrypoint={`${process.env.ENTRYPOINT}/docs.jsonopenapi`}
43+
/>
44+
);

src/stories/Configure.mdx

-3
This file was deleted.

0 commit comments

Comments
 (0)