import { screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { SlideOverCommentsTab } from "@/app/(protected)/workorders/_components/detail/tabs/slide-over-comments-tab";
import { SlideOverExtrasTab } from "@/app/(protected)/workorders/_components/detail/tabs/slide-over-extras-tab";
import {
canMutateWorkOrderComments,
canMutateWorkOrderExtraDocs,
} from "@/domain/work-orders/utils/work-order-lock";
import { renderWithProviders } from "@/test/test-utils";
describe("Completed comments and extra docs remain writable", () => {
it("shows the comment composer when status is Completed", () => {
renderWithProviders(
,
{ withAuth: false },
);
expect(screen.getByPlaceholderText("Add comment…")).toBeInTheDocument();
expect(screen.getByRole("button", { name: /post/i })).toBeInTheDocument();
});
it("keeps edit on the author's own comment when status is Completed", () => {
renderWithProviders(
,
{ withAuth: false },
);
expect(screen.getByRole("button", { name: /edit comment/i })).toBeInTheDocument();
});
it("hides the comment composer when status is Canceled", () => {
renderWithProviders(
,
{ withAuth: false },
);
expect(screen.queryByPlaceholderText("Add comment…")).not.toBeInTheDocument();
});
it("shows extra-docs upload when status is Completed", () => {
renderWithProviders(
,
{ withAuth: false },
);
expect(screen.getByText(/upload documents/i)).toBeInTheDocument();
});
it("hides extra-docs upload when status is Canceled", () => {
renderWithProviders(
,
{ withAuth: false },
);
expect(screen.queryByText(/upload documents/i)).not.toBeInTheDocument();
});
});