|
@@ -1,3 +1,4 @@
|
|
|
|
|
+import { expect } from 'chai'
|
|
|
import React from 'react'
|
|
import React from 'react'
|
|
|
import sinon from 'sinon'
|
|
import sinon from 'sinon'
|
|
|
import { screen, render, fireEvent, waitFor } from '@testing-library/react'
|
|
import { screen, render, fireEvent, waitFor } from '@testing-library/react'
|
|
@@ -30,7 +31,7 @@ describe('<FileTreeRoot/>', function() {
|
|
|
fileRefs: []
|
|
fileRefs: []
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
|
- render(
|
|
|
|
|
|
|
+ const { container } = render(
|
|
|
<FileTreeRoot
|
|
<FileTreeRoot
|
|
|
rootFolder={rootFolder}
|
|
rootFolder={rootFolder}
|
|
|
projectId="123abc"
|
|
projectId="123abc"
|
|
@@ -38,12 +39,14 @@ describe('<FileTreeRoot/>', function() {
|
|
|
rootDocId="456def"
|
|
rootDocId="456def"
|
|
|
onSelect={onSelect}
|
|
onSelect={onSelect}
|
|
|
onInit={onInit}
|
|
onInit={onInit}
|
|
|
|
|
+ isConnected
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
screen.queryByRole('tree')
|
|
screen.queryByRole('tree')
|
|
|
screen.getByRole('treeitem')
|
|
screen.getByRole('treeitem')
|
|
|
screen.getByRole('treeitem', { name: 'main.tex', selected: true })
|
|
screen.getByRole('treeitem', { name: 'main.tex', selected: true })
|
|
|
|
|
+ expect(container.querySelector('.disconnected-overlay')).to.not.exist
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('renders with invalid selected doc in local storage', async function() {
|
|
it('renders with invalid selected doc in local storage', async function() {
|
|
@@ -67,6 +70,7 @@ describe('<FileTreeRoot/>', function() {
|
|
|
rootDocId="456def"
|
|
rootDocId="456def"
|
|
|
onSelect={onSelect}
|
|
onSelect={onSelect}
|
|
|
onInit={onInit}
|
|
onInit={onInit}
|
|
|
|
|
+ isConnected
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -80,6 +84,31 @@ describe('<FileTreeRoot/>', function() {
|
|
|
await waitFor(() => screen.getByRole('button', { name: 'Cancel' }))
|
|
await waitFor(() => screen.getByRole('button', { name: 'Cancel' }))
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ it('renders disconnected overlay', function() {
|
|
|
|
|
+ const rootFolder = [
|
|
|
|
|
+ {
|
|
|
|
|
+ _id: 'root-folder-id',
|
|
|
|
|
+ docs: [{ _id: '456def', name: 'main.tex' }],
|
|
|
|
|
+ folders: [],
|
|
|
|
|
+ fileRefs: []
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+
|
|
|
|
|
+ const { container } = render(
|
|
|
|
|
+ <FileTreeRoot
|
|
|
|
|
+ rootFolder={rootFolder}
|
|
|
|
|
+ projectId="123abc"
|
|
|
|
|
+ hasWritePermissions={false}
|
|
|
|
|
+ rootDocId="456def"
|
|
|
|
|
+ onSelect={onSelect}
|
|
|
|
|
+ onInit={onInit}
|
|
|
|
|
+ isConnected={false}
|
|
|
|
|
+ />
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ expect(container.querySelector('.disconnected-overlay')).to.exist
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
it('fire onSelect', function() {
|
|
it('fire onSelect', function() {
|
|
|
const rootFolder = [
|
|
const rootFolder = [
|
|
|
{
|
|
{
|
|
@@ -100,6 +129,7 @@ describe('<FileTreeRoot/>', function() {
|
|
|
hasWritePermissions={false}
|
|
hasWritePermissions={false}
|
|
|
onSelect={onSelect}
|
|
onSelect={onSelect}
|
|
|
onInit={onInit}
|
|
onInit={onInit}
|
|
|
|
|
+ isConnected
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
sinon.assert.calledOnce(onSelect)
|
|
sinon.assert.calledOnce(onSelect)
|
|
@@ -147,6 +177,7 @@ describe('<FileTreeRoot/>', function() {
|
|
|
hasWritePermissions={false}
|
|
hasWritePermissions={false}
|
|
|
onSelect={onSelect}
|
|
onSelect={onSelect}
|
|
|
onInit={onInit}
|
|
onInit={onInit}
|
|
|
|
|
+ isConnected
|
|
|
/>
|
|
/>
|
|
|
)
|
|
)
|
|
|
|
|
|