Skip to content

Commit 3ebc382

Browse files
test: cover read gating during a workspace storage transition
readIndex/readPayload/getPayloadKeys switched to isStorageReadable(), which permits reads while a transition is in progress and resumeAvailability is 'available' -- distinct from isStorageAvailable(), which writes use. No test asserted this; a regression that read-gated on isStorageAvailable() instead would have passed the existing suite. Also moved the transition-lifecycle tests out of the clearWorkflowRestoreState describe block into their own, since they exercise the transition state machine rather than that function specifically. Found by CodeRabbit on #14337.
1 parent 6dc319e commit 3ebc382

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/platform/workflow/persistence/base/storageIO.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ describe('storageIO', () => {
388388
})
389389
})
390390

391-
describe('clearWorkflowRestoreState', () => {
391+
describe('workflow storage transitions', () => {
392392
it('blocks writes and clears restore state when a persistence flush fails', async () => {
393393
const isolatedStorageIO = await import('./storageIO')
394394
localStorage.setItem('workflow', '{}')
@@ -497,6 +497,23 @@ describe('storageIO', () => {
497497
expect(isolatedStorageIO.isStorageAvailable()).toBe(true)
498498
})
499499

500+
it('keeps reads available while a workspace transition blocks writes', async () => {
501+
const isolatedStorageIO = await import('./storageIO')
502+
503+
isolatedStorageIO.writePayload('ws-1', 'draft', {
504+
data: '{}',
505+
updatedAt: 1
506+
})
507+
const cancelTransition =
508+
isolatedStorageIO.prepareWorkflowWorkspaceTransition()
509+
510+
expect(isolatedStorageIO.readPayload('ws-1', 'draft')).not.toBeNull()
511+
expect(isolatedStorageIO.getPayloadKeys('ws-1')).toContain('draft')
512+
cancelTransition()
513+
})
514+
})
515+
516+
describe('clearWorkflowRestoreState', () => {
500517
it('clears cross-workspace restore state without deleting scoped drafts', () => {
501518
localStorage.setItem('Comfy.Workflow.DraftIndex.v2:ws-1', '{}')
502519
localStorage.setItem('Comfy.Workflow.Draft.v2:ws-1:abc', '{}')

0 commit comments

Comments
 (0)