mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
* feat(shared): add outputModality to Tool metadata for crossing tools * feat(shared): add modalityForExtension, toolInputModality, toolOutputModality * fix(pipeline): route finalize and parent jobs to the pipeline's modality pool * feat(automate): add ConvertAudioControls pipeline step (exemplar) * feat(automate): add video tool settings controls to pipelines * feat(automate): add audio tool settings controls to pipelines * feat(automate): add document tool settings controls to pipelines * feat(automate): add chart-maker settings control to pipelines * feat(automate): warn on modality-incompatible pipeline steps * feat(automate): add single-file download button for pipeline results * refactor(automate): modality-aware icons, nav handler rename, mobile size bar * test(pipeline): cover audio, document, file, and cross-modality chains * i18n(automate): translate the modality-warning tooltip * test(pipeline): gate media-pool routing assertion on ffmpeg availability
131 lines
4.6 KiB
TypeScript
131 lines
4.6 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { cleanup, render, screen } from "@testing-library/react";
|
|
import userEvent from "@testing-library/user-event";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { ConvertAudioControls } from "@/components/tools/convert-audio-settings";
|
|
|
|
afterEach(() => {
|
|
cleanup();
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
describe("ConvertAudioControls", () => {
|
|
it("emits valid defaults on mount", () => {
|
|
const onChange = vi.fn();
|
|
render(<ConvertAudioControls onChange={onChange} />);
|
|
expect(onChange).toHaveBeenCalledWith(
|
|
expect.objectContaining({ format: "mp3", bitrateKbps: 192 }),
|
|
);
|
|
});
|
|
|
|
it("emits the chosen format on change", async () => {
|
|
const onChange = vi.fn();
|
|
render(<ConvertAudioControls onChange={onChange} />);
|
|
await userEvent.selectOptions(screen.getByLabelText(/output format/i), "flac");
|
|
expect(onChange).toHaveBeenLastCalledWith(expect.objectContaining({ format: "flac" }));
|
|
});
|
|
|
|
it("emits the chosen bitrate on change", async () => {
|
|
const onChange = vi.fn();
|
|
render(<ConvertAudioControls onChange={onChange} />);
|
|
await userEvent.selectOptions(screen.getByLabelText(/bitrate/i), "320");
|
|
expect(onChange).toHaveBeenLastCalledWith(expect.objectContaining({ bitrateKbps: 320 }));
|
|
});
|
|
|
|
it("initializes from incoming settings once", () => {
|
|
const onChange = vi.fn();
|
|
render(
|
|
<ConvertAudioControls settings={{ format: "wav", bitrateKbps: 256 }} onChange={onChange} />,
|
|
);
|
|
expect(onChange).toHaveBeenCalledWith(
|
|
expect.objectContaining({ format: "wav", bitrateKbps: 256 }),
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("TrimVideoControls", async () => {
|
|
const { TrimVideoControls } = await import("@/components/tools/trim-video-settings");
|
|
|
|
it("emits valid defaults on mount", () => {
|
|
const onChange = vi.fn();
|
|
render(<TrimVideoControls onChange={onChange} />);
|
|
expect(onChange).toHaveBeenCalledWith(
|
|
expect.objectContaining({ startS: 0, endS: 0, precise: false }),
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("RotateVideoControls", async () => {
|
|
const { RotateVideoControls } = await import("@/components/tools/rotate-video-settings");
|
|
|
|
it("emits valid defaults on mount", () => {
|
|
const onChange = vi.fn();
|
|
render(<RotateVideoControls onChange={onChange} />);
|
|
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ transform: "cw90" }));
|
|
});
|
|
});
|
|
|
|
describe("AudioChannelsControls", async () => {
|
|
const { AudioChannelsControls } = await import("@/components/tools/audio-channels-settings");
|
|
|
|
it("emits valid defaults on mount", () => {
|
|
const onChange = vi.fn();
|
|
render(<AudioChannelsControls onChange={onChange} />);
|
|
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ mode: "stereo-to-mono" }));
|
|
});
|
|
});
|
|
|
|
describe("RotatePdfControls", async () => {
|
|
const { RotatePdfControls } = await import("@/components/tools/rotate-pdf-settings");
|
|
|
|
it("emits valid defaults on mount", () => {
|
|
const onChange = vi.fn();
|
|
render(<RotatePdfControls onChange={onChange} />);
|
|
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ angle: 90, range: "1-z" }));
|
|
});
|
|
});
|
|
|
|
describe("RedactPdfControls", async () => {
|
|
const { RedactPdfControls } = await import("@/components/tools/redact-pdf-settings");
|
|
|
|
it("emits empty terms array on mount", () => {
|
|
const onChange = vi.fn();
|
|
render(<RedactPdfControls onChange={onChange} />);
|
|
expect(onChange).toHaveBeenCalledWith(
|
|
expect.objectContaining({ terms: [], caseSensitive: false }),
|
|
);
|
|
});
|
|
|
|
it("splits comma-separated input into terms array", async () => {
|
|
const onChange = vi.fn();
|
|
render(<RedactPdfControls onChange={onChange} />);
|
|
const input = screen.getByRole("textbox");
|
|
await userEvent.type(input, "foo, bar, baz");
|
|
const lastCall = onChange.mock.calls[onChange.mock.calls.length - 1][0];
|
|
expect(lastCall.terms).toEqual(["foo", "bar", "baz"]);
|
|
});
|
|
});
|
|
|
|
describe("NupPdfControls", async () => {
|
|
const { NupPdfControls } = await import("@/components/tools/nup-pdf-settings");
|
|
|
|
it("emits perSheet as a number on mount", () => {
|
|
const onChange = vi.fn();
|
|
render(<NupPdfControls onChange={onChange} />);
|
|
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ perSheet: 2 }));
|
|
});
|
|
});
|
|
|
|
describe("ChartMakerControls", async () => {
|
|
const { ChartMakerControls } = await import("@/components/tools/chart-maker-settings");
|
|
|
|
it("emits valid defaults on mount", () => {
|
|
const onChange = vi.fn();
|
|
render(<ChartMakerControls onChange={onChange} />);
|
|
expect(onChange).toHaveBeenCalledWith(
|
|
expect.objectContaining({ kind: "bar", width: 960, height: 540 }),
|
|
);
|
|
});
|
|
});
|