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.5 KB
Raw Blame
import { isLaunchpadIntentId, LAUNCHPAD_INTENT_IDS, resolveLaunchpadIntent } from '@workbench/launchpad/intents';
import { builtInLayoutPresetDescriptors } from '@workbench/layoutPresets';
import { describe, expect, it } from 'vitest';

describe('launchpad intents', () => {
  it('names a real built-in preset for every intent', () => {
    const presetIds = new Set(builtInLayoutPresetDescriptors.map((descriptor) => descriptor.preset.id));

    for (const id of LAUNCHPAD_INTENT_IDS) {
      expect(presetIds).toContain(resolveLaunchpadIntent(id)?.presetId);
    }
  });

  it('opens text-to-image in Compose and node work in Workflow', () => {
    expect(resolveLaunchpadIntent('generate')).toEqual({ id: 'generate', presetId: 'compose', sourceId: 'generate' });
    expect(resolveLaunchpadIntent('workflow')).toEqual({ id: 'workflow', presetId: 'automate', sourceId: 'workflow' });
  });

  it('sets a source that a preset alone could not imply', () => {
    const generate = resolveLaunchpadIntent('generate');
    const upscale = resolveLaunchpadIntent('upscale');

    expect(generate?.presetId).toBe(upscale?.presetId);
    expect(generate?.sourceId).not.toBe(upscale?.sourceId);
  });

  it('falls back to no intent for a stale or hand-edited value', () => {
    expect(resolveLaunchpadIntent('sideways')).toBeNull();
    expect(resolveLaunchpadIntent(undefined)).toBeNull();
    expect(resolveLaunchpadIntent(42)).toBeNull();
    expect(isLaunchpadIntentId('generate')).toBe(true);
    expect(isLaunchpadIntentId('')).toBe(false);
  });
});