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.8 KB
Raw Blame
import { getLayoutPresetCommandTitleOverrides } from '@workbench/layoutPresetSnapshots';
import { createInitialWorkbenchState } from '@workbench/workbenchState';
import { describe, expect, it } from 'vitest';

import { firstPartyHotkeyCatalog } from './catalog';
import {
  FIRST_PARTY_APP_COMMAND_IDS,
  FIRST_PARTY_COMMAND_IDS,
  FIRST_PARTY_IMAGE_RECALL_COMMAND_IDS,
} from './firstPartyCommands';

const centrallyOwnedCommandIds = new Set(FIRST_PARTY_COMMAND_IDS);

describe('first-party hotkey commands', () => {
  it('uses the account names for built-in layout commands', () => {
    const initial = createInitialWorkbenchState();
    const account = {
      ...initial.account,
      layoutPresetMetadataOverrides: { compose: { label: 'Writing' } },
    };

    expect(getLayoutPresetCommandTitleOverrides(account, (name) => `${name} layout`)).toEqual({
      'app.selectComposePreset': 'Writing layout',
    });
  });

  it('registers handlers for every app and shared image recall command', () => {
    const sharedImageRecallCommands = new Set([
      'gallery.remix',
      'viewer.loadWorkflow',
      'viewer.recallAll',
      'viewer.recallPrompts',
      'viewer.recallSeed',
      'viewer.remix',
      'viewer.useSize',
    ]);
    const expectedCentralCommands = new Set(
      firstPartyHotkeyCatalog
        .filter((hotkey) => hotkey.category === 'app' || sharedImageRecallCommands.has(hotkey.commandId))
        .map((hotkey) => hotkey.commandId)
    );

    expect(centrallyOwnedCommandIds).toEqual(expectedCentralCommands);
    expect(new Set(FIRST_PARTY_COMMAND_IDS).size).toBe(FIRST_PARTY_COMMAND_IDS.length);
    expect(new Set(FIRST_PARTY_APP_COMMAND_IDS).size).toBe(FIRST_PARTY_APP_COMMAND_IDS.length);
    expect(new Set(FIRST_PARTY_IMAGE_RECALL_COMMAND_IDS).size).toBe(FIRST_PARTY_IMAGE_RECALL_COMMAND_IDS.length);
  });
});