2020-11-26 14:22:30 +00:00
|
|
|
import { expect } from 'chai'
|
|
|
|
import { screen } from '@testing-library/react'
|
|
|
|
import renderWithContext from '../helpers/render-with-context'
|
|
|
|
|
|
|
|
import FileTreeToolbar from '../../../../../frontend/js/features/file-tree/components/file-tree-toolbar'
|
|
|
|
|
2021-04-14 13:17:21 +00:00
|
|
|
describe('<FileTreeToolbar/>', function () {
|
|
|
|
beforeEach(function () {
|
2021-01-07 14:22:40 +00:00
|
|
|
global.localStorage.clear()
|
|
|
|
})
|
|
|
|
|
2021-04-14 13:17:21 +00:00
|
|
|
it('without selected files', function () {
|
2020-11-26 14:22:30 +00:00
|
|
|
renderWithContext(<FileTreeToolbar />)
|
|
|
|
|
2020-12-10 11:15:05 +00:00
|
|
|
screen.getByRole('button', { name: 'New File' })
|
|
|
|
screen.getByRole('button', { name: 'New Folder' })
|
|
|
|
screen.getByRole('button', { name: 'Upload' })
|
2020-11-26 14:22:30 +00:00
|
|
|
expect(screen.queryByRole('button', { name: 'Rename' })).to.not.exist
|
|
|
|
expect(screen.queryByRole('button', { name: 'Delete' })).to.not.exist
|
|
|
|
})
|
|
|
|
|
2021-04-14 13:17:21 +00:00
|
|
|
it('read-only', function () {
|
2020-11-26 14:22:30 +00:00
|
|
|
renderWithContext(<FileTreeToolbar />, {
|
2022-01-10 15:46:46 +00:00
|
|
|
contextProps: { permissionsLevel: 'readOnly' },
|
2020-11-26 14:22:30 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
expect(screen.queryByRole('button')).to.not.exist
|
|
|
|
})
|
|
|
|
|
2021-04-14 13:17:21 +00:00
|
|
|
it('with one selected file', function () {
|
2020-11-26 14:22:30 +00:00
|
|
|
renderWithContext(<FileTreeToolbar />, {
|
2021-01-08 10:03:10 +00:00
|
|
|
contextProps: {
|
|
|
|
rootDocId: '456def',
|
2022-01-10 15:47:01 +00:00
|
|
|
rootFolder: [
|
2021-01-08 10:03:10 +00:00
|
|
|
{
|
|
|
|
_id: 'root-folder-id',
|
2022-01-10 15:46:46 +00:00
|
|
|
name: 'rootFolder',
|
2021-01-08 10:03:10 +00:00
|
|
|
docs: [{ _id: '456def', name: 'main.tex' }],
|
|
|
|
folders: [],
|
2021-04-27 07:52:58 +00:00
|
|
|
fileRefs: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2020-11-26 14:22:30 +00:00
|
|
|
})
|
|
|
|
|
2020-12-10 11:15:05 +00:00
|
|
|
screen.getByRole('button', { name: 'New File' })
|
|
|
|
screen.getByRole('button', { name: 'New Folder' })
|
|
|
|
screen.getByRole('button', { name: 'Upload' })
|
2020-11-26 14:22:30 +00:00
|
|
|
screen.getByRole('button', { name: 'Rename' })
|
|
|
|
screen.getByRole('button', { name: 'Delete' })
|
|
|
|
})
|
|
|
|
})
|