From 2dba4e563ee76196f7143b26a9bca4a4617f1468 Mon Sep 17 00:00:00 2001 From: Tim DiLauro Date: Thu, 26 Sep 2024 20:21:13 -0400 Subject: [PATCH] Logo-only header for QuickSight page. (PP-1720) (#136) * Add assett and style mocks to jest, so we can import our logo in tests. * Add terms of service context to our providers test helper. * Enable a logo-only header and use it for QuickSight dashboard. --- jest.config.js | 5 + src/components/Header.tsx | 153 ++++++++++-------- src/components/QuicksightDashboardPage.tsx | 2 +- src/components/TOSContext.tsx | 7 +- tests/__mocks__/fileMock.js | 1 + tests/__mocks__/styleMock.js | 1 + .../components/QuicksightDashboard.test.tsx | 29 ++-- tests/jest/testUtils/withProviders.tsx | 22 ++- 8 files changed, 139 insertions(+), 81 deletions(-) create mode 100644 tests/__mocks__/fileMock.js create mode 100644 tests/__mocks__/styleMock.js diff --git a/jest.config.js b/jest.config.js index 39fc0af80..8ed13af42 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,10 @@ /** @type {import('ts-jest').JestConfigWithTsJest} */ module.exports = { + moduleNameMapper: { + "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": + "/tests/__mocks__/fileMock.js", + "\\.(css|less)$": "/tests/__mocks__/styleMock.js", + }, preset: "ts-jest", testEnvironment: "jsdom", testEnvironmentOptions: { diff --git a/src/components/Header.tsx b/src/components/Header.tsx index b5d14d3df..5f5a6ae68 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -29,6 +29,7 @@ export interface HeaderDispatchProps { export interface HeaderOwnProps { store?: Store; + logoOnly?: boolean; } export interface HeaderProps @@ -130,83 +131,90 @@ export class Header extends React.Component { }, ]; const accountLink = { label: "Change password", href: "account/" }; + const logoOnly = this.props.logoOnly ?? false; return ( {title()} - {this.props.libraries && this.props.libraries.length > 0 && ( - - {(!this.context.library || !currentLibrary) && ( - - )} - {this.props.libraries.map((library) => ( - - ))} - + {(!this.context.library || !currentLibrary) && ( + + )} + {this.props.libraries.map((library) => ( + + ))} + + )} + + )} - - - {currentLibrary && ( -