-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: SB-640, SB-661 Fix and refactor storybooks
Approved-by: Patryk Ziemkowski
- Loading branch information
Showing
80 changed files
with
903 additions
and
1,014 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { MockPayloadGenerator, RelayMockEnvironment } from 'relay-test-utils'; | ||
import { OperationDescriptor } from 'react-relay/hooks'; | ||
|
||
import crudDemoItemDetailsQueryGraphql from '../../routes/crudDemoItem/crudDemoItemDetails/__generated__/crudDemoItemDetailsQuery.graphql'; | ||
import EditCrudDemoItemQuery from '../../routes/crudDemoItem/editCrudDemoItem/__generated__/editCrudDemoItemQuery.graphql'; | ||
import { connectionFromArray } from '../../tests/utils/fixtures'; | ||
import CrudDemoItemListQuery from '../../routes/crudDemoItem/crudDemoItemList/__generated__/crudDemoItemListQuery.graphql'; | ||
|
||
export const fillCrudDemoItemDetailsQuery = ( | ||
env: RelayMockEnvironment, | ||
data = { | ||
name: 'Demo item name', | ||
}, | ||
variables = {} | ||
) => { | ||
env.mock.queueOperationResolver((operation: OperationDescriptor) => | ||
MockPayloadGenerator.generate(operation, { | ||
CrudDemoItemType() { | ||
return data; | ||
}, | ||
}) | ||
); | ||
env.mock.queuePendingOperation(crudDemoItemDetailsQueryGraphql, variables); | ||
}; | ||
|
||
export const fillEditCrudDemoItemQuery = ( | ||
env: RelayMockEnvironment, | ||
data: object = { | ||
name: 'Default name', | ||
}, | ||
variables = {} | ||
) => { | ||
env.mock.queueOperationResolver((operation: OperationDescriptor) => | ||
MockPayloadGenerator.generate(operation, { | ||
CrudDemoItemType() { | ||
return data; | ||
}, | ||
}) | ||
); | ||
env.mock.queuePendingOperation(EditCrudDemoItemQuery, variables); | ||
}; | ||
|
||
export const fillCrudDemoItemListQuery = ( | ||
env: RelayMockEnvironment, | ||
data = [{ name: 'First item' }, { name: 'Second item' }] | ||
) => { | ||
env.mock.queueOperationResolver((operation: OperationDescriptor) => | ||
MockPayloadGenerator.generate(operation, { | ||
CrudDemoItemConnection: (...args) => connectionFromArray(data), | ||
}) | ||
); | ||
env.mock.queuePendingOperation(CrudDemoItemListQuery, {}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
import { Story } from '@storybook/react'; | ||
import { ProvidersWrapper } from '../../../shared/utils/testUtils'; | ||
import { withProviders } from '../../../shared/utils/storybook'; | ||
import { Login } from './login.component'; | ||
|
||
const Template: Story = () => { | ||
return ( | ||
<ProvidersWrapper> | ||
<Login /> | ||
</ProvidersWrapper> | ||
); | ||
return <Login />; | ||
}; | ||
|
||
export default { | ||
title: 'Routes/Login', | ||
title: 'Routes/Auth/Login', | ||
component: Login, | ||
}; | ||
|
||
export const Default = Template.bind({}); | ||
Default.decorators = [withProviders({})]; |
22 changes: 17 additions & 5 deletions
22
...ebapp/src/routes/auth/passwordReset/passwordResetConfirm/passwordResetConfirm.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,30 @@ | ||
import { Story } from '@storybook/react'; | ||
import { ProvidersWrapper } from '../../../../shared/utils/testUtils'; | ||
import { Route, Routes } from 'react-router'; | ||
import { withProviders } from '../../../../shared/utils/storybook'; | ||
import { RoutesConfig } from '../../../../app/config/routes'; | ||
import { createMockRouterProps } from '../../../../tests/utils/rendering'; | ||
import { PasswordResetConfirm } from './passwordResetConfirm.component'; | ||
|
||
const routePath = ['passwordReset', 'confirm']; | ||
const userParam = 'user'; | ||
const tokenParam = 'token'; | ||
|
||
const Template: Story = () => { | ||
return ( | ||
<ProvidersWrapper> | ||
<PasswordResetConfirm /> | ||
</ProvidersWrapper> | ||
<Routes> | ||
<Route path={RoutesConfig.getLocalePath(routePath)} element={<PasswordResetConfirm />} /> | ||
</Routes> | ||
); | ||
}; | ||
|
||
export default { | ||
title: 'Shared/Auth/PasswordResetConfirm', | ||
title: 'Routes/Auth/PasswordResetConfirm', | ||
component: PasswordResetConfirm, | ||
}; | ||
|
||
export const Default = Template.bind({}); | ||
Default.decorators = [ | ||
withProviders({ | ||
routerProps: createMockRouterProps(routePath, { user: userParam, token: tokenParam }), | ||
}), | ||
]; |
Oops, something went wrong.