Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

1.4 KB
Raw Blame
import { describe, expect, it } from 'vitest';
import type { CaptureStateUpdate } from '@/core/capture/capture-state-update';
import { CaptureState } from '@/core/capture/machine';
import { shouldReopenBlur } from '../restore';

const state = (over: Partial<CaptureStateUpdate> = {}): CaptureStateUpdate => ({
  state: CaptureState.PAUSED,
  stepCount: 1,
  currentGuideId: 'guide-1',
  pauseReason: 'blur',
  ...over,
});

describe('shouldReopenBlur', () => {
  it('re-opens in the top frame of a recording paused for blur', () => {
    expect(shouldReopenBlur(state(), true)).toBe(true);
  });

  it('never re-opens in a subframe', () => {
    expect(shouldReopenBlur(state(), false)).toBe(false);
  });

  it('does not re-open for a manual pause, which has no overlay', () => {
    expect(shouldReopenBlur(state({ pauseReason: 'manual' }), true)).toBe(false);
  });

  it('does not re-open over a live recording', () => {
    expect(shouldReopenBlur(state({ state: CaptureState.RECORDING, pauseReason: null }), true)).toBe(false);
  });

  it('does not re-open when nothing is being recorded', () => {
    expect(shouldReopenBlur(state({ state: CaptureState.IDLE, currentGuideId: null, pauseReason: null }), true)).toBe(
      false,
    );
  });

  it('does not re-open when the reason is missing', () => {
    expect(shouldReopenBlur(state({ pauseReason: null }), true)).toBe(false);
  });
});