mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2025-07-29 05:00:06 +02:00

* Update fetch-mock to version 12 * Replace `fetchMock.done` by `fetchMock.callHistory.done` * Replace `…Mock.called` by `…Mock.callHistory.called` * Replace `fetchMock.reset` by `fetchMock.hardReset` * Replace `fetchMock.restore` by `fetchMock.hardReset` * Replace `fetchMock.resetHistory` by `fetchMock.clearHistory` * Replace `fetchMock.calls` by `fetchMock.callHistory.calls` * Replace `fetchMock.flush` by `fetchMock.callHistory.flush` * Update tests for fetch-mock version 12 See https://www.wheresrhys.co.uk/fetch-mock/docs/Usage/upgrade-guide * Update stories for fetch-mock version 12 * Remove `overwriteRoutes` option * Add `fetchMock.spyGlobal()` to storybook * Remove deprecated `sendAsJson` param * Replace `fetchMock.hardReset()` by `fetchMock.removeRoutes().clearHistory()` * Fixup fetch-mock in storybook: Call `mockGlobal` inside the hook, call `removeRoutes` and `unmockGlobal` on cleanup Behaviour can be tested by navigating between https://storybook.dev-overleaf.com/main/?path=/story/editor-ai-error-assistant-compile-log-entries--first-log-entry https://storybook.dev-overleaf.com/main/?path=/story/editor-ai-error-assistant-compile-log-entries--rate-limited https://storybook.dev-overleaf.com/main/?path=/story/project-list-notifications--project-invite https://storybook.dev-overleaf.com/main/?path=/story/project-list-notifications--project-invite-network-error And clicking the buttons GitOrigin-RevId: 35611b4430259e4c21c3d819ad18b2e6dab66242
89 lines
2.4 KiB
JavaScript
89 lines
2.4 KiB
JavaScript
import {
|
|
createFileModalDecorator,
|
|
mockCreateFileModalFetch,
|
|
} from './create-file-modal-decorator'
|
|
import FileTreeModalCreateFile from '../../../js/features/file-tree/components/modals/file-tree-modal-create-file'
|
|
import useFetchMock from '../../hooks/use-fetch-mock'
|
|
import { ScopeDecorator } from '../../decorators/scope'
|
|
import { useScope } from '../../hooks/use-scope'
|
|
import getMeta from '@/utils/meta'
|
|
|
|
export const MinimalFeatures = args => {
|
|
useFetchMock(mockCreateFileModalFetch)
|
|
Object.assign(getMeta('ol-ExposedSettings'), {
|
|
hasLinkUrlFeature: false,
|
|
hasLinkedProjectFileFeature: false,
|
|
hasLinkedProjectOutputFileFeature: false,
|
|
})
|
|
|
|
return <FileTreeModalCreateFile {...args} />
|
|
}
|
|
MinimalFeatures.decorators = [createFileModalDecorator()]
|
|
|
|
export const WithExtraFeatures = args => {
|
|
useFetchMock(mockCreateFileModalFetch)
|
|
|
|
getMeta('ol-ExposedSettings').hasLinkUrlFeature = true
|
|
|
|
return <FileTreeModalCreateFile {...args} />
|
|
}
|
|
WithExtraFeatures.decorators = [
|
|
createFileModalDecorator({
|
|
refProviders: { mendeley: true, zotero: true },
|
|
}),
|
|
]
|
|
|
|
export const ErrorImportingFileFromExternalURL = args => {
|
|
useFetchMock(fetchMock => {
|
|
mockCreateFileModalFetch(fetchMock)
|
|
|
|
fetchMock.post('express:/project/:projectId/linked_file', 500)
|
|
})
|
|
|
|
getMeta('ol-ExposedSettings').hasLinkUrlFeature = true
|
|
|
|
return <FileTreeModalCreateFile {...args} />
|
|
}
|
|
ErrorImportingFileFromExternalURL.decorators = [createFileModalDecorator()]
|
|
|
|
export const ErrorImportingFileFromReferenceProvider = args => {
|
|
useFetchMock(fetchMock => {
|
|
mockCreateFileModalFetch(fetchMock)
|
|
|
|
fetchMock.post('express:/project/:projectId/linked_file', 500)
|
|
})
|
|
|
|
return <FileTreeModalCreateFile {...args} />
|
|
}
|
|
ErrorImportingFileFromReferenceProvider.decorators = [
|
|
createFileModalDecorator({
|
|
refProviders: { mendeley: true, zotero: true },
|
|
}),
|
|
]
|
|
|
|
export const FileLimitReached = args => {
|
|
useFetchMock(mockCreateFileModalFetch)
|
|
|
|
useScope({
|
|
project: {
|
|
rootFolder: {
|
|
_id: 'root-folder-id',
|
|
name: 'rootFolder',
|
|
docs: Array.from({ length: 10 }, (_, index) => ({
|
|
_id: `entity-${index}`,
|
|
})),
|
|
fileRefs: [],
|
|
folders: [],
|
|
},
|
|
},
|
|
})
|
|
|
|
return <FileTreeModalCreateFile {...args} />
|
|
}
|
|
FileLimitReached.decorators = [createFileModalDecorator()]
|
|
|
|
export default {
|
|
title: 'Editor / Modals / Create File',
|
|
component: FileTreeModalCreateFile,
|
|
decorators: [ScopeDecorator],
|
|
}
|