Skip to content

Commit b0ba0b0

Browse files
committed
Add argtype to allow testing error case
1 parent 4398b7f commit b0ba0b0

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

packages/ra-core/src/controller/field/ReferenceManyFieldBase.stories.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,9 @@ const AuthorList = ({ source }) => {
416416
};
417417

418418
// test queryOptions type, it should support onSuccess and onError
419-
export const QueryOptions = () => (
419+
export const QueryOptions = ({ dataProvider }) => (
420420
<TestMemoryRouter initialEntries={['/authors/1/show']}>
421-
<CoreAdmin dataProvider={dataProviderWithAuthors}>
421+
<CoreAdmin dataProvider={dataProvider}>
422422
<Resource
423423
name="authors"
424424
show={
@@ -431,6 +431,7 @@ export const QueryOptions = () => (
431431
onSuccess: () =>
432432
console.log('Query successful'),
433433
onError: () => console.log('Query failed'),
434+
retry: false,
434435
}}
435436
>
436437
<AuthorList source="title" />
@@ -441,3 +442,18 @@ export const QueryOptions = () => (
441442
</CoreAdmin>
442443
</TestMemoryRouter>
443444
);
445+
446+
QueryOptions.args = {
447+
dataProvider: dataProviderWithAuthors,
448+
};
449+
450+
QueryOptions.argTypes = {
451+
dataProvider: {
452+
control: { type: 'radio' },
453+
options: ['No error', 'With Error'],
454+
mapping: {
455+
'No error': dataProviderWithAuthors,
456+
'With Error': dataProviderWithAuthorsError,
457+
},
458+
},
459+
};

0 commit comments

Comments
 (0)