Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(search): Add new Feedback component fields to search index #4015

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
mockConfirmationResult,
mockContentResult,
mockDrawBoundaryResult,
mockFeedbackResult,
mockFileUploadAndLabelResult,
mockFindPropertyResult,
mockFlow,
Expand Down Expand Up @@ -784,3 +785,49 @@ describe("result fields", () => {
});
});
});

describe("feedback fields", () => {
it("renders data.ratingQuestion", () => {
const output = getDisplayDetailsForResult(mockFeedbackResult);

expect(output).toStrictEqual<Output>({
key: "Rating question",
iconKey: ComponentType.Feedback,
componentType: "Feedback",
title: "title text",
headline: "Bullfrog",
});
});

it("renders data.freeformQuestion", () => {
const output = getDisplayDetailsForResult({
...mockFeedbackResult,
key: "data.freeformQuestion",
matchValue: "Oarfish",
});

expect(output).toStrictEqual<Output>({
key: "Freeform question",
iconKey: ComponentType.Feedback,
componentType: "Feedback",
title: "title text",
headline: "Oarfish",
});
});

it("renders data.disclaimer", () => {
const output = getDisplayDetailsForResult({
...mockFeedbackResult,
key: "data.disclaimer",
matchValue: "Wagtail",
});

expect(output).toStrictEqual<Output>({
key: "Disclaimer",
iconKey: ComponentType.Feedback,
componentType: "Feedback",
title: "title text",
headline: "Wagtail",
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ const keyFormatters: KeyMap = {
"data.schema.fields.data.options.data.val": {
getDisplayKey: () => "Option (data)",
},
"data.ratingQuestion": {
getDisplayKey: () => "Rating question",
},
"data.freeformQuestion": {
getDisplayKey: () => "Freeform question",
},
};

const componentFormatters: ComponentMap = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ const pay: SearchFacets = [
"data.govPayMetadata.value",
];

const feedback: SearchFacets = [
richTextField("data.ratingQuestion"),
richTextField("data.freeformQuestion"),
richTextField("data.disclaimer"),
];

export const ALL_FACETS: SearchFacets = [
...basicFields,
...moreInformation,
Expand All @@ -166,5 +172,6 @@ export const ALL_FACETS: SearchFacets = [
...drawBoundary,
...planningConstraints,
...pay,
...feedback,
...DATA_FACETS,
];
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const mockFlow: FlowGraph = {
"9jiJvRYka6",
"G6L9c8Sllg",
"gyyVEMm9Yb",
"ZVZx9UDPqb",
],
},
"6rgnMh94zu": {
Expand Down Expand Up @@ -274,6 +275,17 @@ export const mockFlow: FlowGraph = {
},
type: 9,
},
ZVZx9UDPqb: {
data: {
title: "title text",
disclaimer: "<p>Oarfish</p>",
description: "<p>description text</p>",
ratingQuestion: "<p><strong>Bullfrog</strong></p>",
feedbackRequired: false,
freeformQuestion: "<p><strong>Wagtail</strong></p>",
},
type: 900,
},
};

export const mockQuestionResult: SearchResult<IndexedNode> = {
Expand Down Expand Up @@ -649,3 +661,23 @@ export const mockResultResult: SearchResult<IndexedNode> = {
refIndex: 0,
matchValue: "Squid",
};

export const mockFeedbackResult: SearchResult<IndexedNode> = {
item: {
id: "ZVZx9UDPqb",
parentId: "_root",
type: 900,
data: {
title: "title text",
disclaimer: "<p>Oarfish</p>",
description: "<p>description text</p>",
ratingQuestion: "<p><strong>Bullfrog</strong></p>",
feedbackRequired: false,
freeformQuestion: "<p><strong>Wagtail</strong></p>",
},
},
key: "data.ratingQuestion",
matchIndices: [[0, 7]],
matchValue: "Bullfrog",
refIndex: 0,
};
Loading