Files
mail-tools/tests/components/workbench.test.tsx
T
2026-09-01 12:39:23 +02:00

38 lines
1.6 KiB
TypeScript

import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { describe, expect, it } from "vitest";
import { Workbench } from "../../src/components/Workbench";
describe("Mail workbench", () => {
it("shows parsed structure and retains it after an invalid edit", async () => {
const user = userEvent.setup();
render(<Workbench />);
expect(
screen.getByRole("heading", { name: "Mail Tools" }),
).toBeInTheDocument();
expect(screen.getByText(/Parsed 5 MIME parts/iu)).toBeInTheDocument();
await user.clear(screen.getByLabelText("EML source"));
await user.type(screen.getByLabelText("EML source"), "bad header");
await user.click(screen.getByRole("button", { name: "Inspect message" }));
expect(screen.getByRole("alert")).toHaveTextContent(/last successful/iu);
expect(
screen.getAllByText("multipart/mixed", { exact: false }),
).not.toHaveLength(0);
});
it("moves through body, attachment and diagnostic views", async () => {
const user = userEvent.setup();
render(<Workbench />);
await user.click(screen.getByRole("button", { name: "Bodies" }));
expect(
screen.getByRole("heading", { name: "Body-part comparison" }),
).toBeInTheDocument();
await user.click(screen.getByRole("button", { name: "Attachments" }));
expect(screen.getByText("notes.txt", { exact: true })).toBeInTheDocument();
await user.click(screen.getByRole("button", { name: "Diagnostics" }));
expect(
screen.getByText(/Authentication-Results claims/iu),
).toBeInTheDocument();
});
});