2024-07-24 09:40:24 -04:00
|
|
|
import '../../../../helpers/bootstrap-3'
|
2024-01-18 07:54:24 -05:00
|
|
|
import FileTreeitemInner from '../../../../../../frontend/js/features/file-tree/components/file-tree-item/file-tree-item-inner'
|
|
|
|
import FileTreeContextMenu from '../../../../../../frontend/js/features/file-tree/components/file-tree-context-menu'
|
|
|
|
import { EditorProviders } from '../../../../helpers/editor-providers'
|
|
|
|
import { FileTreeProvider } from '../../helpers/file-tree-provider'
|
|
|
|
|
|
|
|
describe('<FileTreeitemInner />', function () {
|
|
|
|
describe('menu', function () {
|
|
|
|
it('does not display if file is not selected', function () {
|
|
|
|
cy.mount(
|
|
|
|
<EditorProviders>
|
|
|
|
<FileTreeProvider>
|
2024-05-08 06:39:18 -04:00
|
|
|
<FileTreeitemInner
|
|
|
|
id="123abc"
|
|
|
|
name="bar.tex"
|
|
|
|
isSelected={false}
|
|
|
|
type="doc"
|
|
|
|
/>
|
|
|
|
,
|
2024-01-18 07:54:24 -05:00
|
|
|
</FileTreeProvider>
|
|
|
|
</EditorProviders>
|
|
|
|
)
|
|
|
|
|
|
|
|
cy.findByRole('menu', { hidden: true }).should('not.exist')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('context menu', function () {
|
|
|
|
it('does not display without write permissions', function () {
|
|
|
|
cy.mount(
|
|
|
|
<EditorProviders permissionsLevel="readOnly">
|
|
|
|
<FileTreeProvider>
|
2024-05-08 06:39:18 -04:00
|
|
|
<FileTreeitemInner
|
|
|
|
id="123abc"
|
|
|
|
name="bar.tex"
|
|
|
|
isSelected
|
|
|
|
type="doc"
|
|
|
|
/>
|
2024-01-18 07:54:24 -05:00
|
|
|
<FileTreeContextMenu />
|
|
|
|
</FileTreeProvider>
|
|
|
|
</EditorProviders>
|
|
|
|
)
|
|
|
|
|
|
|
|
cy.get('div.entity').trigger('contextmenu')
|
|
|
|
cy.findByRole('menu', { hidden: true }).should('not.exist')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('open / close', function () {
|
|
|
|
cy.mount(
|
|
|
|
<EditorProviders>
|
|
|
|
<FileTreeProvider>
|
2024-05-08 06:39:18 -04:00
|
|
|
<FileTreeitemInner
|
|
|
|
id="123abc"
|
|
|
|
name="bar.tex"
|
|
|
|
isSelected
|
|
|
|
type="doc"
|
|
|
|
/>
|
2024-01-18 07:54:24 -05:00
|
|
|
<FileTreeContextMenu />
|
|
|
|
</FileTreeProvider>
|
|
|
|
</EditorProviders>
|
|
|
|
)
|
|
|
|
|
|
|
|
cy.findByRole('menu', { hidden: true }).should('not.exist')
|
|
|
|
|
|
|
|
// open the context menu
|
|
|
|
cy.get('div.entity').trigger('contextmenu')
|
|
|
|
cy.findByRole('menu')
|
|
|
|
|
|
|
|
// close the context menu
|
|
|
|
cy.get('div.entity').click()
|
|
|
|
cy.findByRole('menu').should('not.exist')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('name', function () {
|
|
|
|
it('renders name', function () {
|
|
|
|
cy.mount(
|
|
|
|
<EditorProviders>
|
|
|
|
<FileTreeProvider>
|
2024-05-08 06:39:18 -04:00
|
|
|
<FileTreeitemInner
|
|
|
|
id="123abc"
|
|
|
|
name="bar.tex"
|
|
|
|
isSelected
|
|
|
|
type="doc"
|
|
|
|
/>
|
2024-01-18 07:54:24 -05:00
|
|
|
</FileTreeProvider>
|
|
|
|
</EditorProviders>
|
|
|
|
)
|
|
|
|
|
|
|
|
cy.findByRole('button', { name: 'bar.tex' })
|
|
|
|
cy.findByRole('textbox').should('not.exist')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('starts rename on menu item click', function () {
|
|
|
|
const rootFolder = [
|
|
|
|
{
|
|
|
|
_id: 'root-folder-id',
|
|
|
|
name: 'rootFolder',
|
|
|
|
docs: [{ _id: '123abc', name: 'bar.tex' }],
|
|
|
|
folders: [],
|
|
|
|
fileRefs: [],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
cy.mount(
|
|
|
|
<EditorProviders rootDocId="123abc" rootFolder={rootFolder as any}>
|
|
|
|
<FileTreeProvider>
|
2024-05-08 06:39:18 -04:00
|
|
|
<FileTreeitemInner
|
|
|
|
id="123abc"
|
|
|
|
name="bar.tex"
|
|
|
|
isSelected
|
|
|
|
type="doc"
|
|
|
|
/>
|
2024-01-18 07:54:24 -05:00
|
|
|
<FileTreeContextMenu />
|
|
|
|
</FileTreeProvider>
|
|
|
|
</EditorProviders>
|
|
|
|
)
|
|
|
|
|
|
|
|
cy.findByRole('button', { name: 'Menu' }).click()
|
|
|
|
cy.findByRole('menuitem', { name: 'Rename' }).click()
|
|
|
|
cy.findByRole('button', { name: 'bar.tex' }).should('not.exist')
|
|
|
|
cy.findByRole('textbox')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|