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
import { describe, expect, it } from 'vitest';
import { createEmptyCanvasState } from './canvasMigration';
import { MAX_SUPPORTED_CANVAS_SCHEMA_VERSION } from './canvasSchemaVersion';
import { gateProjectCanvases } from './projectCanvasGate';
const canvas = createEmptyCanvasState();
describe('gateProjectCanvases', () => {
it('admits a project whose live canvas loads and ignores removed queue history', () => {
expect(gateProjectCanvases({ canvas, id: 'p', name: 'P', queue: { items: [{ snapshot: null }] } })).toBeNull();
expect(gateProjectCanvases({ id: 'legacy', name: 'Legacy' })).toBeNull();
expect(gateProjectCanvases('not a project')).toBeNull();
});
it('refuses a project whose live canvas is unsupported or invalid, keeping the raw document', () => {
const future = { canvas: { ...canvas, version: MAX_SUPPORTED_CANVAS_SCHEMA_VERSION + 1 }, id: 'p', name: 'P' };
const broken = { canvas: { ...canvas, version: '2' }, id: 'p', name: 'P' };
expect(gateProjectCanvases(future)).toMatchObject({
projectId: 'p',
projectName: 'P',
raw: future,
refusal: { scope: 'state', status: 'unsupported-version', version: MAX_SUPPORTED_CANVAS_SCHEMA_VERSION + 1 },
source: 'canvas',
});
expect(gateProjectCanvases(broken)).toMatchObject({
raw: broken,
refusal: { status: 'invalid' },
source: 'canvas',
});
});
});