Skip to content

Commit

Permalink
Merge pull request #45 from art-institute-of-chicago/feature/hide-reg…
Browse files Browse the repository at this point in the history
…enstein-artworks

Exclude artworks in Regenstein from My Museum Tour builder [WEB-2864]
  • Loading branch information
nikhiltri authored May 21, 2024
2 parents 1f095bd + 3c89658 commit f7aec5d
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 14 deletions.
31 changes: 17 additions & 14 deletions dist/MyMuseumTourBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ function T(s, a, r = "", n = "", d = "full", l = !0) {
function L(s, a) {
const r = new URL("https://api.artic.edu/api/v1/artworks/search");
if (r.searchParams.set(
"query[bool][must_not][][term][gallery_id][value]",
"2147475902"
), r.searchParams.set(
"query[bool][should][0][bool][must][][exists][field]",
"short_description"
), r.searchParams.set(
Expand Down Expand Up @@ -535,7 +538,7 @@ V.propTypes = {
t.object
]).isRequired
};
const M = H();
const q = H();
function W(s) {
const {
children: a,
Expand All @@ -552,7 +555,7 @@ function W(s) {
c || null
), k = C();
return /* @__PURE__ */ e.createElement(
M.Provider,
q.Provider,
{
value: {
searchResultItems: u,
Expand Down Expand Up @@ -581,7 +584,7 @@ W.propTypes = {
searchError: t.oneOfType([t.string, t.bool]),
searchPreviewId: t.number
};
M.Provider.propTypes = {
q.Provider.propTypes = {
value: t.shape({
searchResultItems: t.array,
setSearchResultItems: t.func,
Expand Down Expand Up @@ -638,7 +641,7 @@ function J(s) {
setSearchFetching: d,
setSearchError: l,
setActiveTheme: c
} = S(M), [u, m] = E(!0), { fetchData: o } = G({
} = S(q), [u, m] = E(!0), { fetchData: o } = G({
dataSubSelector: "data",
dataSetter: n,
fetchingSetter: d,
Expand Down Expand Up @@ -711,7 +714,7 @@ function K(s) {
setSearchQuery: p,
activeTheme: i,
setActiveTheme: h
} = S(M), { fetchData: g } = G({
} = S(q), { fetchData: g } = G({
dataSubSelector: "data",
dataSetter: u,
fetchingSetter: m,
Expand Down Expand Up @@ -835,7 +838,7 @@ X.propTypes = {
hideFromTours: t.array
};
function Z(s) {
const { setSearchPreviewId: a, searchPreviewRef: r } = S(M), { iiifBaseUrl: n, setScrollY: d, tourItems: l } = S(P), { itemData: c } = s, u = l.some((h) => h.id === c.id), m = C(null), o = C(), p = () => {
const { setSearchPreviewId: a, searchPreviewRef: r } = S(q), { iiifBaseUrl: n, setScrollY: d, tourItems: l } = S(P), { itemData: c } = s, u = l.some((h) => h.id === c.id), m = C(null), o = C(), p = () => {
const h = document.documentElement.scrollTop;
F(document, "gtm:push", {
event: "mmt_artwork_modal",
Expand Down Expand Up @@ -945,7 +948,7 @@ Z.propTypes = {
})
};
function Te() {
const { searchPreviewId: s, searchResultItems: a, searchPreviewRef: r } = S(M), { iiifBaseUrl: n, tourItems: d, tourItemsDispatch: l, limits: c } = S(P), [u, m] = E(!1), [o, p] = E(null), i = O({
const { searchPreviewId: s, searchResultItems: a, searchPreviewRef: r } = S(q), { iiifBaseUrl: n, tourItems: d, tourItemsDispatch: l, limits: c } = S(P), [u, m] = E(!1), [o, p] = E(null), i = O({
"aic-ct-preview__content": !0,
"aic-ct-preview--loading": !o,
"aic-ct-preview__content-warning": d.length >= 6
Expand Down Expand Up @@ -1044,7 +1047,7 @@ function Pe() {
setSearchPreviewId: d,
activeTheme: l,
searchQuery: c
} = S(M), { scrollY: u } = S(P), m = C(null), o = B(
} = S(q), { scrollY: u } = S(P), m = C(null), o = B(
(i) => {
var h;
(i.type === "close" || (h = n == null ? void 0 : n.current) != null && h.open && i.target === (n == null ? void 0 : n.current)) && (n.current.close(), d(null), document.documentElement.scrollTop = u, document.documentElement.classList.remove(
Expand Down Expand Up @@ -1119,7 +1122,7 @@ function Pe() {
/* @__PURE__ */ e.createElement(Te, null)
))), /* @__PURE__ */ e.createElement("p", { className: "u-hide", id: "aic-ct-search__in-your-tour" }, "This object is in your tour", " "), /* @__PURE__ */ e.createElement("p", { className: "sr-only", "aria-live": "polite" }, a ? "Loading" : l ? `Showing results for ${l}` : c ? `Showing results for ${c}` : "Showing default results"));
}
function q(s = {}) {
function M(s = {}) {
const { initialValue: a, maxLength: r, valueSetter: n } = s, [d, l] = E(a || ""), c = C(null), u = r - d.length;
return {
value: d,
Expand All @@ -1143,7 +1146,7 @@ function ee(s) {
event: "mmt_artwork_note",
fieldPopulated: p.current
}));
}, h = q({
}, h = M({
initialValue: (b = c[r]) == null ? void 0 : b.objectNote,
maxLength: m.objectNote,
valueSetter: i
Expand Down Expand Up @@ -1359,19 +1362,19 @@ function Ce() {
event: "mmt_email_optin",
optInStatus: N
}), i(N);
}, I = q({
}, I = M({
initialValue: s,
maxLength: f.title,
valueSetter: a
}), R = q({
}), R = M({
initialValue: c,
maxLength: f.creatorName,
valueSetter: v
}), D = q({
}), D = M({
initialValue: m,
maxLength: f.recipientName,
valueSetter: _
}), x = q({
}), x = M({
initialValue: h,
maxLength: f.description,
valueSetter: k
Expand Down
24 changes: 24 additions & 0 deletions src/components/search/SearchBar.cy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,28 @@ describe("<SearchBar />", () => {
"&query%5Bbool%5D%5Bmust_not%5D%5B%5D%5Bterm%5D%5Bid%5D%5Bvalue%5D%3D111111",
);
});

it("Hides Regenstein artwork from search", () => {
cy.intercept("GET", "https://api.artic.edu/api/v1/artworks/search*", {
fixture: "json/search.json",
delayMs: 80,
}).as("search");

cy.mount(
<AppProvider>
<SearchProvider>
<SearchBar />
</SearchProvider>
</AppProvider>,
);
cy.get("#aic-ct-search__input").type("test");
cy.get("#aic-ct-search__button").click();
cy.get("@search").its("request.url").should("include", "q=test");
cy.get("@search")
.its("request.url")
.should(
"include",
"query%5Bbool%5D%5Bmust_not%5D%5B%5D%5Bterm%5D%5Bgallery_id%5D%5Bvalue%5D=2147475902",
);
});
});
26 changes: 26 additions & 0 deletions src/components/search/ThemesToggle.cy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,30 @@ describe("<Themes />", () => {
"&query%5Bbool%5D%5Bmust_not%5D%5B%5D%5Bterm%5D%5Bid%5D%5Bvalue%5D%3D111111",
);
});

it("Requests the correct URL with hiding Regenstein artworks", () => {
cy.intercept("GET", "https://api.artic.edu/api/v1/artworks/search*", {
fixture: "json/search.json",
delayMs: 80,
}).as("search");

cy.mount(
<AppProvider>
<SearchProvider>
<ThemeToggle
id="0"
label="Test theme"
searchParams={{ category_ids: ["PC-154"] }}
/>
</SearchProvider>
</AppProvider>,
);
cy.get("#aic-ct-theme-toggle-0").click();
cy.get("@search")
.its("request.url")
.should(
"include",
"query%5Bbool%5D%5Bmust_not%5D%5B%5D%5Bterm%5D%5Bgallery_id%5D%5Bvalue%5D=2147475902",
);
});
});
4 changes: 4 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export function createSearchUrl(queryParams, hideFromTours) {
// Build the query string
// I've broken this up to make it easer to reason about and manipulate
const url = new URL("https://api.artic.edu/api/v1/artworks/search");
url.searchParams.set(
"query[bool][must_not][][term][gallery_id][value]",
"2147475902",
);
url.searchParams.set(
"query[bool][should][0][bool][must][][exists][field]",
"short_description",
Expand Down

0 comments on commit f7aec5d

Please sign in to comment.