Skip to content

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.

1.7 KB
Raw Blame
import { createMenuPartLoader } from '@platform/ui/Menu';

import type { QueueLocalRun, QueueUiAdapter } from './QueueUiContext';
import type { QueueWidgetRuntime } from './QueueWidgetView';

const noLoadingModel = { getLabel: (): string | null => null, subscribe: () => () => undefined };

/** A single-user adapter that can manage everything, connected, with nothing queued locally. */
export const createTestQueueUiAdapter = (overrides: Partial<QueueUiAdapter> = {}): QueueUiAdapter => ({
  ItemActions: () => null,
  activeProjectId: null,
  activeProjectName: null,
  canManageInvocationCache: false,
  canManageModelCache: false,
  canManageItem: () => true,
  canManageProcessor: true,
  canViewItemDetails: () => true,
  cancelLocalRun: () => undefined,
  cancelLocalRuns: () => undefined,
  isConnected: true,
  isProjectOpen: () => true,
  itemRecallMenuGroup: createMenuPartLoader(() => Promise.resolve(() => null)),
  loadingModel: noLoadingModel,
  localRuns: [],
  notify: { error: () => undefined, info: () => undefined, success: () => undefined },
  openQueue: () => undefined,
  preloadItemActions: () => undefined,
  queueJobsScope: 'all',
  recallAllFromItem: () => undefined,
  viewer: 'single',
  ...overrides,
});

/** A run this tab queued long ago in `project-1` and is still submitting, with no failure yet. */
export const createTestLocalRun = (overrides: Partial<QueueLocalRun> = {}): QueueLocalRun => ({
  id: 'run-1',
  label: 'A castle at dusk',
  projectId: 'project-1',
  retry: null,
  submittedAt: 0,
  ...overrides,
});

/** A widget runtime that takes registrations and runs nothing. */
export const createTestQueueWidgetRuntime = (): QueueWidgetRuntime => ({
  commands: { register: () => () => undefined },
});