mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Ensure FileTreeProvider stubbed props don't change in Cypress tests (#16758)
GitOrigin-RevId: 01c7fefdef8b28af0b52007209785b478e5d8600
This commit is contained in:
parent
8136036c33
commit
7f9d105d8c
1 changed files with 14 additions and 8 deletions
|
@ -1,17 +1,23 @@
|
|||
import { FC } from 'react'
|
||||
import { ComponentProps, FC, useRef } from 'react'
|
||||
import FileTreeContext from '@/features/file-tree/components/file-tree-context'
|
||||
|
||||
export const FileTreeProvider: FC<{
|
||||
refProviders?: Record<string, boolean>
|
||||
}> = ({ children, refProviders = {} }) => {
|
||||
const propsRef =
|
||||
useRef<Omit<ComponentProps<typeof FileTreeContext>, 'refProviders'>>()
|
||||
|
||||
if (propsRef.current === undefined) {
|
||||
propsRef.current = {
|
||||
reindexReferences: cy.stub().as('reindexReferences'),
|
||||
setRefProviderEnabled: cy.stub().as('setRefProviderEnabled'),
|
||||
setStartedFreeTrial: cy.stub().as('setStartedFreeTrial'),
|
||||
onSelect: cy.stub(),
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<FileTreeContext
|
||||
refProviders={refProviders}
|
||||
reindexReferences={cy.stub().as('reindexReferences')}
|
||||
setRefProviderEnabled={cy.stub().as('setRefProviderEnabled')}
|
||||
setStartedFreeTrial={cy.stub().as('setStartedFreeTrial')}
|
||||
onSelect={() => {}}
|
||||
>
|
||||
<FileTreeContext refProviders={refProviders} {...propsRef.current}>
|
||||
<>{children}</>
|
||||
</FileTreeContext>
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue