Skip to content

Commit

Permalink
SHARED:AKR:OTR:VKT:YKI(Frontend): Fix rendering of toggle filter with…
Browse files Browse the repository at this point in the history
… zero count
  • Loading branch information
pkoivisto committed Feb 28, 2024
1 parent 7647de1 commit 24d01f7
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 11 deletions.
2 changes: 1 addition & 1 deletion frontend/packages/akr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"akr:tslint": "yarn g:tsc --pretty --noEmit"
},
"dependencies": {
"shared": "npm:@opetushallitus/[email protected].4"
"shared": "npm:@opetushallitus/[email protected].5"
}
}
2 changes: 1 addition & 1 deletion frontend/packages/otr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"otr:tslint": "yarn g:tsc --pretty --noEmit"
},
"dependencies": {
"shared": "npm:@opetushallitus/[email protected].4"
"shared": "npm:@opetushallitus/[email protected].5"
}
}
6 changes: 6 additions & 0 deletions frontend/packages/shared/CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Released]

## [1.10.5] - 2024-02-28

### Fixed

- ToggleFilterGroup buttons should render zero counts properly

## [1.10.4] - 2024-01-23

### Changed
Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opetushallitus/kieli-ja-kaantajatutkinnot.shared",
"version": "1.10.4",
"version": "1.10.5",
"description": "Shared Frontend Package",
"exports": {
"./components": "./src/components/index.tsx",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import renderer from 'react-test-renderer';

import { ToggleFilterGroup } from './ToggleFilterGroup';

const enum FilterStatusEnum {
Active,
Passive,
Expired,
}
const filterData = [
{
status: FilterStatusEnum.Active,
label: 'Active',
count: 10,
testId: 'toggleFilter--active',
},
{
status: FilterStatusEnum.Passive,
label: 'Passive',
count: 0,
},
{
status: FilterStatusEnum.Expired,
label: 'Expired',
},
];

describe('ToggleFilterGroup', () => {
it('should render correctly', () => {
const tree = renderer
.create(
<ToggleFilterGroup
filters={filterData}
activeStatus={FilterStatusEnum.Active}
onButtonClick={jest.fn}
/>,
)
.toJSON();

expect(tree).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function ToggleFilterGroup<T>({
>
<div className="columns gapped">
<div className="grow">{label}</div>
{count && <div>{`(${count})`}</div>}
{typeof count === "number" && <div>{`(${count})`}</div>}
</div>
</CustomButton>
))}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ToggleFilterGroup should render correctly 1`] = `
<div
className="columns"
>
<button
className="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedSecondary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-root MuiButton-contained MuiButton-containedSecondary MuiButton-sizeMedium MuiButton-containedSizeMedium border-radius-unset css-zcbmsk-MuiButtonBase-root-MuiButton-root"
data-testid="toggleFilter--active"
disabled={false}
onBlur={[Function]}
onClick={[Function]}
onContextMenu={[Function]}
onDragLeave={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseLeave={[Function]}
onMouseUp={[Function]}
onTouchEnd={[Function]}
onTouchMove={[Function]}
onTouchStart={[Function]}
tabIndex={0}
type="button"
>
<div
className="columns gapped"
>
<div
className="grow"
>
Active
</div>
<div>
(10)
</div>
</div>
</button>
<button
className="MuiButtonBase-root MuiButton-root MuiButton-outlined MuiButton-outlinedSecondary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-root MuiButton-outlined MuiButton-outlinedSecondary MuiButton-sizeMedium MuiButton-outlinedSizeMedium border-radius-unset css-1l9sosn-MuiButtonBase-root-MuiButton-root"
disabled={false}
onBlur={[Function]}
onClick={[Function]}
onContextMenu={[Function]}
onDragLeave={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseLeave={[Function]}
onMouseUp={[Function]}
onTouchEnd={[Function]}
onTouchMove={[Function]}
onTouchStart={[Function]}
tabIndex={0}
type="button"
>
<div
className="columns gapped"
>
<div
className="grow"
>
Passive
</div>
<div>
(0)
</div>
</div>
</button>
<button
className="MuiButtonBase-root MuiButton-root MuiButton-outlined MuiButton-outlinedSecondary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-root MuiButton-outlined MuiButton-outlinedSecondary MuiButton-sizeMedium MuiButton-outlinedSizeMedium border-radius-unset css-1l9sosn-MuiButtonBase-root-MuiButton-root"
disabled={false}
onBlur={[Function]}
onClick={[Function]}
onContextMenu={[Function]}
onDragLeave={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseLeave={[Function]}
onMouseUp={[Function]}
onTouchEnd={[Function]}
onTouchMove={[Function]}
onTouchStart={[Function]}
tabIndex={0}
type="button"
>
<div
className="columns gapped"
>
<div
className="grow"
>
Expired
</div>
</div>
</button>
</div>
`;
2 changes: 1 addition & 1 deletion frontend/packages/vkt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
},
"dependencies": {
"reduxjs-toolkit-persist": "^7.2.1",
"shared": "npm:@opetushallitus/[email protected].4"
"shared": "npm:@opetushallitus/[email protected].5"
}
}
2 changes: 1 addition & 1 deletion frontend/packages/yki/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"yki:tslint": "yarn g:tsc --pretty --noEmit"
},
"dependencies": {
"shared": "npm:@opetushallitus/[email protected].4"
"shared": "npm:@opetushallitus/[email protected].5"
},
"devDependencies": {
"multer": "^1.4.5-lts.1"
Expand Down
10 changes: 5 additions & 5 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2586,15 +2586,15 @@ __metadata:
version: 0.0.0-use.local
resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.akr@workspace:packages/akr"
dependencies:
shared: "npm:@opetushallitus/[email protected].3"
shared: "npm:@opetushallitus/[email protected].5"
languageName: unknown
linkType: soft

"@opetushallitus/kieli-ja-kaantajatutkinnot.otr@workspace:packages/otr":
version: 0.0.0-use.local
resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.otr@workspace:packages/otr"
dependencies:
shared: "npm:@opetushallitus/[email protected].3"
shared: "npm:@opetushallitus/[email protected].5"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -2687,7 +2687,7 @@ __metadata:
languageName: unknown
linkType: soft

"@opetushallitus/kieli-ja-kaantajatutkinnot.shared@workspace:packages/shared, shared@npm:@opetushallitus/[email protected].3":
"@opetushallitus/kieli-ja-kaantajatutkinnot.shared@workspace:packages/shared, shared@npm:@opetushallitus/[email protected].5":
version: 0.0.0-use.local
resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.shared@workspace:packages/shared"
languageName: unknown
Expand All @@ -2698,7 +2698,7 @@ __metadata:
resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.vkt@workspace:packages/vkt"
dependencies:
reduxjs-toolkit-persist: "npm:^7.2.1"
shared: "npm:@opetushallitus/[email protected].3"
shared: "npm:@opetushallitus/[email protected].5"
languageName: unknown
linkType: soft

Expand All @@ -2707,7 +2707,7 @@ __metadata:
resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.yki@workspace:packages/yki"
dependencies:
multer: "npm:^1.4.5-lts.1"
shared: "npm:@opetushallitus/[email protected].3"
shared: "npm:@opetushallitus/[email protected].5"
languageName: unknown
linkType: soft

Expand Down

0 comments on commit 24d01f7

Please sign in to comment.