From b08e72cd5955c31c354e52320a12bea300481182 Mon Sep 17 00:00:00 2001 From: Nichole Frey Date: Tue, 5 Mar 2024 19:27:14 -0500 Subject: [PATCH] commit test that fails --- src/app/work/WorkTabs.tsx | 15 ++++++++++----- src/app/work/page.test.tsx | 11 ++++++----- src/app/work/page.tsx | 8 ++++++-- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/app/work/WorkTabs.tsx b/src/app/work/WorkTabs.tsx index be3f2de..7b1fd43 100644 --- a/src/app/work/WorkTabs.tsx +++ b/src/app/work/WorkTabs.tsx @@ -2,7 +2,7 @@ import { useState, SyntheticEvent } from 'react'; import Box from '@mui/material/Box'; -import Tabs from '@mui/material/Tabs'; +import Tabs, { TabsProps } from '@mui/material/Tabs'; import Tab from '@mui/material/Tab'; import { WorkItemType } from './constants'; @@ -17,15 +17,22 @@ type TabsOnChange = (event: SyntheticEvent, value: any) => void; interface WorkTabsProps { items: WorkItemType[]; + scrollable: boolean; } -const WorkTabs: React.FC = ({ items }) => { +const WorkTabs: React.FC = ({ items, scrollable }) => { const [value, setValue] = useState(0); const handleChange: TabsOnChange = (_, newValue) => { setValue(newValue); }; + const scrollableProps: TabsProps = { + variant: 'scrollable', + scrollButtons: true, + allowScrollButtonsMobile: true, + }; + return ( @@ -33,11 +40,9 @@ const WorkTabs: React.FC = ({ items }) => { value={value} onChange={handleChange} aria-label="work experience tabs" - variant="scrollable" - scrollButtons - allowScrollButtonsMobile // https://mui.com/base-ui/react-tabs/#keyboard-navigation selectionFollowsFocus + {...(scrollable && scrollableProps)} > {items.map((item, index) => { return ( diff --git a/src/app/work/page.test.tsx b/src/app/work/page.test.tsx index 8fb9a13..1a0096f 100644 --- a/src/app/work/page.test.tsx +++ b/src/app/work/page.test.tsx @@ -7,7 +7,7 @@ import { screen, renderSnapshotWithLayout, } from 'test-utils'; -// import userEvent from '@testing-library/user-event'; +import userEvent from '@testing-library/user-event'; import WorkPage from './page'; @@ -46,10 +46,10 @@ describe('The Work Page', () => { } ); - test('works as expected', () => { - // const user = userEvent.setup(); + test('works as expected', async () => { + const user = userEvent.setup(); - render(); + render(); const heading = screen.getByRole('heading', { level: 1 }); expect(heading).toBeVisible(); @@ -65,7 +65,8 @@ describe('The Work Page', () => { expect(imperfectTab).toBeVisible(); // TODO https://github.com/nicholeuf/zen-site-next/issues/30 - // await user.click(imperfectTab); + // This triggers an error, which only happens while under test + await user.click(imperfectTab); // const imperfectHeading2 = screen.getByRole('heading', { level: 2 }); // expect(imperfectHeading2).toBeVisible(); diff --git a/src/app/work/page.tsx b/src/app/work/page.tsx index 27c5ad1..1adf5fb 100644 --- a/src/app/work/page.tsx +++ b/src/app/work/page.tsx @@ -9,7 +9,11 @@ export const metadata: Metadata = { title: 'Work', }; -const Work: React.FC = () => { +interface WorkProps { + scrollable?: boolean; +} + +const Work: React.FC = ({ scrollable = true }) => { return ( @@ -24,7 +28,7 @@ const Work: React.FC = () => { mentorship to colleagues, and collaborating within agile, cross-functional teams. - + ); };