mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Streamline the project references context provider (#19387)
GitOrigin-RevId: 9af00459ec121a605b84809b349a0bc258896048
This commit is contained in:
@@ -30,7 +30,6 @@ describe('<FileTreeRoot/>', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub()}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
@@ -73,7 +72,6 @@ describe('<FileTreeRoot/>', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub()}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
@@ -117,7 +115,6 @@ describe('<FileTreeRoot/>', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub()}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
@@ -154,7 +151,6 @@ describe('<FileTreeRoot/>', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub()}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub().as('onSelect')}
|
||||
@@ -202,7 +198,6 @@ describe('<FileTreeRoot/>', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub()}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
@@ -247,7 +242,6 @@ describe('<FileTreeRoot/>', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub()}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
@@ -318,7 +312,6 @@ describe('<FileTreeRoot/>', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub()}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
|
||||
@@ -27,7 +27,6 @@ describe('FileTree Context Menu Flow', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub()}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
@@ -64,7 +63,6 @@ describe('FileTree Context Menu Flow', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub()}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
@@ -101,7 +99,6 @@ describe('FileTree Context Menu Flow', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub()}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
|
||||
@@ -30,7 +30,6 @@ describe('FileTree Create Folder Flow', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub()}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
@@ -100,7 +99,6 @@ describe('FileTree Create Folder Flow', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub()}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
@@ -177,7 +175,6 @@ describe('FileTree Create Folder Flow', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub()}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
@@ -244,7 +241,6 @@ describe('FileTree Create Folder Flow', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub()}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
|
||||
@@ -35,7 +35,6 @@ describe('FileTree Delete Entity Flow', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub().as('reindexReferences')}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
@@ -84,7 +83,6 @@ describe('FileTree Delete Entity Flow', function () {
|
||||
).should('not.exist')
|
||||
|
||||
cy.get('@deleteDoc.all').should('have.length', 1)
|
||||
cy.get('@reindexReferences').should('not.have.been.called')
|
||||
})
|
||||
|
||||
it('continues delete on 404s', function () {
|
||||
@@ -162,7 +160,6 @@ describe('FileTree Delete Entity Flow', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub().as('reindexReferences')}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
@@ -226,7 +223,6 @@ describe('FileTree Delete Entity Flow', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub().as('reindexReferences')}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub()}
|
||||
@@ -282,7 +278,6 @@ describe('FileTree Delete Entity Flow', function () {
|
||||
|
||||
cy.get('@deleteDoc.all').should('have.length', 1)
|
||||
cy.get('@deleteFile.all').should('have.length', 1)
|
||||
cy.get('@reindexReferences').should('have.been.calledOnce')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -42,7 +42,6 @@ describe('FileTree Rename Entity Flow', function () {
|
||||
>
|
||||
<FileTreeRoot
|
||||
refProviders={{}}
|
||||
reindexReferences={cy.stub()}
|
||||
setRefProviderEnabled={cy.stub()}
|
||||
setStartedFreeTrial={cy.stub()}
|
||||
onSelect={cy.stub().as('onSelect')}
|
||||
|
||||
@@ -12,7 +12,6 @@ export const FileTreeProvider: FC<{
|
||||
|
||||
if (propsRef.current === undefined) {
|
||||
propsRef.current = {
|
||||
reindexReferences: cy.stub().as('reindexReferences'),
|
||||
setRefProviderEnabled: cy.stub().as('setRefProviderEnabled'),
|
||||
setStartedFreeTrial: cy.stub().as('setStartedFreeTrial'),
|
||||
onSelect: cy.stub(),
|
||||
|
||||
+19
-6
@@ -8,6 +8,7 @@ import { User, UserId } from '../../../../../types/user'
|
||||
import { TestContainer } from '../helpers/test-container'
|
||||
import { FC } from 'react'
|
||||
import { MetadataContext } from '@/features/ide-react/context/metadata-context'
|
||||
import { ReferencesContext } from '@/features/ide-react/context/references-context'
|
||||
|
||||
describe('autocomplete', { scrollBehavior: false }, function () {
|
||||
beforeEach(function () {
|
||||
@@ -62,7 +63,6 @@ describe('autocomplete', { scrollBehavior: false }, function () {
|
||||
]
|
||||
|
||||
const scope = mockScope()
|
||||
scope.$root._references.keys = ['foo']
|
||||
scope.project.rootFolder = rootFolder
|
||||
|
||||
cy.mount(
|
||||
@@ -209,7 +209,6 @@ describe('autocomplete', { scrollBehavior: false }, function () {
|
||||
]
|
||||
|
||||
const scope = mockScope()
|
||||
scope.$root._references.keys = ['foo']
|
||||
|
||||
cy.mount(
|
||||
<TestContainer>
|
||||
@@ -373,11 +372,27 @@ describe('autocomplete', { scrollBehavior: false }, function () {
|
||||
]
|
||||
|
||||
const scope = mockScope()
|
||||
scope.$root._references.keys = ['ref-1', 'ref-2', 'ref-3']
|
||||
|
||||
const ReferencesProvider: FC = ({ children }) => {
|
||||
return (
|
||||
<ReferencesContext.Provider
|
||||
value={{
|
||||
referenceKeys: new Set(['ref-1', 'ref-2', 'ref-3']),
|
||||
indexAllReferences: cy.stub(),
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</ReferencesContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
cy.mount(
|
||||
<TestContainer>
|
||||
<EditorProviders scope={scope} rootFolder={rootFolder as any}>
|
||||
<EditorProviders
|
||||
scope={scope}
|
||||
providers={{ ReferencesProvider }}
|
||||
rootFolder={rootFolder as any}
|
||||
>
|
||||
<CodeMirrorEditor />
|
||||
</EditorProviders>
|
||||
</TestContainer>
|
||||
@@ -428,7 +443,6 @@ describe('autocomplete', { scrollBehavior: false }, function () {
|
||||
]
|
||||
|
||||
const scope = mockScope()
|
||||
scope.$root._references.keys = ['foo']
|
||||
scope.project.rootFolder = rootFolder
|
||||
|
||||
cy.mount(
|
||||
@@ -893,7 +907,6 @@ describe('autocomplete', { scrollBehavior: false }, function () {
|
||||
]
|
||||
|
||||
const scope = mockScope()
|
||||
scope.$root._references.keys = ['foo']
|
||||
scope.project.rootFolder = rootFolder
|
||||
|
||||
cy.mount(
|
||||
|
||||
@@ -80,10 +80,5 @@ export const mockScope = (content?: string) => {
|
||||
$on: cy.stub().log(false),
|
||||
$broadcast: cy.stub().log(false),
|
||||
$emit: cy.stub().log(false),
|
||||
$root: {
|
||||
_references: {
|
||||
keys: ['foo'],
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user