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:
Tim Down
2025-07-10 08:06:31 +00:00
committed by Copybot
parent 9237d8227b
commit 905cc5d45f
79 changed files with 806 additions and 703 deletions
@@ -4,11 +4,16 @@ import {
OverallThemeMeta,
SpellCheckLanguage,
} from '../../../../types/project-settings'
import { EditorProviders } from '../../helpers/editor-providers'
import {
EditorProviders,
makeProjectProvider,
} from '../../helpers/editor-providers'
import { mockScope } from './scope'
import { Folder } from '../../../../types/folder'
import { docsInFolder } from '@/features/file-tree/util/docs-in-folder'
import getMeta from '@/utils/meta'
import { mockProject } from '../../features/source-editor/helpers/mock-project'
import { UserId } from '../../../../types/user'
describe('<EditorLeftMenu />', function () {
beforeEach(function () {
@@ -57,9 +62,14 @@ describe('<EditorLeftMenu />', function () {
it('render full menu', function () {
const scope = mockScope()
const project = mockProject()
cy.mount(
<EditorProviders scope={scope} layoutContext={{ leftMenuShown: true }}>
<EditorProviders
scope={scope}
layoutContext={{ leftMenuShown: true }}
providers={{ ProjectProvider: makeProjectProvider(project) }}
>
<EditorLeftMenu />
</EditorProviders>
)
@@ -209,12 +219,6 @@ describe('<EditorLeftMenu />', function () {
})
const scope = mockScope({
project: {
members: [],
owner: {
_id: '123',
},
},
user: {
features: {
dropbox: false,
@@ -226,6 +230,14 @@ describe('<EditorLeftMenu />', function () {
<EditorProviders
scope={scope}
layoutContext={{ leftMenuShown: true }}
projectOwner={{
_id: '123' as UserId,
email: 'owner@example.com',
first_name: 'Test',
last_name: 'Owner',
privileges: 'owner',
signUpDate: new Date('2025-07-07').toISOString(),
}}
>
<EditorLeftMenu />
</EditorProviders>
@@ -236,21 +248,25 @@ describe('<EditorLeftMenu />', function () {
})
it('shows git modal correctly', function () {
const scope = mockScope({
project: {
owner: {
_id: '123',
},
features: {
gitBridge: true,
},
},
})
const scope = mockScope()
cy.mount(
<EditorProviders
scope={scope}
layoutContext={{ leftMenuShown: true }}
projectOwner={{
_id: '123' as UserId,
email: 'owner@example.com',
first_name: 'Test',
last_name: 'Owner',
privileges: 'owner',
signUpDate: new Date('2025-07-07').toISOString(),
}}
projectFeatures={
{
gitBridge: true,
} as any
}
>
<EditorLeftMenu />
</EditorProviders>
@@ -262,21 +278,25 @@ describe('<EditorLeftMenu />', function () {
})
it('shows git modal paywall correctly', function () {
const scope = mockScope({
project: {
owner: {
_id: '123',
},
features: {
gitBridge: false,
},
},
})
const scope = mockScope()
cy.mount(
<EditorProviders
scope={scope}
layoutContext={{ leftMenuShown: true }}
projectOwner={{
_id: '123' as UserId,
email: 'owner@example.com',
first_name: 'Test',
last_name: 'Owner',
privileges: 'owner',
signUpDate: new Date('2025-07-07').toISOString(),
}}
projectFeatures={
{
gitBridge: false,
} as any
}
>
<EditorLeftMenu />
</EditorProviders>
@@ -9,6 +9,7 @@ import {
} from '../../../../frontend/js/shared/context/layout-context'
import { FC, PropsWithChildren, useEffect } from 'react'
import { useLocalCompileContext } from '@/shared/context/local-compile-context'
import { ProjectCompiler } from '../../../../types/project-settings'
const storeAndFireEvent = (win: typeof window, key: string, value: unknown) => {
localStorage.setItem(key, value)
@@ -215,7 +216,7 @@ describe('<PdfPreview/>', function () {
cached: false,
setup: () => {},
props: {
compiler: 'lualatex',
compiler: 'lualatex' as ProjectCompiler,
},
},
'ignores the compile from cache when draft mode changed': {