Skip to content

Commit

Permalink
add test for rejected comment stream link state on dsa reports
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-funk committed Nov 27, 2023
1 parent 50a2068 commit 4531f5f
Showing 1 changed file with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import userEvent from "@testing-library/user-event";

import { pureMerge } from "coral-common/common/lib/utils";
import {
GQLCOMMENT_STATUS,
GQLDSAReportDecisionLegality,
GQLDSAReportHistoryType,
GQLDSAReportStatus,
Expand All @@ -25,7 +26,8 @@ beforeEach(async () => {
});

const createTestRenderer = async (
params: CreateTestRendererParams<GQLResolver> = {}
params: CreateTestRendererParams<GQLResolver> = {},
commentStatus?: GQLCOMMENT_STATUS
) => {
const { context } = createContext({
...params,
Expand All @@ -34,7 +36,17 @@ const createTestRenderer = async (
Query: {
settings: () => settings,
viewer: () => adminViewer,
dsaReport: () => dsaReports[0],
dsaReport: () => {
return {
...dsaReports[0],
comment: commentStatus
? {
...dsaReports[0].comment,
status: commentStatus,
}
: dsaReports[0].comment,
};
},
},
Mutation: {
addDSAReportNote: ({ variables }) => {
Expand Down Expand Up @@ -251,3 +263,20 @@ it("can make a legality decision on a report", async () => {
)
);
});

it("stream link is unavailable when comment is already rejected", async () => {
const { container } = await createTestRenderer(
undefined,
GQLCOMMENT_STATUS.REJECTED
);

expect(await within(container).findByText("Rejected"));
expect(await within(container).findByText("Unavailable in stream"));

expect(
within(container).getByRole("link", { name: "View comment in moderation" })
).toHaveProperty(
"href",
"http://localhost/admin/moderate/comment/comment-regular-0"
);
});

0 comments on commit 4531f5f

Please sign in to comment.