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 { describe, expect, it } from 'vitest';

import { getCreateFromBboxNotice } from './createFromBboxNotice';

describe('getCreateFromBboxNotice', () => {
  it.each([
    ['raster', 'widgets.canvas.import.raster'],
    ['control', 'widgets.canvas.import.control'],
    ['regional-reference', 'widgets.canvas.import.regionalReference'],
  ] as const)('labels a created %s destination with its import label key', (destination, labelKey) => {
    expect(getCreateFromBboxNotice({ destination, layerIds: ['layer-1'], status: 'created' })).toEqual({
      kind: 'success',
      options: { destination: labelKey },
      titleKey: 'widgets.canvas.contextMenu.createdFromBbox',
    });
  });

  it.each([
    ['empty', 'info', 'widgets.canvas.contextMenu.empty'],
    ['stale', 'info', 'widgets.canvas.contextMenu.stale'],
    ['not-ready', 'info', 'widgets.canvas.contextMenu.notReady'],
    ['over-budget', 'info', 'widgets.canvas.contextMenu.notReady'],
    ['blocked', 'info', 'widgets.canvas.import.blocked'],
    ['stale-document', 'error', 'widgets.canvas.import.staleDocument'],
    ['stale-project', 'error', 'widgets.canvas.import.staleProject'],
  ] as const)('maps %s to a %s notice', (status, kind, titleKey) => {
    expect(getCreateFromBboxNotice({ status })).toEqual({ kind, titleKey });
  });

  it('names the layer that could not be read', () => {
    expect(getCreateFromBboxNotice({ layerId: 'layer-7', layerName: 'Sky', status: 'unreadable' })).toEqual({
      kind: 'error',
      options: { name: 'Sky' },
      titleKey: 'widgets.canvas.contextMenu.unreadable',
    });
  });

  it('passes an adjustment refusal on as an error for the view to word', () => {
    const refusal = { ownerId: 'g', ownerName: 'Sky', reason: 'too-large', status: 'adjustment-refused' } as const;
    expect(getCreateFromBboxNotice(refusal)).toEqual({ kind: 'error', refusal });
  });
});