mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Merge pull request #3495 from overleaf/ae-prettier-2
Upgrade Prettier to v2 GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
@@ -5,11 +5,11 @@ import { screen, render, fireEvent } from '@testing-library/react'
|
||||
|
||||
import FileTreeRoot from '../../../../../frontend/js/features/file-tree/components/file-tree-root'
|
||||
|
||||
describe('FileTree Context Menu Flow', function() {
|
||||
describe('FileTree Context Menu Flow', function () {
|
||||
const onSelect = sinon.stub()
|
||||
const onInit = sinon.stub()
|
||||
|
||||
it('opens on contextMenu event', async function() {
|
||||
it('opens on contextMenu event', async function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
_id: 'root-folder-id',
|
||||
@@ -43,7 +43,7 @@ describe('FileTree Context Menu Flow', function() {
|
||||
expect(screen.getAllByRole('menu').length).to.equal(2) // toolbar + menu
|
||||
})
|
||||
|
||||
it("doesn't open in read only mode", async function() {
|
||||
it("doesn't open in read only mode", async function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
_id: 'root-folder-id',
|
||||
|
||||
@@ -7,18 +7,18 @@ import MockedSocket from 'socket.io-mock'
|
||||
|
||||
import FileTreeRoot from '../../../../../frontend/js/features/file-tree/components/file-tree-root'
|
||||
|
||||
describe('FileTree Create Folder Flow', function() {
|
||||
describe('FileTree Create Folder Flow', function () {
|
||||
const onSelect = sinon.stub()
|
||||
const onInit = sinon.stub()
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
global.requestAnimationFrame = sinon.stub()
|
||||
window._ide = {
|
||||
socket: new MockedSocket()
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
delete global.requestAnimationFrame
|
||||
fetchMock.restore()
|
||||
onSelect.reset()
|
||||
@@ -26,7 +26,7 @@ describe('FileTree Create Folder Flow', function() {
|
||||
delete window._ide
|
||||
})
|
||||
|
||||
it('add to root when no files are selected', async function() {
|
||||
it('add to root when no files are selected', async function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
_id: 'root-folder-id',
|
||||
@@ -78,7 +78,7 @@ describe('FileTree Create Folder Flow', function() {
|
||||
await screen.findByRole('treeitem', { name: newFolderName })
|
||||
})
|
||||
|
||||
it('add to folder from folder', async function() {
|
||||
it('add to folder from folder', async function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
_id: 'root-folder-id',
|
||||
@@ -148,7 +148,7 @@ describe('FileTree Create Folder Flow', function() {
|
||||
expect(screen.queryByRole('treeitem', { name: newFolderName })).to.not.exist
|
||||
})
|
||||
|
||||
it('add to folder from child', async function() {
|
||||
it('add to folder from child', async function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
_id: 'root-folder-id',
|
||||
@@ -215,7 +215,7 @@ describe('FileTree Create Folder Flow', function() {
|
||||
expect(screen.queryByRole('treeitem', { name: newFolderName })).to.not.exist
|
||||
})
|
||||
|
||||
it('prevents adding duplicate or invalid names', async function() {
|
||||
it('prevents adding duplicate or invalid names', async function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
_id: 'root-folder-id',
|
||||
@@ -278,9 +278,7 @@ describe('FileTree Create Folder Flow', function() {
|
||||
}
|
||||
|
||||
function fakeId() {
|
||||
return Math.random()
|
||||
.toString(16)
|
||||
.replace(/0\./, 'random-test-id-')
|
||||
return Math.random().toString(16).replace(/0\./, 'random-test-id-')
|
||||
}
|
||||
|
||||
async function getModalCreateButton() {
|
||||
|
||||
@@ -7,25 +7,25 @@ import MockedSocket from 'socket.io-mock'
|
||||
|
||||
import FileTreeRoot from '../../../../../frontend/js/features/file-tree/components/file-tree-root'
|
||||
|
||||
describe('FileTree Delete Entity Flow', function() {
|
||||
describe('FileTree Delete Entity Flow', function () {
|
||||
const onSelect = sinon.stub()
|
||||
const onInit = sinon.stub()
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
window._ide = {
|
||||
socket: new MockedSocket()
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
fetchMock.restore()
|
||||
onSelect.reset()
|
||||
onInit.reset()
|
||||
delete window._ide
|
||||
})
|
||||
|
||||
describe('single entity', function() {
|
||||
beforeEach(function() {
|
||||
describe('single entity', function () {
|
||||
beforeEach(function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
_id: 'root-folder-id',
|
||||
@@ -57,7 +57,7 @@ describe('FileTree Delete Entity Flow', function() {
|
||||
fireEvent.click(deleteButton)
|
||||
})
|
||||
|
||||
it('removes item', async function() {
|
||||
it('removes item', async function () {
|
||||
const fetchMatcher = /\/project\/\w+\/doc\/\w+/
|
||||
fetchMock.delete(fetchMatcher, 204)
|
||||
|
||||
@@ -88,7 +88,7 @@ describe('FileTree Delete Entity Flow', function() {
|
||||
expect(lastFetchPath).to.equal('/project/123abc/doc/456def')
|
||||
})
|
||||
|
||||
it('continues delete on 404s', async function() {
|
||||
it('continues delete on 404s', async function () {
|
||||
fetchMock.delete(/\/project\/\w+\/doc\/\w+/, 404)
|
||||
|
||||
const modalDeleteButton = await getModalDeleteButton()
|
||||
@@ -119,7 +119,7 @@ describe('FileTree Delete Entity Flow', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('aborts delete on error', async function() {
|
||||
it('aborts delete on error', async function () {
|
||||
const fetchMatcher = /\/project\/\w+\/doc\/\w+/
|
||||
fetchMock.delete(fetchMatcher, 500)
|
||||
|
||||
@@ -131,8 +131,8 @@ describe('FileTree Delete Entity Flow', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('folders', function() {
|
||||
beforeEach(function() {
|
||||
describe('folders', function () {
|
||||
beforeEach(function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
docs: [{ _id: '456def', name: 'main.tex' }],
|
||||
@@ -174,15 +174,15 @@ describe('FileTree Delete Entity Flow', function() {
|
||||
window._ide.socket.socketClient.emit('removeEntity', '123abc')
|
||||
})
|
||||
|
||||
it('removes the folder', function() {
|
||||
it('removes the folder', function () {
|
||||
expect(screen.queryByRole('treeitem', { name: 'folder' })).to.not.exist
|
||||
})
|
||||
|
||||
it('leaves the main file selected', function() {
|
||||
it('leaves the main file selected', function () {
|
||||
screen.getByRole('treeitem', { name: 'main.tex', selected: true })
|
||||
})
|
||||
|
||||
it('unselect the child entity', async function() {
|
||||
it('unselect the child entity', async function () {
|
||||
// as a proxy to check that the child entity has been unselect we start
|
||||
// a delete and ensure the modal is displayed (the cancel button can be
|
||||
// selected) This is needed to make sure the test fail.
|
||||
@@ -192,8 +192,8 @@ describe('FileTree Delete Entity Flow', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('multiple entities', function() {
|
||||
beforeEach(function() {
|
||||
describe('multiple entities', function () {
|
||||
beforeEach(function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
_id: 'root-folder-id',
|
||||
@@ -229,7 +229,7 @@ describe('FileTree Delete Entity Flow', function() {
|
||||
fireEvent.click(deleteButton)
|
||||
})
|
||||
|
||||
it('removes all items', async function() {
|
||||
it('removes all items', async function () {
|
||||
const fetchMatcher = /\/project\/\w+\/(doc|file)\/\w+/
|
||||
fetchMock.delete(fetchMatcher, 204)
|
||||
|
||||
|
||||
@@ -7,18 +7,18 @@ import MockedSocket from 'socket.io-mock'
|
||||
|
||||
import FileTreeRoot from '../../../../../frontend/js/features/file-tree/components/file-tree-root'
|
||||
|
||||
describe('FileTree Rename Entity Flow', function() {
|
||||
describe('FileTree Rename Entity Flow', function () {
|
||||
const onSelect = sinon.stub()
|
||||
const onInit = sinon.stub()
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
window._ide = {
|
||||
socket: new MockedSocket()
|
||||
}
|
||||
global.requestAnimationFrame = sinon.stub()
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
delete global.requestAnimationFrame
|
||||
fetchMock.restore()
|
||||
onSelect.reset()
|
||||
@@ -26,7 +26,7 @@ describe('FileTree Rename Entity Flow', function() {
|
||||
delete window._ide
|
||||
})
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
_id: 'root-folder-id',
|
||||
@@ -63,7 +63,7 @@ describe('FileTree Rename Entity Flow', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('renames doc', function() {
|
||||
it('renames doc', function () {
|
||||
const fetchMatcher = /\/project\/\w+\/doc\/\w+\/rename/
|
||||
fetchMock.post(fetchMatcher, 204)
|
||||
|
||||
@@ -77,7 +77,7 @@ describe('FileTree Rename Entity Flow', function() {
|
||||
expect(lastFetchBody.name).to.equal('b.tex')
|
||||
})
|
||||
|
||||
it('renames folder', function() {
|
||||
it('renames folder', function () {
|
||||
const fetchMatcher = /\/project\/\w+\/folder\/\w+\/rename/
|
||||
fetchMock.post(fetchMatcher, 204)
|
||||
|
||||
@@ -91,7 +91,7 @@ describe('FileTree Rename Entity Flow', function() {
|
||||
expect(lastFetchBody.name).to.equal('new folder name')
|
||||
})
|
||||
|
||||
it('renames file in subfolder', function() {
|
||||
it('renames file in subfolder', function () {
|
||||
const fetchMatcher = /\/project\/\w+\/file\/\w+\/rename/
|
||||
fetchMock.post(fetchMatcher, 204)
|
||||
|
||||
@@ -109,7 +109,7 @@ describe('FileTree Rename Entity Flow', function() {
|
||||
expect(lastFetchBody.name).to.equal('d.tex')
|
||||
})
|
||||
|
||||
it('reverts rename on error', async function() {
|
||||
it('reverts rename on error', async function () {
|
||||
const fetchMatcher = /\/project\/\w+\/doc\/\w+\/rename/
|
||||
fetchMock.post(fetchMatcher, 500)
|
||||
|
||||
@@ -120,7 +120,7 @@ describe('FileTree Rename Entity Flow', function() {
|
||||
screen.getByRole('treeitem', { name: 'b.tex' })
|
||||
})
|
||||
|
||||
it('shows error modal on invalid filename', async function() {
|
||||
it('shows error modal on invalid filename', async function () {
|
||||
const input = initItemRename('a.tex')
|
||||
fireEvent.change(input, { target: { value: '///' } })
|
||||
fireEvent.keyDown(input, { key: 'Enter' })
|
||||
@@ -131,7 +131,7 @@ describe('FileTree Rename Entity Flow', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('shows error modal on duplicate filename', async function() {
|
||||
it('shows error modal on duplicate filename', async function () {
|
||||
const input = initItemRename('a.tex')
|
||||
fireEvent.change(input, { target: { value: 'folder' } })
|
||||
fireEvent.keyDown(input, { key: 'Enter' })
|
||||
@@ -142,7 +142,7 @@ describe('FileTree Rename Entity Flow', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('shows error modal on duplicate filename in subfolder', async function() {
|
||||
it('shows error modal on duplicate filename in subfolder', async function () {
|
||||
const expandButton = screen.queryByRole('button', { name: 'Expand' })
|
||||
if (expandButton) fireEvent.click(expandButton)
|
||||
|
||||
@@ -156,7 +156,7 @@ describe('FileTree Rename Entity Flow', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('shows error modal on blocked filename', async function() {
|
||||
it('shows error modal on blocked filename', async function () {
|
||||
const input = initItemRename('a.tex')
|
||||
fireEvent.change(input, { target: { value: 'prototype' } })
|
||||
fireEvent.keyDown(input, { key: 'Enter' })
|
||||
@@ -167,8 +167,8 @@ describe('FileTree Rename Entity Flow', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('via socket event', function() {
|
||||
it('renames doc', function() {
|
||||
describe('via socket event', function () {
|
||||
it('renames doc', function () {
|
||||
screen.getByRole('treeitem', { name: 'a.tex' })
|
||||
|
||||
window._ide.socket.socketClient.emit(
|
||||
|
||||
Reference in New Issue
Block a user