Keep a typed main kind from being ranked as the catalog other kind, and store that catalog kind on the finished Rule.

This commit is contained in:
adilallo committed 2026-11-23 11:07:50 -07:00
1 parent 4b90bce006
commit 3e0181e4de
7 files changed
+174 -48

No files matched your search

+38
View File
@@ -1,5 +1,11 @@
import { describe, it, expect } from "vitest";
import { buildFacetQueryString } from "../../lib/create/buildFacetQueryString";
import { TYPED_ORG_TYPE_MARKER } from "../../lib/create/deckTypes";
import {
groupAnswersFromCreateFlowState,
groupAnswersFromRequestedFacets,
} from "../../lib/create/groupAnswers";
import { parseRequestedFacetsFromSearchParams } from "../../lib/server/validation/methodFacetsSchemas";
describe("buildFacetQueryString", () => {
it("maps community chip ids to facet.* query params", () => {
@@ -19,4 +25,36 @@ describe("buildFacetQueryString", () => {
it("returns empty string when no selections", () => {
expect(buildFacetQueryString({})).toBe("");
});
it("keeps a catalog other kind from becoming the main kind when the main kind was typed", () => {
const state = {
selectedCommunitySizeIds: ["sixToTwelve"],
selectedOrganizationTypeIds: ["custom-tenants-union", "workersCoop"],
};
const params = new URLSearchParams(buildFacetQueryString(state));
expect(params.getAll("facet.orgType")).toEqual([
TYPED_ORG_TYPE_MARKER,
"workersCoop",
]);
const fromState = groupAnswersFromCreateFlowState(state);
const fromQuery = groupAnswersFromRequestedFacets(
parseRequestedFacetsFromSearchParams(params),
);
expect(fromQuery.mainKind).toBeNull();
expect(fromQuery.otherKinds).toEqual(["workersCoop"]);
expect(fromQuery.mainKind).toBe(fromState.mainKind);
expect(fromQuery.otherKinds).toEqual(fromState.otherKinds);
});
it("does not mark a catalog main kind", () => {
const params = new URLSearchParams(
buildFacetQueryString({
selectedOrganizationTypeIds: ["workersCoop", "nonprofit"],
}),
);
expect(params.getAll("facet.orgType")).toEqual([
"workersCoop",
"nonprofit",
]);
});
});