2021-05-11 10:25:22 -04:00
|
|
|
import useFetchMock from './hooks/use-fetch-mock'
|
2021-09-14 04:54:21 -04:00
|
|
|
import { withContextRoot } from './utils/with-context-root'
|
|
|
|
import CloneProjectModal from '../js/features/clone-project-modal/components/clone-project-modal'
|
2021-01-06 05:30:08 -05:00
|
|
|
|
2021-09-14 04:54:21 -04:00
|
|
|
const project = { _id: 'original-project', name: 'Project Title' }
|
|
|
|
|
|
|
|
export const Success = args => {
|
2021-05-11 10:25:22 -04:00
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
fetchMock.post(
|
|
|
|
'express:/project/:projectId/clone',
|
2021-09-14 04:54:21 -04:00
|
|
|
{ status: 200 },
|
|
|
|
{ delay: 250 }
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
return withContextRoot(<CloneProjectModal {...args} />, { project })
|
|
|
|
}
|
2021-01-06 05:30:08 -05:00
|
|
|
|
2021-09-14 04:54:21 -04:00
|
|
|
export const GenericErrorResponse = args => {
|
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
fetchMock.post(
|
|
|
|
'express:/project/:projectId/clone',
|
|
|
|
{ status: 500 },
|
|
|
|
{ delay: 250 }
|
2021-05-11 10:25:22 -04:00
|
|
|
)
|
|
|
|
})
|
2021-01-06 05:30:08 -05:00
|
|
|
|
2021-09-14 04:54:21 -04:00
|
|
|
return withContextRoot(<CloneProjectModal {...args} />, { project })
|
2021-01-06 05:30:08 -05:00
|
|
|
}
|
2021-09-14 04:54:21 -04:00
|
|
|
|
|
|
|
export const SpecificErrorResponse = args => {
|
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
fetchMock.post(
|
|
|
|
'express:/project/:projectId/clone',
|
|
|
|
{ status: 400, body: 'The project name is not valid' },
|
|
|
|
{ delay: 250 }
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
return withContextRoot(<CloneProjectModal {...args} />, { project })
|
2021-01-06 05:30:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
2021-03-25 06:11:45 -04:00
|
|
|
title: 'Modals / Clone Project',
|
2021-03-05 08:00:13 -05:00
|
|
|
component: CloneProjectModal,
|
2021-01-06 05:30:08 -05:00
|
|
|
args: {
|
2021-04-27 03:52:58 -04:00
|
|
|
show: true,
|
2021-01-06 05:30:08 -05:00
|
|
|
},
|
|
|
|
argTypes: {
|
2021-03-05 08:00:13 -05:00
|
|
|
handleHide: { action: 'close modal' },
|
|
|
|
openProject: { action: 'open project' },
|
2021-04-27 03:52:58 -04:00
|
|
|
},
|
2021-01-06 05:30:08 -05:00
|
|
|
}
|