From e431be028909fbd7576fd7bea5f55e4a4c4e853c Mon Sep 17 00:00:00 2001 From: Nicholas Lee Date: Wed, 6 Nov 2024 17:21:33 -0500 Subject: [PATCH] MAINT: add banner for town hall (#844) * MAINT: add banner for town hall * fix: failing integration tests * Dummy commit to trigger something --- .../Extraction/ExtractionTable.cy.tsx | 14 +- .../SleuthImport/DoSleuthImport.cy.tsx | 2 +- compose/neurosynth-frontend/src/App.tsx | 128 +++++++++--------- .../src/components/Downbanner.tsx | 101 ++++++++------ 4 files changed, 134 insertions(+), 111 deletions(-) diff --git a/compose/neurosynth-frontend/cypress/e2e/workflows/Extraction/ExtractionTable.cy.tsx b/compose/neurosynth-frontend/cypress/e2e/workflows/Extraction/ExtractionTable.cy.tsx index f1fc62bc..54172e13 100644 --- a/compose/neurosynth-frontend/cypress/e2e/workflows/Extraction/ExtractionTable.cy.tsx +++ b/compose/neurosynth-frontend/cypress/e2e/workflows/Extraction/ExtractionTable.cy.tsx @@ -154,24 +154,30 @@ describe('ExtractionTable', () => { }); }); - it('should remove the filter if the delete button is clicked', () => { + it.only('should remove the filter if the delete button is clicked', () => { + let studysetYear = ''; // ARRANGE cy.wait('@studysetFixture').then((studysetFixture) => { const studyset = studysetFixture?.response?.body as StudysetReturn; const studysetStudies = studyset.studies as StudyReturn[]; + studysetYear = studysetStudies[0].year?.toString() || ""; cy.get('input').eq(0).click(); cy.get(`input`) .eq(0) .type(studysetStudies[0].year?.toString() || ''); }); cy.get('tbody > tr').should('have.length', 1); - cy.get('[data-testid="CancelIcon"]').should('exist'); + // ACT - cy.get('[data-testid="CancelIcon"]').click(); + cy.contains( + `Filtering YEAR: ${studysetYear}` + ).parent().find('[data-testid="CancelIcon"]').click(); // ASSERT cy.get('tbody > tr').should('have.length', 3); - cy.get(`[data-testid="CancelIcon"]`).should('not.exist'); + cy.contains( + `Filtering YEAR: ${studysetYear}` + ).should('not.exist') }); }); diff --git a/compose/neurosynth-frontend/cypress/e2e/workflows/SleuthImport/DoSleuthImport.cy.tsx b/compose/neurosynth-frontend/cypress/e2e/workflows/SleuthImport/DoSleuthImport.cy.tsx index 13acbfc1..950f9e1b 100644 --- a/compose/neurosynth-frontend/cypress/e2e/workflows/SleuthImport/DoSleuthImport.cy.tsx +++ b/compose/neurosynth-frontend/cypress/e2e/workflows/SleuthImport/DoSleuthImport.cy.tsx @@ -422,7 +422,7 @@ describe('DoSleuthImport', () => { it('should select MKDA and create an MKDA meta analysis', () => { cy.contains('button', 'Yes').click(); - cy.get('[type="radio"]').eq(1).click(); + cy.get('[type="radio"]').eq(1).click({ force: true }); cy.contains('button', 'create') .click() .wait('@specificationPostFixture') diff --git a/compose/neurosynth-frontend/src/App.tsx b/compose/neurosynth-frontend/src/App.tsx index f713e039..7d791c8c 100644 --- a/compose/neurosynth-frontend/src/App.tsx +++ b/compose/neurosynth-frontend/src/App.tsx @@ -1,78 +1,82 @@ -import Close from '@mui/icons-material/Close'; -import { IconButton } from '@mui/material'; -import { AxiosError } from 'axios'; -import useGoogleAnalytics from 'hooks/useGoogleAnalytics'; -import { SnackbarKey, SnackbarProvider } from 'notistack'; -import { useEffect, useRef } from 'react'; -import { QueryCache, QueryClient, QueryClientProvider } from 'react-query'; -import Navbar from 'components/Navbar/Navbar'; -import useGetToken from './hooks/useGetToken'; -import BaseNavigation from 'pages/BaseNavigation/BaseNavigation'; -import { useLocation } from 'react-router-dom'; +import Close from "@mui/icons-material/Close"; +import { IconButton } from "@mui/material"; +import { AxiosError } from "axios"; +import useGoogleAnalytics from "hooks/useGoogleAnalytics"; +import { SnackbarKey, SnackbarProvider } from "notistack"; +import { useEffect, useRef } from "react"; +import { QueryCache, QueryClient, QueryClientProvider } from "react-query"; +import Navbar from "components/Navbar/Navbar"; +import useGetToken from "./hooks/useGetToken"; +import BaseNavigation from "pages/BaseNavigation/BaseNavigation"; +import { useLocation } from "react-router-dom"; +import Downbanner from "components/Downbanner"; const queryClient = new QueryClient({ - defaultOptions: { - queries: { - retry: 0, - refetchOnWindowFocus: false, - // staleTime: 5000, // https://tkdodo.eu/blog/practical-react-query#the-defaults-explained - }, + defaultOptions: { + queries: { + retry: 0, + refetchOnWindowFocus: false, + // staleTime: 5000, // https://tkdodo.eu/blog/practical-react-query#the-defaults-explained }, - queryCache: new QueryCache({ - onError: (error) => { - console.log({ error }); - const responseStatus = (error as AxiosError)?.response?.status; - if (responseStatus && responseStatus === 404) { - console.error('could not find resource'); - } - }, - }), + }, + queryCache: new QueryCache({ + onError: (error) => { + console.log({ error }); + const responseStatus = (error as AxiosError)?.response?.status; + if (responseStatus && responseStatus === 404) { + console.error("could not find resource"); + } + }, + }), }); declare global { - interface Window { - gtag?: ( - type: 'event' | 'config' | 'get' | 'set' | 'consent', - action: 'login' | 'page_view', - options?: any - ) => void; - } + interface Window { + gtag?: ( + type: "event" | "config" | "get" | "set" | "consent", + action: "login" | "page_view", + options?: any + ) => void; + } } function App() { - const notistackRef = useRef(null); - useGetToken(); - useGoogleAnalytics(); + const notistackRef = useRef(null); + useGetToken(); + useGoogleAnalytics(); - const location = useLocation(); - useEffect(() => { - if (window.gtag) { - window.gtag('event', 'page_view', { - page_path: `${location.pathname}${location.search}`, - }); - } - }, [location]); + const location = useLocation(); + useEffect(() => { + if (window.gtag) { + window.gtag("event", "page_view", { + page_path: `${location.pathname}${location.search}`, + }); + } + }, [location]); - const handleCloseSnackbar = (key: SnackbarKey) => (_event: React.MouseEvent) => { - if (notistackRef?.current?.closeSnackbar) notistackRef.current?.closeSnackbar(key); + const handleCloseSnackbar = + (key: SnackbarKey) => (_event: React.MouseEvent) => { + if (notistackRef?.current?.closeSnackbar) + notistackRef.current?.closeSnackbar(key); }; - return ( - - ( - - - - )} - > - - - - - ); + return ( + + ( + + + + )} + > + + + + + + ); } export default App; diff --git a/compose/neurosynth-frontend/src/components/Downbanner.tsx b/compose/neurosynth-frontend/src/components/Downbanner.tsx index 8ea82583..078de858 100644 --- a/compose/neurosynth-frontend/src/components/Downbanner.tsx +++ b/compose/neurosynth-frontend/src/components/Downbanner.tsx @@ -1,52 +1,65 @@ -import { Cancel } from '@mui/icons-material'; -import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline'; -import { Box, IconButton } from '@mui/material'; -import BaseNavigationStyles from 'pages/BaseNavigation/BaseNavigation.styles'; -import { useState } from 'react'; +import { Cancel } from "@mui/icons-material"; +import EmojiPeopleIcon from "@mui/icons-material/EmojiPeople"; +import { Box, IconButton, Link } from "@mui/material"; +import BaseNavigationStyles from "pages/BaseNavigation/BaseNavigation.styles"; +import { useState } from "react"; + +const localStorageDownBannerKey = "hide-downbanner-nov-6-2024"; const Downbanner: React.FC = () => { - const shouldHide = !!localStorage.getItem('hide-downbanner-sep-13-2024'); - const [hideBanner, setHideBanner] = useState(shouldHide); + const shouldHide = !!localStorage.getItem(localStorageDownBannerKey); + const [hideBanner, setHideBanner] = useState(shouldHide); - if (hideBanner) return <>; + if (hideBanner) return <>; - return ( - - - - - Neurosynth-compose will be undergoing planned maintenance and will be offline on - friday (Sep/13/2024) - - { - localStorage.setItem('hide-downbanner-sep-13-2024', 'true'); - setHideBanner(true); - }} - sx={{ padding: 0, ':hover': { backgroundColor: 'secondary.light' } }} - > - - - + return ( + + + + + Join us next Wednesday, November 13th at 19:00 ET for the inaugural + Neurosynth Compose Virtual Town Hall!{" "} + + Click here to register + - ); + { + localStorage.setItem(localStorageDownBannerKey, "true"); + setHideBanner(true); + }} + sx={{ + padding: 0, + ":hover": { backgroundColor: "secondary.light" }, + }} + > + + + + + ); }; export default Downbanner;