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

Release #498

Merged
merged 2 commits into from
Aug 15, 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
2 changes: 1 addition & 1 deletion components/page/FilterBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const FilterBar = ({ filterType, setLiveRegionMessage }) => {
/>
</Styled.FilterSearch>
)}
<Styled.Clear onClick={handleReset}>
<Styled.Clear onClick={handleReset} data-cy="clear">
<IconComposer icon="cancel" />
{t(`search-clear`)}
</Styled.Clear>
Expand Down
28 changes: 16 additions & 12 deletions components/templates/SearchPage/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import PropTypes from "prop-types";
import styled from "styled-components";
import { useTranslation } from "react-i18next";
import Body from "@/global/Body";
import Breadcrumbs from "@/components/page/Breadcrumbs";
import { Container } from "@rubin-epo/epo-react-lib";
import DynamicComponentFactory from "@/components/factories/DynamicComponentFactory";
import FilterBar from "@/components/page/FilterBar";
import { usePathData } from "@/lib/utils";
import { BREAK_PHABLET } from "@/styles/globalStyles";
import { FilterParamsProvider } from "@/contexts/FilterParams";

export default function SearchPage({
data: { description, dynamicComponent, id, title, uri },
}) {
const { t } = useTranslation();
const bodyProps = {
description,
title,
Expand All @@ -30,17 +29,22 @@ export default function SearchPage({
return (
<Body {...bodyProps}>
<Breadcrumbs breadcrumbs={[pageLink]} />
<FilterBar filterType={dynamicComponent} />
<Container bgColor="white" className="c-page-header">
<Title>
<h1>{title}</h1>
{keyphrase && <h1>&quot;{keyphrase}&quot;</h1>}
</Title>
</Container>
<FilterParamsProvider>
<FilterBar filterType={dynamicComponent} />
<Container bgColor="white" className="c-page-header">
<Title>
<h1>{title}</h1>
{keyphrase && <h1>&quot;{keyphrase}&quot;</h1>}
</Title>
</Container>

{dynamicComponent && (
<DynamicComponentFactory componentType={dynamicComponent} pageId={id} />
)}
{dynamicComponent && (
<DynamicComponentFactory
componentType={dynamicComponent}
pageId={id}
/>
)}
</FilterParamsProvider>
</Body>
);
}
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/filtering.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe("Filtering dynamic data", () => {
// so we must tell it to visit our website with the `cy.visit()` command.
// Since we want to visit the same URL at the start of all our tests,
// we include it in our beforeEach function so that it runs before each test
cy.visit("/calendar");
cy.visit("/news");
});

it("Should show all filtered items", () => {
Expand All @@ -21,7 +21,7 @@ describe("Filtering dynamic data", () => {
});
it("Should show selected filter", () => {
const dropdownId = "filter-dropdown";
const filter = "Education Event";
const filter = "News Post";

cy.get(`[aria-controls="${dropdownId}"]`).click();
cy.get(`[id="${dropdownId}"]`).should("be.visible");
Expand Down
30 changes: 30 additions & 0 deletions cypress/e2e/search.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
describe("Search page", () => {
beforeEach(() => {
// Cypress starts out with a blank slate for each test
// so we must tell it to visit our website with the `cy.visit()` command.
// Since we want to visit the same URL at the start of all our tests,
// we include it in our beforeEach function so that it runs before each test
cy.visit("/search");
});

it("Searching from filter input yields results", () => {
cy.get("#filterSearchInput").type("press release{enter}");
cy.intercept("http://localhost:3000/search?search=press+release").as(
"search"
);
cy.on("url:changed", (newUrl) => {
expect(newUrl).to.contain("?search=press+release");
});
cy.get("ul li").its("length").should("be.gte", 1);
});
it("Clear button resets search", () => {
cy.get("[data-cy='clear']").click();
cy.intercept("http://localhost:3000/search?search=press+release").as(
"search"
);
cy.on("url:changed", (newUrl) => {
cy.get("#filterSearchInput").should("have.value", "");
expect(newUrl).to.be("http://localhost:3000/search");
});
});
});
2 changes: 2 additions & 0 deletions pages/[[...uriSegments]].js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export async function getStaticProps({ params: { uriSegments }, previewData }) {
await purgeNextjsStaticFiles(uriSegments);
return {
notFound: true,
revalidate: 10,
};
}

Expand Down Expand Up @@ -197,6 +198,7 @@ export async function getStaticProps({ params: { uriSegments }, previewData }) {
await purgeNextjsStaticFiles(uriSegments);
return {
notFound: true,
revalidate: 10,
};
}
setEdcLog(runId, "Done building for " + uri, "BUILD_COMPLETE");
Expand Down
Loading