mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-03 06:09:02 +02:00
Merge pull request #28567 from overleaf/bg-fix-project-locator-root-folder
respect elementType when matching rootFolder in findElement GitOrigin-RevId: f4e20ee6441fc16915297b2ac24737ed63398027
This commit is contained in:
@@ -95,7 +95,10 @@ function findElement(options, _callback) {
|
||||
const path = { fileSystem: '', mongo: 'rootFolder.0' }
|
||||
|
||||
const startSearch = project => {
|
||||
if (elementId + '' === project.rootFolder[0]._id + '') {
|
||||
if (
|
||||
elementId + '' === project.rootFolder[0]._id + '' &&
|
||||
elementType === 'folders'
|
||||
) {
|
||||
callback(null, project.rootFolder[0], path, null)
|
||||
} else {
|
||||
search(project.rootFolder[0], path)
|
||||
|
||||
@@ -112,6 +112,30 @@ describe('ProjectLocator', function () {
|
||||
foundElement._id.should.equal(rootFolder._id)
|
||||
})
|
||||
|
||||
it('should not return root folder when searching for docs', async function () {
|
||||
await expect(
|
||||
this.locator.promises.findElement({
|
||||
project_id: project._id,
|
||||
element_id: rootFolder._id,
|
||||
type: 'docs',
|
||||
})
|
||||
)
|
||||
.to.eventually.be.rejectedWith(Errors.NotFoundError)
|
||||
.and.eventually.have.property('message', 'entity not found')
|
||||
})
|
||||
|
||||
it('should not return root folder when searching for files', async function () {
|
||||
await expect(
|
||||
this.locator.promises.findElement({
|
||||
project_id: project._id,
|
||||
element_id: rootFolder._id,
|
||||
type: 'files',
|
||||
})
|
||||
)
|
||||
.to.eventually.be.rejectedWith(Errors.NotFoundError)
|
||||
.and.eventually.have.property('message', 'entity not found')
|
||||
})
|
||||
|
||||
it('when at root', async function () {
|
||||
const {
|
||||
element: foundElement,
|
||||
|
||||
Reference in New Issue
Block a user