Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
test(projects): stub navigator in no-Web-Locks tests
Lincoln Stein008e2a974c33
diff --git a/invokeai/frontend/webv2/src/workbench/projects/durableSyncedPersistence.test.ts b/invokeai/frontend/webv2/src/workbench/projects/durableSyncedPersistence.test.tsindex becae26f4a..4821e6ee9f 100644--- a/invokeai/frontend/webv2/src/workbench/projects/durableSyncedPersistence.test.ts+++ b/invokeai/frontend/webv2/src/workbench/projects/durableSyncedPersistence.test.ts@@ -468,14 +468,21 @@ describe('durable project persistence', () => {saveDraftAsNew,writerToken: 'writer-1',});- const loaded = await service.loadWorkbench();+ // A plain-HTTP origin has no navigator.locks; Node 24 defines one, so remove it explicitly.+ vi.stubGlobal('navigator', {});++ try {+ const loaded = await service.loadWorkbench();- await service.resolveConflictDiscard(discarded.id);- const copy = await service.resolveConflictSaveAsNew(loaded.state.projects.find(({ id }) => id === copied.id)!);+ await service.resolveConflictDiscard(discarded.id);+ const copy = await service.resolveConflictSaveAsNew(loaded.state.projects.find(({ id }) => id === copied.id)!);- await expect(draftStore.get(discarded.id, 'editor-1')).resolves.toMatchObject({ kind: 'empty' });- expect(saveDraftAsNew).toHaveBeenCalledOnce();- expect(api.records.has(copy.targetProjectId)).toBe(true);+ await expect(draftStore.get(discarded.id, 'editor-1')).resolves.toMatchObject({ kind: 'empty' });+ expect(saveDraftAsNew).toHaveBeenCalledOnce();+ expect(api.records.has(copy.targetProjectId)).toBe(true);+ } finally {+ vi.unstubAllGlobals();+ }});it('refuses conflict resolution when the lock request fails although the browser has Web Locks', async () => {@@ -521,9 +528,14 @@ describe('durable project persistence', () => {settle: vi.fn(),});const service = createService(owner, api);+ vi.stubGlobal('navigator', {});- await expect(service.resolveConflictSaveAsNew(project)).rejects.toThrow('active queue runs');- await expect(service.resolveConflictDiscard(project.id)).rejects.toThrow('active queue runs');+ try {+ await expect(service.resolveConflictSaveAsNew(project)).rejects.toThrow('active queue runs');+ await expect(service.resolveConflictDiscard(project.id)).rejects.toThrow('active queue runs');+ } finally {+ vi.unstubAllGlobals();+ }expect(api.createProject).not.toHaveBeenCalled();});diff --git a/invokeai/frontend/webv2/src/workbench/projects/library.test.ts b/invokeai/frontend/webv2/src/workbench/projects/library.test.tsindex 3bd51a7573..06423424d2 100644--- a/invokeai/frontend/webv2/src/workbench/projects/library.test.ts+++ b/invokeai/frontend/webv2/src/workbench/projects/library.test.ts@@ -345,10 +345,16 @@ describe('library mutations', () => {});it('deletes in this tab alone when Web Locks are unavailable, as on a plain-HTTP origin', async () => {+ // A plain-HTTP origin has no navigator.locks; Node 24 defines one, so remove it explicitly.+ vi.stubGlobal('navigator', {});projectLocks.acquireProjectMutationLock.mockResolvedValueOnce({ kind: 'unavailable' });api.deleteProject.mockResolvedValue(undefined);- await library.deleteLibraryProject('closed');+ try {+ await library.deleteLibraryProject('closed');+ } finally {+ vi.unstubAllGlobals();+ }expect(api.deleteProject).toHaveBeenCalledWith('closed', expect.any(AbortSignal), 'release');});@@ -368,6 +374,7 @@ describe('library mutations', () => {});it('still refuses without Web Locks while the project has journaled queue runs', async () => {+ vi.stubGlobal('navigator', {});projectLocks.acquireProjectMutationLock.mockResolvedValueOnce({ kind: 'unavailable' });queueJournal.createAccountOwnedQueueRunJournal.mockResolvedValueOnce({close: vi.fn(),@@ -375,7 +382,11 @@ describe('library mutations', () => {listForProject: vi.fn().mockResolvedValue({ entries: [{}], kind: 'available', removedCorrupt: 0 }),});- await expect(library.deleteLibraryProject('closed')).rejects.toThrow('active queue runs');+ try {+ await expect(library.deleteLibraryProject('closed')).rejects.toThrow('active queue runs');+ } finally {+ vi.unstubAllGlobals();+ }expect(api.deleteProject).not.toHaveBeenCalled();});