overleaf-cep/services/web/test/frontend/features/file-tree/components/file-tree-toolbar.spec.tsx
Jakob Ackermann 39110d9da9 [clsi-cache] check compiler settings before using compile from cache (#24845)
* [web] provide an actual rootFolder from EditorProviders in tests

- Fixup SocketIOMock and ShareJS mocks to provide the complete interface
- Extend SocketIOMock interface to count event listeners
- Fixup test that did not expect to find a working rootDoc

* [web] expose imageName from ProjectContext

* [clsi-cache] check compiler settings before using compile from cache

* [web] avoid fetching initial compile from clsi-cache in PDF detach tab

GitOrigin-RevId: e3c754a7ceca55f03a317e1bc8ae45ed12cc2f02
2025-04-16 08:05:35 +00:00

59 lines
1.8 KiB
TypeScript

import FileTreeToolbar from '../../../../../frontend/js/features/file-tree/components/file-tree-toolbar'
import { EditorProviders } from '../../../helpers/editor-providers'
import { FileTreeProvider } from '../helpers/file-tree-provider'
describe('<FileTreeToolbar/>', function () {
it('without selected files', function () {
cy.mount(
<EditorProviders rootDocId="">
<FileTreeProvider>
<FileTreeToolbar />
</FileTreeProvider>
</EditorProviders>
)
cy.findAllByRole('button', { name: 'New file' })
cy.findAllByRole('button', { name: 'New folder' })
cy.findAllByRole('button', { name: 'Upload' })
cy.findAllByRole('button', { name: 'Rename' }).should('not.exist')
cy.findAllByRole('button', { name: 'Delete' }).should('not.exist')
})
it('read-only', function () {
cy.mount(
<EditorProviders permissionsLevel="readOnly">
<FileTreeProvider>
<FileTreeToolbar />
</FileTreeProvider>
</EditorProviders>
)
cy.findAllByRole('button').should('not.exist')
})
it('with one selected file', function () {
const rootFolder = [
{
_id: 'root-folder-id',
name: 'rootFolder',
docs: [{ _id: '456def', name: 'main.tex' }],
folders: [],
fileRefs: [],
},
]
cy.mount(
<EditorProviders rootDocId="456def" rootFolder={rootFolder as any}>
<FileTreeProvider>
<FileTreeToolbar />
</FileTreeProvider>
</EditorProviders>
)
cy.findAllByRole('button', { name: 'New file' })
cy.findAllByRole('button', { name: 'New folder' })
cy.findAllByRole('button', { name: 'Upload' })
cy.findAllByRole('button', { name: 'Rename' })
cy.findAllByRole('button', { name: 'Delete' })
})
})