Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
f1af0a6
.prettierrc: remove hardcoded babel as parser setting to allow typesc…
clairep94 Aug 3, 2025
8a0f302
SkipLink: lint correctly to add ; to end of type definition lines
clairep94 Aug 3, 2025
1cb8f5b
RouterTab: unit test
clairep94 Aug 3, 2025
d376207
RouterTab: update to tsx --no-verify
clairep94 Aug 3, 2025
29e1e6d
RouterTab: add typescript & install @types/react-router-dom
clairep94 Aug 3, 2025
1efe93d
Button: update to tsx --no-verify
clairep94 Aug 3, 2025
6042638
Button.tsx: migrate to typescript, add unit test, add @types/styled-c…
clairep94 Aug 3, 2025
c1883c5
ButtonOrLink: update to tsx files --no-verify
clairep94 Aug 3, 2025
eb69138
ButtonOrLink: update to typescript
clairep94 Aug 3, 2025
5dd03d1
IconButton: update to tsx --no-verify
clairep94 Aug 3, 2025
197fd67
IconButton: migrate to typescript & add unit test
clairep94 Aug 3, 2025
cfb4b82
usePrevious: update to ts --no-verify
clairep94 Aug 3, 2025
d80961c
usePrevious: migrate to typescript & add unit test
clairep94 Aug 3, 2025
24368cc
isMac: migrate to typescript and add test
clairep94 Aug 3, 2025
e67e015
useKeyDownHandlers: update to ts --no-verify
clairep94 Aug 3, 2025
1b5373c
useKeyDownHandler: migrate to typescript and add unit test
clairep94 Aug 3, 2025
b5eea95
useModalClose: update to ts --no-verify
clairep94 Aug 3, 2025
7ca1e6d
useModalClose: update to typescript & add test
clairep94 Aug 3, 2025
7075ffb
useSyncFormTranslation: update to ts --no-verify
clairep94 Aug 3, 2025
6bc9369
useSyncFormTranslations: update to typescript and add unit test
clairep94 Aug 3, 2025
94ea59a
rename test utility rerender to mountComponent
clairep94 Aug 3, 2025
1b72ea4
Merge branch 'develop' into pr05/migrate_client_common_rebuild
clairep94 Aug 14, 2025
7ce4f54
.eslintrc: update to fix no-shadow eslint error on enums
clairep94 Aug 15, 2025
7188c1b
usePrevious: make type unknown to make more generic
clairep94 Aug 15, 2025
bee3211
RouterTab: update TabProps to interface
clairep94 Aug 15, 2025
6148c33
ButtonOrLink: update to interface
clairep94 Aug 16, 2025
3e8faea
IconButton: remove null
clairep94 Aug 16, 2025
4bd9443
Button: WIP update
clairep94 Aug 18, 2025
7718e02
SkipLink: update type to interface
clairep94 Aug 19, 2025
3428dac
.eslintrc: cherry-pick ts overrids from utils pr
clairep94 Aug 14, 2025
1a7cfaa
useSyncFormTranslations: update to be named export
clairep94 Aug 19, 2025
3676534
eslintrc: fix double config
clairep94 Aug 19, 2025
366aa7e
usePrevious: update to be named export
clairep94 Aug 19, 2025
2d8fe06
useModalClose: update to named export
clairep94 Aug 19, 2025
b1788d5
useKeyDownHandler: update to named export
clairep94 Aug 19, 2025
bc82be5
RouterTab: update to named export
clairep94 Aug 19, 2025
7b67549
ButtonOrLink: update to named export
clairep94 Aug 20, 2025
379e563
IconButton: update to interface and named export
clairep94 Aug 20, 2025
9515291
Button: update to named export
clairep94 Aug 25, 2025
dc7665d
Button: clean up type definition to interface and add basic html elem…
clairep94 Aug 25, 2025
0ff9ac1
lint
clairep94 Aug 25, 2025
a09c8d2
Merge branch 'develop' into pr05/migrate_client_common_rebuild
clairep94 Aug 25, 2025
7e7c1ab
merge with main
clairep94 Aug 25, 2025
67425a1
Button: update jsdoc
clairep94 Aug 19, 2025
001c9e4
SkipLink: Update to named export
clairep94 Aug 19, 2025
e8ba7b8
SkipLink: update test setup to use testutils
clairep94 Aug 25, 2025
6e41106
useKeyDownHandlers: update to use testutils
clairep94 Aug 25, 2025
3d5fba3
useModalClose: update to use testutils
clairep94 Aug 25, 2025
316637e
usePrevious: update to use testutils
clairep94 Aug 25, 2025
3e89f7f
useSyncFormTranslations: update to use testutils
clairep94 Aug 25, 2025
a6e9050
merge with develop
clairep94 Aug 28, 2025
8f0f0b5
Button & IconButton: update focusable to be boolean not booleanish st…
clairep94 Aug 28, 2025
627462e
Button: update enum to explicit export and in constant case
clairep94 Aug 28, 2025
7999ada
Merge branch 'develop' into pr05/migrate_client_common_rebuild
clairep94 Aug 28, 2025
a328e44
Merge branch 'develop' into pr05/migrate_client_common_rebuild
clairep94 Aug 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
"no-unused-vars": "off",
"import/no-default-export": "warn",
"no-underscore-dangle": "warn",
"react/require-default-props": "off",
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error"
}
},
{
Expand Down
10 changes: 5 additions & 5 deletions client/common/Button.stories.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { action } from '@storybook/addon-actions';

import Button from './Button';
import { Button, ButtonDisplays, ButtonKinds, ButtonTypes } from './Button';

Check warning on line 4 in client/common/Button.stories.jsx

View workflow job for this annotation

GitHub Actions / Test and lint code base

'ButtonKinds' is defined but never used
import { GithubIcon, DropdownArrowIcon, PlusIcon } from './icons';

export default {
Expand All @@ -15,13 +15,13 @@
};

export const AllFeatures = (args) => (
<Button disabled={args.disabled} type="submit" label={args.label}>
<Button disabled={args.disabled} type={ButtonTypes.SUBMIT} label={args.label}>
{args.children}
</Button>
);

export const SubmitButton = () => (
<Button type="submit" label="submit">
<Button type={ButtonTypes.SUBMIT} label="submit">
This is a submit button
</Button>
);
Expand Down Expand Up @@ -59,7 +59,7 @@
);

export const InlineButtonWithIconAfter = () => (
<Button iconAfter={<DropdownArrowIcon />} display={Button.displays.inline}>
<Button iconAfter={<DropdownArrowIcon />} display={ButtonDisplays.INLINE}>
File name
</Button>
);
Expand All @@ -68,6 +68,6 @@
<Button
aria-label="Add to collection"
iconBefore={<PlusIcon />}
display={Button.displays.inline}
display={ButtonDisplays.INLINE}
/>
);
91 changes: 91 additions & 0 deletions client/common/Button.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import React from 'react';
import { render, screen, fireEvent } from '../test-utils';
import { Button } from './Button';

const MockIcon = (props: React.SVGProps<SVGSVGElement>) => (
<svg data-testid="mock-icon" {...props} />
);

describe('Button', () => {
// Tag
it('renders as an anchor when href is provided', () => {
render(<Button href="https://example.com">Link</Button>);
const anchor = screen.getByRole('link');
expect(anchor.tagName.toLowerCase()).toBe('a');
expect(anchor).toHaveAttribute('href', 'https://example.com');
});

it('renders as a React Router <Link> when `to` is provided', () => {
render(<Button to="/dashboard">Go</Button>);
const link = screen.getByRole('link');
expect(link.tagName.toLowerCase()).toBe('a'); // Link renders as <a>
expect(link).toHaveAttribute('href', '/dashboard');
});

it('renders as a <button> with a type of "button" by default', () => {
render(<Button>Click Me</Button>);
const el = screen.getByRole('button');
expect(el.tagName.toLowerCase()).toBe('button');
expect(el).toHaveAttribute('type', 'button');
});

// Children & Icons
it('renders children', () => {
render(<Button>Click Me</Button>);
expect(screen.getByText('Click Me')).toBeInTheDocument();
});

it('renders an iconBefore and button text', () => {
render(
<Button iconBefore={<MockIcon aria-label="iconbefore" />}>
This has a before icon
</Button>
);
expect(screen.getByLabelText('iconbefore')).toBeInTheDocument();
expect(screen.getByRole('button')).toHaveTextContent(
'This has a before icon'
);
});

it('renders with iconAfter', () => {
render(
<Button iconAfter={<MockIcon aria-label="iconafter" />}>
This has an after icon
</Button>
);
expect(screen.getByLabelText('iconafter')).toBeInTheDocument();
expect(screen.getByRole('button')).toHaveTextContent(
'This has an after icon'
);
});

it('renders only the icon if iconOnly', () => {
render(
<Button iconAfter={<MockIcon aria-label="iconafter" />} iconOnly>
This has an after icon
</Button>
);
expect(screen.getByLabelText('iconafter')).toBeInTheDocument();
expect(screen.getByRole('button')).not.toHaveTextContent(
'This has an after icon'
);
});

// HTML attributes
it('calls onClick handler when clicked', () => {
const handleClick = jest.fn();
render(<Button onClick={handleClick}>Click</Button>);
fireEvent.click(screen.getByText('Click'));
expect(handleClick).toHaveBeenCalledTimes(1);
});

it('renders disabled state', () => {
render(<Button disabled>Disabled</Button>);
expect(screen.getByRole('button')).toBeDisabled();
});

it('uses aria-label when provided', () => {
render(<Button aria-label="Upload" iconOnly />);
expect(screen.getByLabelText('Upload')).toBeInTheDocument();
});
});
Loading