@databiosphere/findable-ui 32.1.1 → 34.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +27 -0
- package/jest.config.js +4 -0
- package/lib/common/categories/config/utils.d.ts +1 -1
- package/lib/common/categories/config/utils.js +5 -1
- package/lib/common/entities.d.ts +4 -4
- package/lib/components/DataDictionary/components/Entities/entities.d.ts +1 -1
- package/lib/components/DataDictionary/components/Entities/entities.js +3 -2
- package/lib/components/DataDictionary/components/Entities/types.d.ts +3 -4
- package/lib/components/DataDictionary/components/Entity/entity.d.ts +1 -1
- package/lib/components/DataDictionary/components/Entity/entity.js +12 -6
- package/lib/components/DataDictionary/components/Entity/entity.styles.js +7 -1
- package/lib/components/DataDictionary/components/Entity/types.d.ts +4 -4
- package/lib/components/DataDictionary/components/Entity/utils.d.ts +9 -0
- package/lib/components/DataDictionary/components/Entity/utils.js +18 -0
- package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.d.ts +4 -0
- package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.js +9 -0
- package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/types.d.ts +5 -0
- package/lib/components/DataDictionary/components/Filters/components/ColumnFilters/types.js +1 -0
- package/lib/components/DataDictionary/components/Filters/filters.d.ts +4 -0
- package/lib/components/DataDictionary/components/Filters/filters.js +7 -0
- package/lib/components/DataDictionary/components/Filters/filters.styles.d.ts +7 -0
- package/lib/components/DataDictionary/components/Filters/filters.styles.js +13 -0
- package/lib/components/DataDictionary/components/Filters/stories/constants.d.ts +4 -0
- package/lib/components/DataDictionary/components/Filters/stories/constants.js +25 -0
- package/lib/components/DataDictionary/components/Filters/stories/filters.stories.d.ts +6 -0
- package/lib/components/DataDictionary/components/Filters/stories/filters.stories.js +31 -0
- package/lib/components/DataDictionary/components/Filters/stories/hook.d.ts +5 -0
- package/lib/components/DataDictionary/components/Filters/stories/hook.js +5 -0
- package/lib/components/DataDictionary/components/Filters/stories/types.d.ts +4 -0
- package/lib/components/DataDictionary/components/Filters/stories/types.js +1 -0
- package/lib/components/DataDictionary/components/Filters/types.d.ts +5 -0
- package/lib/components/DataDictionary/components/Filters/types.js +1 -0
- package/lib/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.styles.js +3 -1
- package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.d.ts +2 -0
- package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.js +5 -0
- package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.styles.d.ts +5 -0
- package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.styles.js +24 -0
- package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/types.d.ts +5 -0
- package/lib/components/DataDictionary/components/Layout/components/FiltersLayout/types.js +1 -0
- package/lib/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.styles.js +1 -1
- package/lib/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.styles.js +1 -0
- package/lib/components/DataDictionary/components/Layout/constants.d.ts +4 -0
- package/lib/components/DataDictionary/components/Layout/constants.js +4 -0
- package/lib/components/DataDictionary/components/Outline/utils.d.ts +5 -5
- package/lib/components/DataDictionary/components/Outline/utils.js +23 -6
- package/lib/components/DataDictionary/components/Table/hook.d.ts +3 -3
- package/lib/components/DataDictionary/components/Table/hook.js +11 -3
- package/lib/components/DataDictionary/components/Table/options/columnFilters/constants.d.ts +2 -0
- package/lib/components/DataDictionary/components/Table/options/columnFilters/constants.js +8 -0
- package/lib/components/DataDictionary/components/Table/options/columnFilters/hook.d.ts +6 -0
- package/lib/components/DataDictionary/components/Table/options/columnFilters/hook.js +14 -0
- package/lib/components/DataDictionary/components/Table/options/expanded/constants.d.ts +2 -0
- package/lib/components/DataDictionary/components/Table/options/expanded/constants.js +5 -0
- package/lib/components/DataDictionary/components/Table/options/faceted/constants.d.ts +2 -0
- package/lib/components/DataDictionary/components/Table/options/faceted/constants.js +6 -0
- package/lib/components/DataDictionary/components/Table/options/grouping/constants.d.ts +2 -0
- package/lib/components/DataDictionary/components/Table/options/grouping/constants.js +5 -0
- package/lib/components/DataDictionary/components/Table/options/hook.d.ts +1 -1
- package/lib/components/DataDictionary/components/Table/options/hook.js +17 -0
- package/lib/components/DataDictionary/components/Table/options/visibility/constants.d.ts +2 -0
- package/lib/components/DataDictionary/components/Table/options/visibility/constants.js +3 -0
- package/lib/components/DataDictionary/components/Table/table.d.ts +1 -1
- package/lib/components/DataDictionary/components/Table/table.js +2 -2
- package/lib/components/DataDictionary/components/Table/types.d.ts +4 -1
- package/lib/components/DataDictionary/components/Table/utils.d.ts +18 -0
- package/lib/components/DataDictionary/components/Table/utils.js +27 -0
- package/lib/components/DataDictionary/dataDictionary.d.ts +1 -1
- package/lib/components/DataDictionary/dataDictionary.js +9 -7
- package/lib/components/DataDictionary/hooks/UseDataDictionary/hook.js +16 -4
- package/lib/components/DataDictionary/hooks/UseDataDictionary/types.d.ts +6 -4
- package/lib/components/DataDictionary/types.d.ts +1 -0
- package/lib/components/Detail/components/Table/components/TableBody/tableBody.d.ts +8 -2
- package/lib/components/Detail/components/Table/components/TableBody/tableBody.js +2 -2
- package/lib/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.d.ts +8 -2
- package/lib/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.js +2 -2
- package/lib/components/Detail/components/Table/components/TableRows/tableRows.d.ts +8 -2
- package/lib/components/Detail/components/Table/components/TableRows/tableRows.js +2 -2
- package/lib/components/Filter/components/FilterLabel/filterLabel.styles.d.ts +1 -1
- package/lib/components/Filter/components/FilterList/filterList.styles.d.ts +2 -0
- package/lib/components/Filter/components/FilterList/filterList.styles.js +28 -15
- package/lib/components/Filter/components/SearchAllFiltersSearch/searchAllFiltersSearch.styles.d.ts +1 -1
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/Button/button.styles.d.ts +1 -1
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/Button/button.styles.d.ts +1 -1
- package/lib/components/Layout/components/Header/header.styles.js +4 -1
- package/lib/components/Layout/components/Outline/components/ContentsTab/contentsTab.styles.d.ts +1 -1
- package/lib/components/Layout/components/Outline/outline.styles.d.ts +1 -1
- package/lib/components/Login/components/Button/button.styles.d.ts +1 -1
- package/lib/components/Table/common/utils.d.ts +6 -0
- package/lib/components/Table/common/utils.js +14 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.d.ts +7 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.js +33 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.styles.d.ts +3 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/columnFilter.styles.js +19 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/constants.d.ts +2 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/constants.js +14 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/types.d.ts +7 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/types.js +1 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/utils.d.ts +6 -0
- package/lib/components/Table/components/TableFeatures/ColumnFilter/utils.js +23 -0
- package/lib/components/Table/featureOptions/facetedColumn/utils.d.ts +6 -0
- package/lib/components/Table/featureOptions/facetedColumn/utils.js +9 -0
- package/lib/components/common/ButtonGroup/constants.d.ts +2 -0
- package/lib/components/common/ButtonGroup/constants.js +11 -0
- package/lib/components/common/Tabs/tabs.styles.d.ts +1 -1
- package/lib/mocks/@storybook/addon-actions.d.ts +9 -0
- package/lib/mocks/@storybook/addon-actions.js +9 -0
- package/lib/styles/common/mui/buttonGroup.d.ts +13 -0
- package/lib/styles/common/mui/buttonGroup.js +34 -0
- package/lib/styles/common/mui/typography.js +2 -0
- package/lib/tests/mui/constants.d.ts +1 -0
- package/lib/tests/mui/constants.js +1 -0
- package/lib/tests/utils.d.ts +6 -0
- package/lib/tests/utils.js +8 -0
- package/lib/theme/common/components.d.ts +0 -6
- package/lib/theme/common/components.js +17 -31
- package/lib/theme/components/index.d.ts +1 -0
- package/lib/theme/components/index.js +1 -0
- package/lib/theme/components/muiButtonGroup.d.ts +2 -0
- package/lib/theme/components/muiButtonGroup.js +76 -0
- package/lib/theme/theme.js +1 -1
- package/package.json +1 -1
- package/src/common/categories/config/utils.ts +6 -3
- package/src/common/entities.ts +5 -4
- package/src/components/DataDictionary/components/Entities/entities.tsx +5 -9
- package/src/components/DataDictionary/components/Entities/types.ts +3 -4
- package/src/components/DataDictionary/components/Entity/entity.styles.ts +9 -1
- package/src/components/DataDictionary/components/Entity/entity.tsx +18 -8
- package/src/components/DataDictionary/components/Entity/types.ts +4 -4
- package/src/components/DataDictionary/components/Entity/utils.ts +25 -0
- package/src/components/DataDictionary/components/Filters/components/ColumnFilters/columnFilters.tsx +21 -0
- package/src/components/DataDictionary/components/Filters/components/ColumnFilters/types.ts +6 -0
- package/src/components/DataDictionary/components/Filters/filters.styles.ts +14 -0
- package/src/components/DataDictionary/components/Filters/filters.tsx +16 -0
- package/src/components/DataDictionary/components/Filters/stories/constants.ts +31 -0
- package/src/components/DataDictionary/components/Filters/stories/filters.stories.tsx +42 -0
- package/src/components/DataDictionary/components/Filters/stories/hook.ts +9 -0
- package/src/components/DataDictionary/components/Filters/stories/types.ts +3 -0
- package/src/components/DataDictionary/components/Filters/types.ts +6 -0
- package/src/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.styles.ts +4 -1
- package/src/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.styles.ts +27 -0
- package/src/components/DataDictionary/components/Layout/components/FiltersLayout/filtersLayout.tsx +10 -0
- package/src/components/DataDictionary/components/Layout/components/FiltersLayout/types.ts +6 -0
- package/src/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.styles.ts +1 -1
- package/src/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.styles.ts +1 -0
- package/src/components/DataDictionary/components/Layout/constants.ts +4 -0
- package/src/components/DataDictionary/components/Outline/utils.ts +35 -13
- package/src/components/DataDictionary/components/Table/hook.ts +17 -5
- package/src/components/DataDictionary/components/Table/options/columnFilters/constants.ts +16 -0
- package/src/components/DataDictionary/components/Table/options/columnFilters/hook.ts +32 -0
- package/src/components/DataDictionary/components/Table/options/expanded/constants.ts +13 -0
- package/src/components/DataDictionary/components/Table/options/faceted/constants.ts +14 -0
- package/src/components/DataDictionary/components/Table/options/grouping/constants.ts +9 -0
- package/src/components/DataDictionary/components/Table/options/hook.ts +26 -3
- package/src/components/DataDictionary/components/Table/options/visibility/constants.ts +5 -0
- package/src/components/DataDictionary/components/Table/table.tsx +2 -0
- package/src/components/DataDictionary/components/Table/types.ts +8 -1
- package/src/components/DataDictionary/components/Table/utils.ts +40 -0
- package/src/components/DataDictionary/dataDictionary.tsx +10 -6
- package/src/components/DataDictionary/hooks/UseDataDictionary/hook.ts +19 -4
- package/src/components/DataDictionary/hooks/UseDataDictionary/types.ts +6 -4
- package/src/components/DataDictionary/types.ts +1 -0
- package/src/components/Detail/components/Table/components/TableBody/tableBody.tsx +14 -3
- package/src/components/Detail/components/Table/components/TableRows/components/CollapsableRows/collapsableRows.tsx +9 -2
- package/src/components/Detail/components/Table/components/TableRows/tableRows.tsx +9 -2
- package/src/components/Filter/components/FilterList/filterList.styles.ts +34 -15
- package/src/components/Layout/components/Header/header.styles.ts +6 -1
- package/src/components/Table/common/utils.ts +16 -0
- package/src/components/Table/components/TableFeatures/ColumnFilter/columnFilter.styles.ts +23 -0
- package/src/components/Table/components/TableFeatures/ColumnFilter/columnFilter.tsx +98 -0
- package/src/components/Table/components/TableFeatures/ColumnFilter/constants.ts +16 -0
- package/src/components/Table/components/TableFeatures/ColumnFilter/types.ts +10 -0
- package/src/components/Table/components/TableFeatures/ColumnFilter/utils.ts +27 -0
- package/src/components/Table/featureOptions/facetedColumn/utils.ts +14 -0
- package/src/components/common/ButtonGroup/constants.ts +13 -0
- package/src/mocks/@storybook/addon-actions.ts +10 -0
- package/src/styles/common/mui/buttonGroup.ts +46 -0
- package/src/styles/common/mui/typography.ts +2 -0
- package/src/tests/mui/constants.ts +1 -0
- package/src/tests/utils.ts +9 -0
- package/src/theme/common/components.ts +17 -32
- package/src/theme/components/index.ts +1 -0
- package/src/theme/components/muiButtonGroup.ts +79 -0
- package/src/theme/theme.ts +1 -1
- package/tests/dataDictionaryColumnFilters.test.tsx +101 -0
package/src/tests/utils.ts
CHANGED
|
@@ -32,6 +32,15 @@ export function getStartsWithRegex(text: string): RegExp {
|
|
|
32
32
|
return new RegExp(`^${escapeRegExp(text)}`);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves an element by its role.
|
|
37
|
+
* @param role - The role of the element.
|
|
38
|
+
* @returns The element.
|
|
39
|
+
*/
|
|
40
|
+
export function getRole<T extends HTMLElement = HTMLElement>(role: string): T {
|
|
41
|
+
return screen.getByRole(role);
|
|
42
|
+
}
|
|
43
|
+
|
|
35
44
|
/**
|
|
36
45
|
* Retrieves an element by its text content.
|
|
37
46
|
* @param text - The text content of the element.
|
|
@@ -3,6 +3,7 @@ import { DropDownIcon } from "../../components/common/Form/components/Select/com
|
|
|
3
3
|
import { COLOR_MIXES } from "../../styles/common/constants/colorMixes";
|
|
4
4
|
import { PALETTE } from "../../styles/common/constants/palette";
|
|
5
5
|
import { SHADOWS } from "../../styles/common/constants/shadows";
|
|
6
|
+
import { BUTTON_PROPS } from "../../styles/common/mui/button";
|
|
6
7
|
import { CHIP_PROPS } from "../../styles/common/mui/chip";
|
|
7
8
|
import { desktopUp, mobileUp, tabletUp } from "./breakpoints";
|
|
8
9
|
import {
|
|
@@ -200,6 +201,22 @@ export const MuiButton = (theme: Theme): Components["MuiButton"] => {
|
|
|
200
201
|
},
|
|
201
202
|
endIcon: {
|
|
202
203
|
margin: 0,
|
|
204
|
+
variants: [
|
|
205
|
+
{
|
|
206
|
+
props: { size: BUTTON_PROPS.SIZE.MEDIUM },
|
|
207
|
+
style: {
|
|
208
|
+
marginLeft: -6,
|
|
209
|
+
marginRight: -6,
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
props: { size: BUTTON_PROPS.SIZE.SMALL },
|
|
214
|
+
style: {
|
|
215
|
+
marginLeft: -6,
|
|
216
|
+
marginRight: -6,
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
],
|
|
203
220
|
},
|
|
204
221
|
outlinedSecondary: {
|
|
205
222
|
backgroundColor: "transparent",
|
|
@@ -317,38 +334,6 @@ export const MuiButtonBase = (theme: Theme): Components["MuiButtonBase"] => {
|
|
|
317
334
|
};
|
|
318
335
|
};
|
|
319
336
|
|
|
320
|
-
/**
|
|
321
|
-
* MuiButtonGroup Component
|
|
322
|
-
* @param theme - Theme.
|
|
323
|
-
* @returns MuiButtonGroup component theme styles.
|
|
324
|
-
*/
|
|
325
|
-
export const MuiButtonGroup = (theme: Theme): Components["MuiButtonGroup"] => {
|
|
326
|
-
return {
|
|
327
|
-
defaultProps: {
|
|
328
|
-
disableElevation: true,
|
|
329
|
-
disableRipple: true,
|
|
330
|
-
},
|
|
331
|
-
styleOverrides: {
|
|
332
|
-
grouped: {
|
|
333
|
-
minWidth: 0,
|
|
334
|
-
padding: "6px 8px",
|
|
335
|
-
},
|
|
336
|
-
groupedContainedPrimary: {
|
|
337
|
-
borderColor: theme.palette.primary.dark,
|
|
338
|
-
boxShadow: `0 1px 0 0 ${theme.palette.primary.dark}`,
|
|
339
|
-
// eslint-disable-next-line sort-keys -- disabling key order for readability
|
|
340
|
-
"&:hover": {
|
|
341
|
-
boxShadow: `0 1px 0 0 ${theme.palette.primary.dark}`,
|
|
342
|
-
},
|
|
343
|
-
// eslint-disable-next-line sort-keys -- disabling key order for readability
|
|
344
|
-
"&:active": {
|
|
345
|
-
boxShadow: "none",
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
},
|
|
349
|
-
};
|
|
350
|
-
};
|
|
351
|
-
|
|
352
337
|
/**
|
|
353
338
|
* MuiCard Component
|
|
354
339
|
*/
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Components } from "@mui/material";
|
|
2
|
+
import { COLOR_MIXES } from "../../styles/common/constants/colorMixes";
|
|
3
|
+
import { PALETTE } from "../../styles/common/constants/palette";
|
|
4
|
+
import { BUTTON_GROUP_PROPS } from "../../styles/common/mui/buttonGroup";
|
|
5
|
+
|
|
6
|
+
const SELECTORS = {
|
|
7
|
+
GROUPED: `.${BUTTON_GROUP_PROPS.CLASSES.GROUPED}`,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const MuiButtonGroup: Components["MuiButtonGroup"] = {
|
|
11
|
+
defaultProps: {
|
|
12
|
+
disableElevation: true,
|
|
13
|
+
disableRipple: true,
|
|
14
|
+
},
|
|
15
|
+
styleOverrides: {
|
|
16
|
+
root: {
|
|
17
|
+
variants: [
|
|
18
|
+
/* PRIMARY CONTAINED */
|
|
19
|
+
{
|
|
20
|
+
props: {
|
|
21
|
+
color: BUTTON_GROUP_PROPS.COLOR.PRIMARY,
|
|
22
|
+
variant: BUTTON_GROUP_PROPS.VARIANT.CONTAINED,
|
|
23
|
+
},
|
|
24
|
+
style: {
|
|
25
|
+
[SELECTORS.GROUPED]: {
|
|
26
|
+
borderColor: PALETTE.PRIMARY_DARK,
|
|
27
|
+
boxShadow: `0 1px 0 0 ${PALETTE.PRIMARY_DARK}`,
|
|
28
|
+
minWidth: 0,
|
|
29
|
+
// eslint-disable-next-line sort-keys -- disabling key order for readability
|
|
30
|
+
"&:hover": {
|
|
31
|
+
boxShadow: `0 1px 0 0 ${PALETTE.PRIMARY_DARK}`,
|
|
32
|
+
},
|
|
33
|
+
// eslint-disable-next-line sort-keys -- disabling key order for readability
|
|
34
|
+
"&:active": {
|
|
35
|
+
boxShadow: "none",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
/* SECONDARY OUTLINED */
|
|
41
|
+
{
|
|
42
|
+
props: {
|
|
43
|
+
color: BUTTON_GROUP_PROPS.COLOR.SECONDARY,
|
|
44
|
+
variant: BUTTON_GROUP_PROPS.VARIANT.OUTLINED,
|
|
45
|
+
},
|
|
46
|
+
style: {
|
|
47
|
+
[SELECTORS.GROUPED]: {
|
|
48
|
+
backgroundColor: PALETTE.COMMON_WHITE,
|
|
49
|
+
boxShadow: `inset 0 0 0 1px ${PALETTE.SMOKE_DARK}, 0 1px 0 0 ${COLOR_MIXES.COMMON_BLACK_08}`,
|
|
50
|
+
color: PALETTE.INK_MAIN,
|
|
51
|
+
minWidth: 0,
|
|
52
|
+
// eslint-disable-next-line sort-keys -- disabling key order for readability
|
|
53
|
+
"&:hover": {
|
|
54
|
+
backgroundColor: PALETTE.SMOKE_LIGHTEST,
|
|
55
|
+
boxShadow: `inset 0 0 0 1px ${PALETTE.SMOKE_DARK}, 0 1px 0 0 ${COLOR_MIXES.COMMON_BLACK_08}`,
|
|
56
|
+
},
|
|
57
|
+
// eslint-disable-next-line sort-keys -- disabling key order for readability
|
|
58
|
+
"&:active": {
|
|
59
|
+
backgroundColor: PALETTE.SMOKE_LIGHTEST,
|
|
60
|
+
boxShadow: `inset 0 0 0 1px ${PALETTE.SMOKE_DARK}`,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
/* SMALL */
|
|
66
|
+
{
|
|
67
|
+
props: {
|
|
68
|
+
size: BUTTON_GROUP_PROPS.SIZE.SMALL,
|
|
69
|
+
},
|
|
70
|
+
style: {
|
|
71
|
+
[SELECTORS.GROUPED]: {
|
|
72
|
+
padding: "6px 8px",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
};
|
package/src/theme/theme.ts
CHANGED
|
@@ -80,7 +80,7 @@ export function createAppTheme(customOptions: ThemeOptions = {}): Theme {
|
|
|
80
80
|
MuiBreadcrumbs: C.MuiBreadcrumbs(theme),
|
|
81
81
|
MuiButton: C.MuiButton(theme),
|
|
82
82
|
MuiButtonBase: C.MuiButtonBase(theme),
|
|
83
|
-
MuiButtonGroup:
|
|
83
|
+
MuiButtonGroup: M.MuiButtonGroup,
|
|
84
84
|
MuiCard: C.MuiCard,
|
|
85
85
|
MuiCheckbox: C.MuiCheckbox(theme),
|
|
86
86
|
MuiChip: C.MuiChip(theme),
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { matchers } from "@emotion/jest";
|
|
2
|
+
import { jest } from "@jest/globals";
|
|
3
|
+
import { composeStories } from "@storybook/react";
|
|
4
|
+
import { waitFor } from "@storybook/test";
|
|
5
|
+
import "@testing-library/jest-dom";
|
|
6
|
+
import { fireEvent, render, screen, within } from "@testing-library/react";
|
|
7
|
+
import React from "react";
|
|
8
|
+
import * as stories from "../src/components/DataDictionary/components/Filters/stories/filters.stories";
|
|
9
|
+
import { MUI_CLASSES } from "../src/tests/mui/constants";
|
|
10
|
+
import {
|
|
11
|
+
getButton,
|
|
12
|
+
getRole,
|
|
13
|
+
getStartsWithRegex,
|
|
14
|
+
getText,
|
|
15
|
+
} from "../src/tests/utils";
|
|
16
|
+
|
|
17
|
+
expect.extend(matchers);
|
|
18
|
+
|
|
19
|
+
const { Default } = composeStories(stories);
|
|
20
|
+
|
|
21
|
+
describe("DataDictionaryColumnFilters", () => {
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
jest.clearAllMocks();
|
|
24
|
+
render(<Default />);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("renders correctly", async () => {
|
|
28
|
+
expect(await screen.findByText("Required")).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("renders all filterable column headers", async () => {
|
|
32
|
+
expect(await screen.findByText("Required")).toBeInTheDocument();
|
|
33
|
+
expect(await screen.findByText("BioNetwork")).toBeInTheDocument();
|
|
34
|
+
expect(screen.queryByText("Example")).not.toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("renders BioNetwork filter options", async () => {
|
|
38
|
+
const buttonEl = getButton("BioNetwork");
|
|
39
|
+
fireEvent.click(buttonEl);
|
|
40
|
+
// Wait for menu to open.
|
|
41
|
+
await waitFor(() => expect(getRole("menu")).toBeInTheDocument());
|
|
42
|
+
expect(getText("Brain")).toBeInTheDocument();
|
|
43
|
+
expect(getText("Lung")).toBeInTheDocument();
|
|
44
|
+
expect(getText("Nervous System")).toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("renders BioNetwork filter options in alphabetical order", async () => {
|
|
48
|
+
const buttonEl = getButton("BioNetwork");
|
|
49
|
+
fireEvent.click(buttonEl);
|
|
50
|
+
// Wait for menu to open.
|
|
51
|
+
await waitFor(() => expect(getRole("menu")).toBeInTheDocument());
|
|
52
|
+
const optionEls = within(getRole("menu")).getAllByRole("button");
|
|
53
|
+
["Brain", "Lung", "Nervous System", "Clear All"].forEach((expected, i) => {
|
|
54
|
+
expect(optionEls[i].textContent).toMatch(getStartsWithRegex(expected));
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("can select and deselect a filter option", async () => {
|
|
59
|
+
const buttonEl = getButton("BioNetwork");
|
|
60
|
+
fireEvent.click(buttonEl);
|
|
61
|
+
// Wait for menu to open.
|
|
62
|
+
await waitFor(() => expect(getRole("menu")).toBeInTheDocument());
|
|
63
|
+
// Select first option.
|
|
64
|
+
const optionEls = within(getRole("menu")).getAllByRole("button");
|
|
65
|
+
const optionEl = optionEls[0];
|
|
66
|
+
fireEvent.click(optionEl);
|
|
67
|
+
await waitFor(() => expect(optionEl).toHaveClass(MUI_CLASSES.SELECTED));
|
|
68
|
+
// Deselect first option.
|
|
69
|
+
fireEvent.click(optionEl);
|
|
70
|
+
await waitFor(() => expect(optionEl).not.toHaveClass(MUI_CLASSES.SELECTED));
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("clears all filters", async () => {
|
|
74
|
+
const buttonEl = getButton("BioNetwork");
|
|
75
|
+
fireEvent.click(buttonEl);
|
|
76
|
+
// Wait for menu to open.
|
|
77
|
+
await waitFor(() => expect(getRole("menu")).toBeInTheDocument());
|
|
78
|
+
// Select all options.
|
|
79
|
+
const optionEls = within(getRole("menu")).getAllByRole("button");
|
|
80
|
+
optionEls.forEach(async (el) => {
|
|
81
|
+
fireEvent.click(el);
|
|
82
|
+
await waitFor(() => expect(el).toHaveClass(MUI_CLASSES.SELECTED));
|
|
83
|
+
});
|
|
84
|
+
// Select "Clear All" button.
|
|
85
|
+
const clearEl = getButton("Clear All");
|
|
86
|
+
fireEvent.click(clearEl);
|
|
87
|
+
// Wait for options to be deselected.
|
|
88
|
+
await waitFor(() =>
|
|
89
|
+
optionEls.forEach((el) =>
|
|
90
|
+
expect(el).not.toHaveClass(MUI_CLASSES.SELECTED)
|
|
91
|
+
)
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("disables Clear All when nothing selected", async () => {
|
|
96
|
+
const buttonEl = getButton("BioNetwork");
|
|
97
|
+
fireEvent.click(buttonEl);
|
|
98
|
+
await waitFor(() => expect(getRole("menu")).toBeInTheDocument());
|
|
99
|
+
expect(getButton("Clear All")).toHaveClass(MUI_CLASSES.DISABLED);
|
|
100
|
+
});
|
|
101
|
+
});
|