From 003f1e0425a643123725b761837ba0758274006c Mon Sep 17 00:00:00 2001 From: Crystal Ngai <“hokei@users.noreply.github.com”> Date: Thu, 4 Mar 2021 11:40:56 -0500 Subject: [PATCH] Advanced Search styling and test fixes --- jest.config.js | 2 +- src/__tests__/helpers/browser | 40 ---- src/__tests__/helpers/routing | 37 ---- .../AdvancedSearch/AdvancedSearch.tsx | 100 +++++----- .../AdvancedSearch.test.tsx.snap | 188 +++++++++--------- src/components/EditionDetail/Edition.tsx | 1 - .../__snapshots__/FilterYears.test.tsx.snap | 164 ++++++++------- src/components/Work/Work.test.tsx | 8 +- src/util/EditionCardUtils.tsx | 16 +- styles/components/AdvancedSearch.scss | 90 ++++----- styles/components/Landing.scss | 2 +- styles/main.scss | 6 + 12 files changed, 296 insertions(+), 358 deletions(-) delete mode 100644 src/__tests__/helpers/browser delete mode 100644 src/__tests__/helpers/routing diff --git a/jest.config.js b/jest.config.js index a9fe30ef..b127f85d 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,7 +5,7 @@ module.exports = { moduleNameMapper: { "^~(.*)$": "$1", }, - testPathIgnorePatterns: ["/.next/", "/node_modules/"], + testPathIgnorePatterns: ["/.next/", "/node_modules/", "testUtils"], setupFilesAfterEnv: ["./setupTests.js"], snapshotSerializers: ["enzyme-to-json/serializer"], resetMocks: true, diff --git a/src/__tests__/helpers/browser b/src/__tests__/helpers/browser deleted file mode 100644 index 324c5d26..00000000 --- a/src/__tests__/helpers/browser +++ /dev/null @@ -1,40 +0,0 @@ -// require.extensions[".svg"] = () => {}; - -// require("@babel/register")(); - -// require.extensions[".svg"] = () => {}; - -// const jsdom = require("jsdom"); - -// const { JSDOM } = jsdom; - -// const virtualConsole = new jsdom.VirtualConsole(); -// const exposedProperties = ["window", "navigator", "document"]; - -// // @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'document'. -// const { document } = new JSDOM("", { -// url: "http://localhost", -// virtualConsole, -// }).window; -// virtualConsole.sendTo(console, { omitJSDOMErrors: true }); -// // @ts-expect-error ts-migrate(2339) FIXME: Property 'document' does not exist on type 'Global... Remove this comment to see the full error message -// global.document = document; -// // @ts-expect-error ts-migrate(2339) FIXME: Property 'window' does not exist on type 'Global'. -// global.window = document.defaultView; -// // @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call. -// Object.keys(document.defaultView).forEach((property) => { -// // @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message -// if (typeof global[property] === "undefined") { -// exposedProperties.push(property); -// // @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message -// global[property] = document.defaultView[property]; -// } -// }); - -// // @ts-expect-error ts-migrate(2339) FIXME: Property 'navigator' does not exist on type 'Globa... Remove this comment to see the full error message -// global.navigator = { -// userAgent: "node.js", -// }; - -// // @ts-expect-error ts-migrate(2304) FIXME: Cannot find name 'documentRef'. -// documentRef = document; diff --git a/src/__tests__/helpers/routing b/src/__tests__/helpers/routing deleted file mode 100644 index b43c5349..00000000 --- a/src/__tests__/helpers/routing +++ /dev/null @@ -1,37 +0,0 @@ -// // @ts-expect-error ts-migrate(2307) FIXME: Cannot find module 'sinon' or its corresponding ty... Remove this comment to see the full error message -// import { stub } from "sinon"; -// import PropTypes from "prop-types"; - -// const mockRouter = (push: any) => ({ -// push, -// createHref: stub(), -// replace: stub(), -// go: stub(), -// goBack: stub(), -// goForward: stub(), -// setRouteLeaveHook: stub(), -// isActive: stub(), -// location: { location: "default" }, -// }); - -// const mockRouterContext = (push: any) => ({ -// router: mockRouter(push || stub()), -// }); - -// mockRouter.propTypes = { -// push: PropTypes.func, -// createHref: PropTypes.func, -// replace: PropTypes.func, -// go: PropTypes.func, -// goBack: PropTypes.func, -// goForward: PropTypes.func, -// setRouteLeaveHook: PropTypes.func, -// isActive: PropTypes.func, -// location: PropTypes.objectOf(PropTypes.any), -// }; - -// mockRouterContext.propTyps = { -// router: PropTypes.func, -// }; - -// export { mockRouter, mockRouterContext }; diff --git a/src/components/AdvancedSearch/AdvancedSearch.tsx b/src/components/AdvancedSearch/AdvancedSearch.tsx index e7372ac1..3bffb281 100644 --- a/src/components/AdvancedSearch/AdvancedSearch.tsx +++ b/src/components/AdvancedSearch/AdvancedSearch.tsx @@ -128,25 +128,18 @@ const AdvancedSearch: React.FC<{ }; return ( -
-
+
+
-
-
-

Digital Research Books Beta

- -
- Search the world's research collections and more for digital - books you can use right now -
-
+
+ Advanced Search
{ submit(e); }} @@ -162,31 +155,31 @@ const AdvancedSearch: React.FC<{ )}
- Advanced Search - - {inputTerms.map((field: { key: string; label: string }) => { - return ( -
- - {field.label} - - onQueryChange(e, field.key)} - /> -
- ); - })} +
+ {inputTerms.map((field: { key: string; label: string }) => { + return ( +
+ + {field.label} + + onQueryChange(e, field.key)} + /> +
+ ); + })} +
{languages.length > 0 && ( - - Search - - clearSearch()} - > - Clear - +
+
+ + Search + + clearSearch()} + > + Clear + +
diff --git a/src/components/AdvancedSearch/__snapshots__/AdvancedSearch.test.tsx.snap b/src/components/AdvancedSearch/__snapshots__/AdvancedSearch.test.tsx.snap index 46304e4b..224f3b0b 100644 --- a/src/components/AdvancedSearch/__snapshots__/AdvancedSearch.test.tsx.snap +++ b/src/components/AdvancedSearch/__snapshots__/AdvancedSearch.test.tsx.snap @@ -78,11 +78,11 @@ Array [ exports[`renders advanced search correctly Renders correctly in when passed well-formed query 1`] = `
-
-

- Digital Research Books Beta -

-
- Search the world's research collections and more for digital books you can use right now -
-
+ Advanced Search +
- - Advanced Search -
- - -
-
- + +
+
- Author - - -
-
- + +
+
- Title - - -
-
- + +
+
- Subject - - + + +
- - + + +
diff --git a/src/components/EditionDetail/Edition.tsx b/src/components/EditionDetail/Edition.tsx index 0e250495..7be5a5ad 100644 --- a/src/components/EditionDetail/Edition.tsx +++ b/src/components/EditionDetail/Edition.tsx @@ -18,7 +18,6 @@ const Edition: React.FC<{ editionResult: EditionResult }> = (props) => { const edition: ApiEdition = props.editionResult.data; const featuredInstance = edition.instances[0]; - console.log("edition", edition); const toggleShowAll = (e: React.ChangeEvent) => { router.push({ diff --git a/src/components/FilterYears/__snapshots__/FilterYears.test.tsx.snap b/src/components/FilterYears/__snapshots__/FilterYears.test.tsx.snap index b614d1e8..50558ba3 100644 --- a/src/components/FilterYears/__snapshots__/FilterYears.test.tsx.snap +++ b/src/components/FilterYears/__snapshots__/FilterYears.test.tsx.snap @@ -1,46 +1,60 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Filter Years with apply button Renders Filter Years with Apply button 1`] = ` -
+
Publication Year - - - - EX. 1901 - - - - - EX. 2000 - +
+ + + + EX. 1901 + +
+
+ + + + EX. 2000 + +
+