[web] Disable various editor buttons during network stall (#34247)

Co-authored-by: Davinder Singh <davibaweja@gmail.com>
GitOrigin-RevId: 9e169f3591cfff2fdae63b461b946fde4611f2d7
This commit is contained in:
Mathias Jakobsen
2026-09-17 11:25:49 +00:00
committed by Copybot
co-authored by Davinder Singh
parent 8741846df8
commit 1acb00407e
21 changed files with 351 additions and 20 deletions
@@ -20,6 +20,7 @@ const defaultIdeReactContextValue = {
const defaultUnsavedDocsContextValue = {
unsavedDocs: new Map<string, number>(),
isLocked: false,
isSavingStalled: false,
}
const mount = ({
@@ -8,6 +8,7 @@ import { SplitTestProvider } from '@/shared/context/split-test-context'
const defaultUnsavedDocsContextValue = {
unsavedDocs: new Map<string, number>([['doc1', 16]]),
isLocked: false,
isSavingStalled: false,
}
const mockSocket = {
@@ -48,6 +48,7 @@ function mount(
projectJoined: true,
permissionsLevel: 'owner' as PermissionsLevel,
setPermissionsLevel: onSetPermissionsLevel,
outOfSync: false,
setOutOfSync: () => {},
}))
@@ -0,0 +1,54 @@
import React, { type FC, type PropsWithChildren } from 'react'
import {
EditorManager,
EditorManagerContext,
} from '@/features/ide-react/context/editor-manager-context'
export function makeEditorManagerProviderWithStaleDocs(
pendingAt: number,
stubs?: {
openDocWithId?: any
openDoc?: any
openFileWithId?: any
}
) {
const staleDocs = [
{
doc_id: 'stale-doc',
getInflightOpCreatedAt: () => undefined,
getPendingOpCreatedAt: () => pendingAt,
},
]
const EditorManagerProviderWithStaleDocs: FC<PropsWithChildren> = ({
children,
}) => {
const value = {
getEditorType: () => null,
getCurrentDocValue: () => null,
getCurrentDocumentId: () => null,
setIgnoringExternalUpdates: () => {},
openDocWithId: stubs?.openDocWithId ?? cy.stub().resolves(),
openDoc: stubs?.openDoc ?? cy.stub().resolves(),
openDocs: {
awaitBufferedOps: cy.stub().resolves(),
unsavedDocs: () => staleDocs,
hasUnsavedChanges: () => true,
getUnsavedOpsSize: () => ({
pendingOpsLength: 0,
inflightOpsLength: 0,
}),
} as any,
openFileWithId: stubs?.openFileWithId ?? cy.stub(),
openInitialDoc: cy.stub().resolves(),
isLoading: false,
jumpToLine: () => {},
debugTimers: { current: {} },
} as unknown as EditorManager
return (
<EditorManagerContext.Provider value={value}>
{children}
</EditorManagerContext.Provider>
)
}
return EditorManagerProviderWithStaleDocs
}