Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

1.3 KB
Raw Blame
import { render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { IngestStepConfig } from "@processor/components/pipelines/IngestStepConfig";

vi.mock("react-i18next", () => ({
  useTranslation: () => ({ t: (key: string) => key }),
}));
vi.mock("@editor/contexts/AppConfigContext", () => ({
  useAppConfig: () => ({ config: { aiEngineEnabled: true }, loading: false }),
}));

describe("ingestion overlap validation", () => {
  it("marks an excessive overlap invalid and clears the error when corrected", () => {
    const { rerender } = render(
      <IngestStepConfig
        parameters={{ chunkSize: 64, overlap: 64 }}
        onChange={vi.fn()}
      />,
    );
    const input = screen.getByLabelText(
      "portal.pipelines.builder.ingest.overlap",
    );
    expect(input).toHaveAttribute("aria-invalid", "true");
    expect(
      screen.getByText("portal.pipelines.builder.ingest.overlapTooBig"),
    ).toBeInTheDocument();
    rerender(
      <IngestStepConfig
        parameters={{ chunkSize: 64, overlap: 16 }}
        onChange={vi.fn()}
      />,
    );
    expect(input).not.toHaveAttribute("aria-invalid", "true");
    expect(
      screen.queryByText("portal.pipelines.builder.ingest.overlapTooBig"),
    ).not.toBeInTheDocument();
  });
});