Skip to content

Commit

Permalink
commit test that fails
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholeuf committed Mar 6, 2024
1 parent 0f96428 commit b08e72c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
15 changes: 10 additions & 5 deletions src/app/work/WorkTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -17,27 +17,32 @@ type TabsOnChange = (event: SyntheticEvent, value: any) => void;

interface WorkTabsProps {
items: WorkItemType[];
scrollable: boolean;
}

const WorkTabs: React.FC<WorkTabsProps> = ({ items }) => {
const WorkTabs: React.FC<WorkTabsProps> = ({ items, scrollable }) => {
const [value, setValue] = useState(0);

const handleChange: TabsOnChange = (_, newValue) => {
setValue(newValue);
};

const scrollableProps: TabsProps = {
variant: 'scrollable',
scrollButtons: true,
allowScrollButtonsMobile: true,
};

return (
<Box sx={{ width: '100%' }}>
<Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
<Tabs
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 (
Expand Down
11 changes: 6 additions & 5 deletions src/app/work/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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(<WorkPage />);
render(<WorkPage scrollable={false} />);

const heading = screen.getByRole('heading', { level: 1 });
expect(heading).toBeVisible();
Expand All @@ -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();
Expand Down
8 changes: 6 additions & 2 deletions src/app/work/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export const metadata: Metadata = {
title: 'Work',
};

const Work: React.FC = () => {
interface WorkProps {
scrollable?: boolean;
}

const Work: React.FC<WorkProps> = ({ scrollable = true }) => {
return (
<PageContainer data-testid="work-page">
<Typography variant="h1" gutterBottom>
Expand All @@ -24,7 +28,7 @@ const Work: React.FC = () => {
mentorship to colleagues, and collaborating within agile,
cross-functional teams.
</Typography>
<WorkTabs items={items} />
<WorkTabs items={items} scrollable={scrollable} />
</PageContainer>
);
};
Expand Down

0 comments on commit b08e72c

Please sign in to comment.