[web] Move pdf.* scopes to react states (#26599)

* Move `pdf.logEntryAnnotations` to react state

* Remove unused scope `pdf.downloadUrl`

* Remove unused scope `pdf.url`

* Move `pdf.uncompiled` to react state

* Move `pdf.logEntries` to react state

* Remove `pdf` from `mockScope`

* Fix test: "renders annotations in the gutter"

GitOrigin-RevId: bf1d0ec30cc0ffcc1177871651483c296ed08baf
This commit is contained in:
Antoine Clausse
2025-07-03 08:04:58 +00:00
committed by Copybot
parent 67342e9c33
commit 40136785dd
4 changed files with 42 additions and 29 deletions
@@ -7,7 +7,9 @@ import { activeEditorLine } from '../helpers/active-editor-line'
import { TestContainer } from '../helpers/test-container'
import customLocalStorage from '@/infrastructure/local-storage'
import { OnlineUsersContext } from '@/features/ide-react/context/online-users-context'
import { FC } from 'react'
import { LocalCompileContext } from '@/shared/context/local-compile-context'
import type { FC, PropsWithChildren } from 'react'
import type { Annotation } from '../../../../../types/annotation'
describe('<CodeMirrorEditor/>', { scrollBehavior: false }, function () {
beforeEach(function () {
@@ -64,27 +66,39 @@ describe('<CodeMirrorEditor/>', { scrollBehavior: false }, function () {
it('renders annotations in the gutter', function () {
const scope = mockScope()
scope.pdf.logEntryAnnotations = {
const logEntryAnnotations: Record<string, Annotation[]> = {
[docId]: [
{
id: '1',
entryIndex: 1,
row: 20,
type: 'error',
text: 'Another error',
firstOnLine: true,
},
{
id: '2',
entryIndex: 2,
row: 19,
type: 'error',
text: 'An error',
firstOnLine: true,
},
{
id: '3',
entryIndex: 3,
row: 20,
type: 'warning',
text: 'A warning on the same line',
firstOnLine: false,
},
{
id: '4',
entryIndex: 4,
row: 25,
type: 'warning',
text: 'Another warning',
firstOnLine: true,
},
],
}
@@ -93,9 +107,19 @@ describe('<CodeMirrorEditor/>', { scrollBehavior: false }, function () {
cy.clock()
const LocalCompileProvider: FC<PropsWithChildren> = ({ children }) => (
// @ts-expect-error: not entering all the values for LocalCompileContext
<LocalCompileContext.Provider value={{ logEntryAnnotations }}>
{children}
</LocalCompileContext.Provider>
)
cy.mount(
<TestContainer>
<EditorProviders scope={scope} userSettings={userSettings}>
<EditorProviders
scope={scope}
userSettings={userSettings}
providers={{ LocalCompileProvider }}
>
<CodeMirrorEditor />
</EditorProviders>
</TestContainer>
@@ -22,9 +22,6 @@ export const mockScope = (
showVisual: false,
wantTrackChanges: false,
},
pdf: {
logEntryAnnotations: {},
},
project: {
_id: 'test-project',
name: 'Test Project',