(
null
);
+ const { data: existingTags } = useGetTagsQuery();
+ const existingTagNames =
+ existingTags != null ? new Set(existingTags.map((tag) => tag.name)) : null;
+ const visibleReasons = NO_MATCH_REASONS.filter(
+ (reason) => existingTagNames == null || existingTagNames.has(reason.tagName)
+ );
const choose = (tagName: string) => {
setSubmittingTagName(tagName);
@@ -83,7 +98,7 @@ export function NoMatchReasonStrip({
Why no match?
- {NO_MATCH_REASONS.map((reason) => (
+ {visibleReasons.map((reason) => (
HttpResponse.json({ tags: ["Tag 1", "Tag 2"] }, { status: 200 })
);
+const serialisedTag = (name: string) => ({
+ name,
+ aliases: [],
+ isEnabledByDefault: true,
+ parent: null,
+ children: [],
+});
+
+// all six no-match reason tags exist server-side - NoMatchReasonStrip shows every chip
+export const tagsAllNoMatchReasonTags = http.get(buildRoute("2/tags/"), () =>
+ HttpResponse.json(
+ {
+ tags: [
+ "custom-art",
+ "altered-frame",
+ "upscaled",
+ "ai-art",
+ "no-collector-line",
+ "non-english",
+ ].map(serialisedTag),
+ },
+ { status: 200 }
+ )
+);
+
+// only two of the six reason tags exist server-side (seed_no_match_reason_tags hasn't fully
+// run, or ran on an older version of the taxonomy) - NoMatchReasonStrip should hide the rest
+export const tagsSomeNoMatchReasonTags = http.get(buildRoute("2/tags/"), () =>
+ HttpResponse.json(
+ { tags: ["custom-art", "ai-art"].map(serialisedTag) },
+ { status: 200 }
+ )
+);
+
//# endregion
//# region sample cards
diff --git a/frontend/tests/NoMatchReasonStrip.spec.ts b/frontend/tests/NoMatchReasonStrip.spec.ts
index 5033f4c91..0be57838e 100644
--- a/frontend/tests/NoMatchReasonStrip.spec.ts
+++ b/frontend/tests/NoMatchReasonStrip.spec.ts
@@ -7,6 +7,8 @@ import {
printingTagQueueOneResult,
submitPrintingTagNoMatch,
submitTagVoteResolvesToApply,
+ tagsAllNoMatchReasonTags,
+ tagsSomeNoMatchReasonTags,
} from "@/mocks/handlers";
import { test } from "../playwright.setup";
@@ -22,6 +24,7 @@ test.describe("NoMatchReasonStrip tests", () => {
printingCandidatesTwoResults,
printingConsensusUnresolved,
submitPrintingTagNoMatch,
+ tagsAllNoMatchReasonTags,
...defaultHandlers
);
await loadPageWithDefaultBackend(page, "printingQueue");
@@ -39,6 +42,32 @@ test.describe("NoMatchReasonStrip tests", () => {
await expect(page.getByTestId("attribute-voting-panel")).not.toBeVisible();
});
+ test("hides chips for reason tags that don't exist server-side yet", async ({
+ page,
+ network,
+ }) => {
+ network.use(
+ printingTagQueueOneResult,
+ printingCandidatesTwoResults,
+ printingConsensusUnresolved,
+ submitPrintingTagNoMatch,
+ tagsSomeNoMatchReasonTags, // only custom-art and ai-art exist
+ ...defaultHandlers
+ );
+ await loadPageWithDefaultBackend(page, "printingQueue");
+
+ await page.getByText("No match").click();
+
+ const strip = page.getByTestId("no-match-reason-strip");
+ await expect(strip).toBeVisible();
+ await expect(strip.getByText("Custom art")).toBeVisible();
+ await expect(strip.getByText("AI art")).toBeVisible();
+ await expect(strip.getByText("Altered frame")).not.toBeVisible();
+ await expect(strip.getByText("Upscaled")).not.toBeVisible();
+ await expect(strip.getByText("No collector line")).not.toBeVisible();
+ await expect(strip.getByText("Non-English")).not.toBeVisible();
+ });
+
test("tapping a reason chip submits a positive tag vote and advances the queue", async ({
page,
network,
@@ -50,6 +79,7 @@ test.describe("NoMatchReasonStrip tests", () => {
printingConsensusUnresolved,
submitPrintingTagNoMatch,
submitTagVoteResolvesToApply,
+ tagsAllNoMatchReasonTags,
...defaultHandlers
);
page.on("request", async (request) => {
@@ -79,6 +109,7 @@ test.describe("NoMatchReasonStrip tests", () => {
printingCandidatesTwoResults,
printingConsensusUnresolved,
submitPrintingTagNoMatch,
+ tagsAllNoMatchReasonTags,
...defaultHandlers
);
page.on("request", (request) => {