mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Move project context out of scope value store (#26615)
* Refactor project context to not use scope store * Fix Cypress tests for project context changes * Fix frontend React Testing Library tests for project context changes * Remove redundant code * Fix some project types in tests * Remove unused import and fix a type * Throw an error if updating the project in the project context before joining the project * Fix some review panel tests * Remove unused imports GitOrigin-RevId: 2f0c928b651f387aa980c29aef7d1ba0649790a7
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
import { docId } from './mock-doc'
|
||||
import { Folder } from '../../../../../types/folder'
|
||||
import { UserId } from '../../../../../types/user'
|
||||
import { ProjectCompiler } from '../../../../../types/project-settings'
|
||||
|
||||
export const rootFolderId = '012345678901234567890123'
|
||||
export const figuresFolderId = '123456789012345678901234'
|
||||
export const figureId = '234567890123456789012345'
|
||||
export const mockProject = ({
|
||||
projectFeatures = {},
|
||||
projectOwner = undefined,
|
||||
spellCheckLanguage = 'en',
|
||||
rootFolder = null,
|
||||
}: any = {}) => {
|
||||
return {
|
||||
_id: 'test-project',
|
||||
name: 'Test Project',
|
||||
spellCheckLanguage,
|
||||
rootDocId: '_root_doc_id',
|
||||
rootFolder:
|
||||
rootFolder ||
|
||||
([
|
||||
{
|
||||
_id: rootFolderId,
|
||||
name: 'rootFolder',
|
||||
docs: [
|
||||
{
|
||||
_id: docId,
|
||||
name: 'test.tex',
|
||||
},
|
||||
],
|
||||
folders: [
|
||||
{
|
||||
_id: figuresFolderId,
|
||||
name: 'figures',
|
||||
docs: [
|
||||
{
|
||||
_id: 'fake-nested-doc-id',
|
||||
name: 'foo.tex',
|
||||
},
|
||||
],
|
||||
folders: [],
|
||||
fileRefs: [
|
||||
{
|
||||
_id: figureId,
|
||||
name: 'frog.jpg',
|
||||
hash: '42',
|
||||
},
|
||||
{
|
||||
_id: 'fake-figure-id',
|
||||
name: 'unicorn.png',
|
||||
hash: '43',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
fileRefs: [],
|
||||
},
|
||||
] as Folder[]),
|
||||
features: {
|
||||
trackChanges: true,
|
||||
...projectFeatures,
|
||||
},
|
||||
compiler: 'pdflatex' as ProjectCompiler,
|
||||
imageName: 'texlive-full:2024.1',
|
||||
trackChangesState: false,
|
||||
invites: [],
|
||||
members: [],
|
||||
owner: projectOwner || {
|
||||
_id: '124abd' as UserId,
|
||||
email: 'owner@example.com',
|
||||
first_name: 'Test',
|
||||
last_name: 'Owner',
|
||||
privileges: 'owner',
|
||||
signUpDate: new Date('2025-07-07').toISOString(),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,10 @@
|
||||
import { docId, mockDoc } from './mock-doc'
|
||||
import { sleep } from '../../../helpers/sleep'
|
||||
import { Folder } from '../../../../../types/folder'
|
||||
|
||||
export const rootFolderId = '012345678901234567890123'
|
||||
export const figuresFolderId = '123456789012345678901234'
|
||||
export const figureId = '234567890123456789012345'
|
||||
export const mockScope = (
|
||||
content?: string,
|
||||
{
|
||||
docOptions = {},
|
||||
projectFeatures = {},
|
||||
permissions = {},
|
||||
projectOwner = undefined,
|
||||
}: any = {}
|
||||
{ docOptions = {}, permissions = {} }: any = {}
|
||||
) => {
|
||||
return {
|
||||
editor: {
|
||||
@@ -21,55 +13,8 @@ export const mockScope = (
|
||||
currentDocumentId: docId,
|
||||
wantTrackChanges: false,
|
||||
},
|
||||
project: {
|
||||
_id: 'test-project',
|
||||
name: 'Test Project',
|
||||
spellCheckLanguage: 'en',
|
||||
rootFolder: [
|
||||
{
|
||||
_id: rootFolderId,
|
||||
name: 'rootFolder',
|
||||
docs: [
|
||||
{
|
||||
_id: docId,
|
||||
name: 'test.tex',
|
||||
},
|
||||
],
|
||||
folders: [
|
||||
{
|
||||
_id: figuresFolderId,
|
||||
name: 'figures',
|
||||
docs: [
|
||||
{
|
||||
_id: 'fake-nested-doc-id',
|
||||
name: 'foo.tex',
|
||||
},
|
||||
],
|
||||
folders: [],
|
||||
fileRefs: [
|
||||
{
|
||||
_id: figureId,
|
||||
name: 'frog.jpg',
|
||||
hash: '42',
|
||||
},
|
||||
{
|
||||
_id: 'fake-figure-id',
|
||||
name: 'unicorn.png',
|
||||
hash: '43',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
fileRefs: [],
|
||||
},
|
||||
] as Folder[],
|
||||
features: {
|
||||
trackChanges: true,
|
||||
...projectFeatures,
|
||||
},
|
||||
trackChangesState: {},
|
||||
members: [],
|
||||
owner: projectOwner,
|
||||
pdf: {
|
||||
logEntryAnnotations: {},
|
||||
},
|
||||
permissions: {
|
||||
comment: true,
|
||||
|
||||
Reference in New Issue
Block a user