@databiosphere/findable-ui 50.5.0 → 50.6.1
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/lib/components/Export/components/ExportMethod/constants.d.ts +2 -0
- package/lib/components/Export/components/ExportMethod/constants.js +6 -0
- package/lib/components/Export/components/ExportMethod/exportMethod.d.ts +2 -1
- package/lib/components/Export/components/ExportMethod/exportMethod.js +6 -4
- package/lib/components/Export/components/ExportMethod/exportMethod.styles.d.ts +8 -2
- package/lib/components/Export/components/ExportMethod/exportMethod.styles.js +4 -6
- package/package.json +6 -1
- package/src/components/Export/components/ExportMethod/constants.ts +8 -0
- package/src/components/Export/components/ExportMethod/exportMethod.styles.ts +10 -8
- package/src/components/Export/components/ExportMethod/exportMethod.tsx +13 -4
- package/.eslintignore +0 -5
- package/.eslintrc.json +0 -79
- package/.github/copilot-instructions.md +0 -176
- package/.github/workflows/release-please.yml +0 -49
- package/.github/workflows/run-checks.yml +0 -57
- package/.husky/commit-msg +0 -18
- package/.husky/pre-commit +0 -43
- package/.prettierignore +0 -19
- package/.prettierrc.json +0 -1
- package/.release-please-manifest.json +0 -3
- package/.storybook/main.ts +0 -10
- package/.storybook/preview-head.html +0 -4
- package/.storybook/preview.js +0 -6
- package/CHANGELOG.md +0 -1110
- package/CLAUDE.md +0 -214
- package/backend/README.md +0 -64
- package/backend/__init__.py +0 -0
- package/backend/controllers/__init__.py +0 -0
- package/backend/controllers/facets_controller.py +0 -16
- package/backend/controllers/models.py +0 -11
- package/backend/main.py +0 -8
- package/backend/requirements.txt +0 -4
- package/backend/services/__init__.py +0 -0
- package/backend/services/facets_service.py +0 -68
- package/backend/services/models.py +0 -43
- package/commitlint.config.js +0 -1
- package/docs/TRUSTED_PUBLISHING.md +0 -132
- package/jest.config.js +0 -6
- package/release-please-config.json +0 -23
- package/tests/azulFileDownload.test.tsx +0 -96
- package/tests/buildCategoryViews.test.ts +0 -282
- package/tests/buildRequestFilters.test.ts +0 -60
- package/tests/buildRequestManifest.test.ts +0 -103
- package/tests/chart.test.tsx +0 -274
- package/tests/chartSortUtils.test.ts +0 -119
- package/tests/chartView.test.tsx +0 -48
- package/tests/dataDictionaryColumnFilters.test.tsx +0 -101
- package/tests/dataDictionary_utils.test.ts +0 -153
- package/tests/fetchApi.test.ts +0 -93
- package/tests/filter.test.tsx +0 -100
- package/tests/filterMenu.test.ts +0 -100
- package/tests/filterRange.test.tsx +0 -372
- package/tests/filterSortUtils.test.ts +0 -180
- package/tests/filters.test.tsx +0 -61
- package/tests/getFacetedMinMaxValues.test.ts +0 -166
- package/tests/getFilterSortType.test.ts +0 -45
- package/tests/getProfileStatus.test.ts +0 -290
- package/tests/linkCell.test.tsx +0 -89
- package/tests/markdownCell.test.tsx +0 -52
- package/tests/provider.test.tsx +0 -189
- package/tests/research.chatState.test.ts +0 -463
- package/tests/research.fetchResponse.test.ts +0 -164
- package/tests/research.queryProvider.test.ts +0 -321
- package/tests/research.useKeyShortCuts.test.ts +0 -256
- package/tests/rowSelectionValidation.test.ts +0 -282
- package/tests/setup.ts +0 -19
- package/tests/stepIcon.test.tsx +0 -42
- package/tests/tableFilter.test.tsx +0 -90
- package/tests/terraProfileProvider.test.tsx +0 -117
- package/tests/theme.test.ts +0 -465
- package/tests/toggleButtonGroupProvider.test.tsx +0 -125
- package/tests/transformRoute.test.ts +0 -21
- package/tests/tsconfig.json +0 -8
- package/tests/useFileLocation.test.ts +0 -36
- package/tests/useRequestManifest.test.ts +0 -201
- package/tests/useRouteHistory.test.ts +0 -97
- package/tests/useSessionActive.test.ts +0 -106
- package/tests/useWindowResize.test.ts +0 -130
- package/tests/viewModelBuilders_utils.test.ts +0 -58
- package/tests/viewToggle.test.tsx +0 -54
- package/tsconfig.json +0 -25
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
import { jest } from "@jest/globals";
|
|
2
|
-
import {
|
|
3
|
-
createColumnHelper,
|
|
4
|
-
getCoreRowModel,
|
|
5
|
-
Row,
|
|
6
|
-
Table,
|
|
7
|
-
TableOptions,
|
|
8
|
-
useReactTable,
|
|
9
|
-
} from "@tanstack/react-table";
|
|
10
|
-
import { renderHook, RenderHookResult } from "@testing-library/react";
|
|
11
|
-
import { ROW_SELECTION_VALIDATION } from "../src/components/Table/features/RowSelectionValidation/constants";
|
|
12
|
-
import { RowSelectionValidationOptions } from "../src/components/Table/features/RowSelectionValidation/types";
|
|
13
|
-
import { getSelectionValidation } from "../src/components/Table/features/RowSelectionValidation/utils";
|
|
14
|
-
|
|
15
|
-
type ValidationFn = NonNullable<
|
|
16
|
-
RowSelectionValidationOptions<RowData>["getRowSelectionValidation"]
|
|
17
|
-
>;
|
|
18
|
-
|
|
19
|
-
interface RowData {
|
|
20
|
-
id: number;
|
|
21
|
-
isValid: boolean;
|
|
22
|
-
name: string;
|
|
23
|
-
status: "active" | "inactive";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const ACCESSOR_KEY: Record<string, keyof RowData> = {
|
|
27
|
-
ID: "id",
|
|
28
|
-
IS_VALID: "isValid",
|
|
29
|
-
NAME: "name",
|
|
30
|
-
STATUS: "status",
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// Mock data.
|
|
34
|
-
const DATA: RowData[] = [
|
|
35
|
-
{ id: 1, isValid: true, name: "Item 1", status: "active" },
|
|
36
|
-
{ id: 2, isValid: false, name: "Item 2", status: "inactive" },
|
|
37
|
-
{ id: 3, isValid: true, name: "Item 3", status: "active" },
|
|
38
|
-
{ id: 4, isValid: false, name: "Item 4", status: "inactive" },
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
const columnHelper = createColumnHelper<RowData>();
|
|
42
|
-
|
|
43
|
-
// Mock column definitions.
|
|
44
|
-
const COLUMNS = [
|
|
45
|
-
columnHelper.accessor(ACCESSOR_KEY.ID, { header: "ID" }),
|
|
46
|
-
columnHelper.accessor(ACCESSOR_KEY.NAME, { header: "Name" }),
|
|
47
|
-
columnHelper.accessor(ACCESSOR_KEY.IS_VALID, { header: "Valid" }),
|
|
48
|
-
columnHelper.accessor(ACCESSOR_KEY.STATUS, { header: "Status" }),
|
|
49
|
-
];
|
|
50
|
-
|
|
51
|
-
// Test constants.
|
|
52
|
-
const VALIDATION_MESSAGE = {
|
|
53
|
-
INVALID: "This item is invalid",
|
|
54
|
-
VALID: "This item is valid",
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const createTable = (
|
|
58
|
-
tableOptions?: Omit<
|
|
59
|
-
TableOptions<RowData>,
|
|
60
|
-
"columns" | "data" | "getCoreRowModel"
|
|
61
|
-
>,
|
|
62
|
-
): RenderHookResult<Table<RowData>, unknown> => {
|
|
63
|
-
return renderHook(() =>
|
|
64
|
-
useReactTable({
|
|
65
|
-
_features: [ROW_SELECTION_VALIDATION],
|
|
66
|
-
columns: COLUMNS,
|
|
67
|
-
data: DATA,
|
|
68
|
-
enableRowSelectionValidation: true,
|
|
69
|
-
getCoreRowModel: getCoreRowModel(),
|
|
70
|
-
...tableOptions,
|
|
71
|
-
}),
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
describe("RowSelectionValidation Feature", () => {
|
|
76
|
-
let tableWithoutValidation: any;
|
|
77
|
-
let firstRowWithoutValidation: any;
|
|
78
|
-
let tableWithValidation: any;
|
|
79
|
-
let firstRowWithValidation: any;
|
|
80
|
-
|
|
81
|
-
beforeEach(() => {
|
|
82
|
-
const resultWithoutValidation = createTable();
|
|
83
|
-
const resultWithValidation = createTable({
|
|
84
|
-
getRowSelectionValidation: () => VALIDATION_MESSAGE.INVALID,
|
|
85
|
-
});
|
|
86
|
-
tableWithoutValidation = resultWithoutValidation.result.current;
|
|
87
|
-
firstRowWithoutValidation = tableWithoutValidation.getRowModel().rows[0];
|
|
88
|
-
tableWithValidation = resultWithValidation.result.current;
|
|
89
|
-
firstRowWithValidation = tableWithValidation.getRowModel().rows[0];
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
describe("ROW_SELECTION_VALIDATION TableFeature", () => {
|
|
93
|
-
test("should have correct structure", () => {
|
|
94
|
-
expect(ROW_SELECTION_VALIDATION).toHaveProperty("createRow");
|
|
95
|
-
expect(ROW_SELECTION_VALIDATION).toHaveProperty("getDefaultOptions");
|
|
96
|
-
expect(typeof ROW_SELECTION_VALIDATION.createRow).toBe("function");
|
|
97
|
-
expect(typeof ROW_SELECTION_VALIDATION.getDefaultOptions).toBe(
|
|
98
|
-
"function",
|
|
99
|
-
);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
test("getDefaultOptions should return correct default options", () => {
|
|
103
|
-
const { getDefaultOptions } = ROW_SELECTION_VALIDATION;
|
|
104
|
-
expect(getDefaultOptions!(tableWithoutValidation)).toEqual({
|
|
105
|
-
enableRowSelectionValidation: false,
|
|
106
|
-
getRowSelectionValidation: undefined,
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe("getSelectionValidation utility", () => {
|
|
112
|
-
test("should return undefined when no validation function is provided", () => {
|
|
113
|
-
expect(
|
|
114
|
-
getSelectionValidation(
|
|
115
|
-
firstRowWithoutValidation,
|
|
116
|
-
tableWithoutValidation,
|
|
117
|
-
),
|
|
118
|
-
).toBeUndefined();
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
test("should return validation message when validation function is provided", () => {
|
|
122
|
-
expect(
|
|
123
|
-
getSelectionValidation(firstRowWithValidation, tableWithValidation),
|
|
124
|
-
).toBe(VALIDATION_MESSAGE.INVALID);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
test("should return undefined when validation function returns undefined", () => {
|
|
128
|
-
const getRowSelectionValidation = jest
|
|
129
|
-
.fn<ValidationFn>()
|
|
130
|
-
.mockReturnValue(undefined);
|
|
131
|
-
|
|
132
|
-
const { result } = createTable({ getRowSelectionValidation });
|
|
133
|
-
|
|
134
|
-
const table = result.current;
|
|
135
|
-
const firstRow = table.getRowModel().rows[0];
|
|
136
|
-
|
|
137
|
-
const validationResult = getSelectionValidation(firstRow, table);
|
|
138
|
-
|
|
139
|
-
expect(validationResult).toBeUndefined();
|
|
140
|
-
expect(getRowSelectionValidation).toHaveBeenCalledWith(firstRow);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
test("should work with different rows from the same table", () => {
|
|
144
|
-
const getRowSelectionValidation = jest
|
|
145
|
-
.fn<ValidationFn>()
|
|
146
|
-
.mockImplementation((row) => {
|
|
147
|
-
const status = row.getValue(ACCESSOR_KEY.STATUS);
|
|
148
|
-
return status === "inactive" ? VALIDATION_MESSAGE.INVALID : undefined;
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
const { result } = createTable({ getRowSelectionValidation });
|
|
152
|
-
|
|
153
|
-
const table = result.current;
|
|
154
|
-
const rows = table.getRowModel().rows;
|
|
155
|
-
|
|
156
|
-
expect(getSelectionValidation(rows[0], table)).toBeUndefined();
|
|
157
|
-
expect(getSelectionValidation(rows[2], table)).toBeUndefined();
|
|
158
|
-
expect(getSelectionValidation(rows[1], table)).toBe(
|
|
159
|
-
VALIDATION_MESSAGE.INVALID,
|
|
160
|
-
);
|
|
161
|
-
expect(getRowSelectionValidation).toHaveBeenCalledTimes(3);
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
describe("row.getSelectionValidation method", () => {
|
|
166
|
-
test("should be attached to rows when feature is included", () => {
|
|
167
|
-
const rows = tableWithoutValidation.getRowModel().rows;
|
|
168
|
-
|
|
169
|
-
rows.forEach((row: any) => {
|
|
170
|
-
expect(row).toHaveProperty("getSelectionValidation");
|
|
171
|
-
expect(typeof row.getSelectionValidation).toBe("function");
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
test("should return undefined when no validation function is configured", () => {
|
|
176
|
-
expect(
|
|
177
|
-
firstRowWithoutValidation.getSelectionValidation(),
|
|
178
|
-
).toBeUndefined();
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
test("should return validation message when validation function is configured", () => {
|
|
182
|
-
expect(firstRowWithValidation.getSelectionValidation()).toBe(
|
|
183
|
-
VALIDATION_MESSAGE.INVALID,
|
|
184
|
-
);
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
describe("Integration with table options", () => {
|
|
189
|
-
test("should work with getRowSelectionValidation function", () => {
|
|
190
|
-
const enableRowSelection = jest
|
|
191
|
-
.fn<(row: Row<RowData>) => boolean>()
|
|
192
|
-
.mockImplementation((row) => row.getValue(ACCESSOR_KEY.IS_VALID));
|
|
193
|
-
|
|
194
|
-
const getRowSelectionValidation = jest
|
|
195
|
-
.fn<ValidationFn>()
|
|
196
|
-
.mockImplementation((row) => {
|
|
197
|
-
const isValid = row.getValue(ACCESSOR_KEY.IS_VALID);
|
|
198
|
-
return isValid ? undefined : VALIDATION_MESSAGE.INVALID;
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
const { result } = createTable({
|
|
202
|
-
enableRowSelection,
|
|
203
|
-
getRowSelectionValidation,
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
const table = result.current;
|
|
207
|
-
const rows = table.getRowModel().rows;
|
|
208
|
-
|
|
209
|
-
rows.forEach((row) => {
|
|
210
|
-
const isValid = row.getValue(ACCESSOR_KEY.IS_VALID);
|
|
211
|
-
const canSelect = row.getCanSelect();
|
|
212
|
-
const validationMessage = row.getSelectionValidation?.();
|
|
213
|
-
|
|
214
|
-
if (isValid) {
|
|
215
|
-
expect(canSelect).toBe(true);
|
|
216
|
-
expect(validationMessage).toBeUndefined();
|
|
217
|
-
} else {
|
|
218
|
-
expect(canSelect).toBe(false);
|
|
219
|
-
expect(validationMessage).toBe(VALIDATION_MESSAGE.INVALID);
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
test("should handle complex validation scenarios", () => {
|
|
225
|
-
const getRowSelectionValidation = jest
|
|
226
|
-
.fn<ValidationFn>()
|
|
227
|
-
.mockImplementation((row) => {
|
|
228
|
-
const id = row.getValue(ACCESSOR_KEY.ID);
|
|
229
|
-
const isValid = row.getValue(ACCESSOR_KEY.IS_VALID);
|
|
230
|
-
|
|
231
|
-
if (!isValid) return VALIDATION_MESSAGE.INVALID;
|
|
232
|
-
if (id === 1) return VALIDATION_MESSAGE.VALID;
|
|
233
|
-
return undefined;
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
const { result } = createTable({ getRowSelectionValidation });
|
|
237
|
-
|
|
238
|
-
const table = result.current;
|
|
239
|
-
const rows = table.getRowModel().rows;
|
|
240
|
-
|
|
241
|
-
expect(rows[0].getSelectionValidation?.()).toBe(VALIDATION_MESSAGE.VALID);
|
|
242
|
-
expect(rows[1].getSelectionValidation?.()).toBe(
|
|
243
|
-
VALIDATION_MESSAGE.INVALID,
|
|
244
|
-
);
|
|
245
|
-
expect(rows[2].getSelectionValidation?.()).toBeUndefined();
|
|
246
|
-
expect(rows[3].getSelectionValidation?.()).toBe(
|
|
247
|
-
VALIDATION_MESSAGE.INVALID,
|
|
248
|
-
);
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
describe("Edge cases", () => {
|
|
253
|
-
test("should work when feature is not included", () => {
|
|
254
|
-
const { result } = createTable({
|
|
255
|
-
_features: [],
|
|
256
|
-
enableRowSelectionValidation: false,
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
const table = result.current;
|
|
260
|
-
const firstRow = table.getRowModel().rows[0];
|
|
261
|
-
|
|
262
|
-
expect(firstRow).not.toHaveProperty("getSelectionValidation");
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
test("should return undefined when feature is disabled", () => {
|
|
266
|
-
const getRowSelectionValidation = jest
|
|
267
|
-
.fn<ValidationFn>()
|
|
268
|
-
.mockReturnValue(VALIDATION_MESSAGE.INVALID);
|
|
269
|
-
|
|
270
|
-
const { result } = createTable({
|
|
271
|
-
enableRowSelectionValidation: false,
|
|
272
|
-
getRowSelectionValidation,
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
const table = result.current;
|
|
276
|
-
const firstRow = table.getRowModel().rows[0];
|
|
277
|
-
|
|
278
|
-
expect(firstRow.getSelectionValidation?.()).toBeUndefined();
|
|
279
|
-
expect(getRowSelectionValidation).not.toHaveBeenCalled();
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
});
|
package/tests/setup.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { jest } from "@jest/globals";
|
|
2
|
-
import { setProjectAnnotations } from "@storybook/react";
|
|
3
|
-
import { TextDecoder, TextEncoder } from "util";
|
|
4
|
-
import { decorators } from "../src/storybook/decorators";
|
|
5
|
-
import { parameters } from "../src/storybook/parameters";
|
|
6
|
-
|
|
7
|
-
// Set project annotations once before all tests
|
|
8
|
-
setProjectAnnotations({ decorators, parameters });
|
|
9
|
-
|
|
10
|
-
// Polyfill ResizeObserver for environments (like Jest) where it's not globally available
|
|
11
|
-
global.ResizeObserver = jest.fn().mockImplementation(() => ({
|
|
12
|
-
disconnect: jest.fn(),
|
|
13
|
-
observe: jest.fn(),
|
|
14
|
-
unobserve: jest.fn(),
|
|
15
|
-
})) as unknown as typeof ResizeObserver;
|
|
16
|
-
|
|
17
|
-
// Polyfill TextEncoder/TextDecoder for environments (like Jest) where they're not globally available
|
|
18
|
-
global.TextEncoder = global.TextEncoder || TextEncoder;
|
|
19
|
-
global.TextDecoder = global.TextDecoder || TextDecoder;
|
package/tests/stepIcon.test.tsx
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { composeStories } from "@storybook/react";
|
|
2
|
-
import { render, screen } from "@testing-library/react";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { STEP_ICON_TEST_ID } from "../src/components/Stepper/components/Step/components/StepIcon/constants";
|
|
5
|
-
import * as stories from "../src/components/Stepper/components/Step/components/StepIcon/stories/stepIcon.stories";
|
|
6
|
-
import { MUI_CLASSES } from "../src/tests/mui/constants";
|
|
7
|
-
import { getClassNames, getTagName } from "../src/utils/tests";
|
|
8
|
-
|
|
9
|
-
const { Active, Completed, Default } = composeStories(stories);
|
|
10
|
-
|
|
11
|
-
describe("StepIcon", () => {
|
|
12
|
-
it("renders correctly", () => {
|
|
13
|
-
render(<Default testId={STEP_ICON_TEST_ID} />);
|
|
14
|
-
const stepIconEl = screen.getByTestId(STEP_ICON_TEST_ID);
|
|
15
|
-
expect(stepIconEl).not.toBeNull();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("renders inactive step icon", () => {
|
|
19
|
-
render(<Default testId={STEP_ICON_TEST_ID} />);
|
|
20
|
-
const stepIconEl = screen.getByTestId(STEP_ICON_TEST_ID);
|
|
21
|
-
expect(stepIconEl.textContent).toEqual("1");
|
|
22
|
-
expect(getClassNames(stepIconEl)).not.toContain(MUI_CLASSES.ACTIVE);
|
|
23
|
-
expect(getClassNames(stepIconEl)).not.toContain(MUI_CLASSES.COMPLETED);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("renders active step icon", () => {
|
|
27
|
-
render(<Active testId={STEP_ICON_TEST_ID} />);
|
|
28
|
-
const stepIconEl = screen.getByTestId(STEP_ICON_TEST_ID);
|
|
29
|
-
expect(stepIconEl.textContent).toEqual("1");
|
|
30
|
-
expect(getClassNames(stepIconEl)).toContain(MUI_CLASSES.ACTIVE);
|
|
31
|
-
expect(getClassNames(stepIconEl)).not.toContain(MUI_CLASSES.COMPLETED);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("renders completed step icon", () => {
|
|
35
|
-
render(<Completed testId={STEP_ICON_TEST_ID} />);
|
|
36
|
-
const stepIconEl = screen.getByTestId(STEP_ICON_TEST_ID);
|
|
37
|
-
expect(stepIconEl.textContent).not.toEqual("1");
|
|
38
|
-
expect(getClassNames(stepIconEl)).not.toContain(MUI_CLASSES.ACTIVE);
|
|
39
|
-
expect(getClassNames(stepIconEl)).toContain(MUI_CLASSES.COMPLETED);
|
|
40
|
-
expect(getTagName(stepIconEl.firstElementChild)).toBe("path");
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { composeStories } from "@storybook/react";
|
|
2
|
-
import { render } from "@testing-library/react";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import * as filterStories from "../src/components/Detail/components/Table/stories/filter/filter.stories";
|
|
5
|
-
|
|
6
|
-
const COLUMN_INDEX = {
|
|
7
|
-
ARRAY: 1,
|
|
8
|
-
NUMBER: 3,
|
|
9
|
-
STRING: 0,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const {
|
|
13
|
-
FilterByArrayValue,
|
|
14
|
-
FilterByRangeBetweenValue,
|
|
15
|
-
FilterByRangeGreaterThanValue,
|
|
16
|
-
FilterByRangeLessThanValue,
|
|
17
|
-
FilterByStringValue,
|
|
18
|
-
FilterByStringValueWithNoMatch,
|
|
19
|
-
} = composeStories(filterStories);
|
|
20
|
-
|
|
21
|
-
describe("Table - Filtering", () => {
|
|
22
|
-
describe("Table filter stories", () => {
|
|
23
|
-
test("FilterByStringValueWithNoMatch shows no rows", () => {
|
|
24
|
-
const { container } = render(<FilterByStringValueWithNoMatch />);
|
|
25
|
-
const rows = container.querySelectorAll("tbody tr");
|
|
26
|
-
expect(rows).toHaveLength(0);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test("FilterByStringValue shows rows matching the filters of string values", () => {
|
|
30
|
-
const { container } = render(<FilterByStringValue />);
|
|
31
|
-
const rows = container.querySelectorAll("tbody tr");
|
|
32
|
-
expect(rows).toHaveLength(2);
|
|
33
|
-
rows.forEach((row) => {
|
|
34
|
-
const cell = row.querySelectorAll("td")[COLUMN_INDEX.STRING];
|
|
35
|
-
const text = cell.textContent;
|
|
36
|
-
expect(text).toMatch(
|
|
37
|
-
/Coronary Artery Disease Study|Myocardial Infarction Study/,
|
|
38
|
-
);
|
|
39
|
-
expect(text).not.toMatch(/Myocardial Infarction Study X/);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test("FilterByArrayValue shows rows matching the filters of array values", () => {
|
|
44
|
-
const { container } = render(<FilterByArrayValue />);
|
|
45
|
-
const rows = container.querySelectorAll("tbody tr");
|
|
46
|
-
expect(rows).toHaveLength(4);
|
|
47
|
-
rows.forEach((row) => {
|
|
48
|
-
const cell = row.querySelectorAll("td")[COLUMN_INDEX.ARRAY];
|
|
49
|
-
const text = cell.textContent;
|
|
50
|
-
expect(text).toMatch(/Exome|RNAseq/);
|
|
51
|
-
// Confirm that the text "Whole Genome" is not present in any row cell as a single value.
|
|
52
|
-
expect(text).not.toMatch(/^Whole Genome$/);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test("FilterByRangeBetweenValue shows rows matching filters between two number values", () => {
|
|
57
|
-
const { container } = render(<FilterByRangeBetweenValue />);
|
|
58
|
-
const rows = container.querySelectorAll("tbody tr");
|
|
59
|
-
expect(rows).toHaveLength(2);
|
|
60
|
-
rows.forEach((row) => {
|
|
61
|
-
const cell = row.querySelectorAll("td")[COLUMN_INDEX.NUMBER];
|
|
62
|
-
const value = Number(cell.textContent);
|
|
63
|
-
expect(value).toBeGreaterThanOrEqual(10);
|
|
64
|
-
expect(value).toBeLessThanOrEqual(100);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test("FilterByRangeGreaterThanValue shows rows matching filters greater than a number value", () => {
|
|
69
|
-
const { container } = render(<FilterByRangeGreaterThanValue />);
|
|
70
|
-
const rows = container.querySelectorAll("tbody tr");
|
|
71
|
-
expect(rows).toHaveLength(4);
|
|
72
|
-
rows.forEach((row) => {
|
|
73
|
-
const cell = row.querySelectorAll("td")[COLUMN_INDEX.NUMBER];
|
|
74
|
-
const value = Number(cell.textContent);
|
|
75
|
-
expect(value).toBeGreaterThanOrEqual(100);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test("FilterByRangeLessThanValue shows rows matching filters less than a number value", () => {
|
|
80
|
-
const { container } = render(<FilterByRangeLessThanValue />);
|
|
81
|
-
const rows = container.querySelectorAll("tbody tr");
|
|
82
|
-
expect(rows).toHaveLength(3);
|
|
83
|
-
rows.forEach((row) => {
|
|
84
|
-
const cell = row.querySelectorAll("td")[COLUMN_INDEX.NUMBER];
|
|
85
|
-
const value = Number(cell.textContent);
|
|
86
|
-
expect(value).toBeLessThanOrEqual(100);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
});
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { jest } from "@jest/globals";
|
|
2
|
-
import { render } from "@testing-library/react";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { DEFAULT_AUTHENTICATION_STATE } from "../src/providers/authentication/authentication/constants";
|
|
5
|
-
import { authenticationComplete } from "../src/providers/authentication/authentication/dispatch";
|
|
6
|
-
import { DEFAULT_CREDENTIALS_STATE } from "../src/providers/authentication/credentials/constants";
|
|
7
|
-
import { updateCredentials } from "../src/providers/authentication/credentials/dispatch";
|
|
8
|
-
|
|
9
|
-
const TOKEN = "test-token";
|
|
10
|
-
|
|
11
|
-
const PROFILE_PENDING = {
|
|
12
|
-
isComplete: false,
|
|
13
|
-
isProfileActive: false,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const PROFILE_SETTLED_ACTIVE = {
|
|
17
|
-
isComplete: true,
|
|
18
|
-
isProfileActive: true,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const PROFILE_SETTLED_INACTIVE = {
|
|
22
|
-
isComplete: true,
|
|
23
|
-
isProfileActive: false,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
jest.unstable_mockModule(
|
|
27
|
-
"../src/providers/authentication/authentication/hook",
|
|
28
|
-
() => ({
|
|
29
|
-
useAuthentication: jest.fn(),
|
|
30
|
-
}),
|
|
31
|
-
);
|
|
32
|
-
jest.unstable_mockModule(
|
|
33
|
-
"../src/providers/authentication/credentials/hook",
|
|
34
|
-
() => ({
|
|
35
|
-
useCredentials: jest.fn(),
|
|
36
|
-
}),
|
|
37
|
-
);
|
|
38
|
-
jest.unstable_mockModule(
|
|
39
|
-
"../src/providers/authentication/terra/hooks/useFetchProfiles",
|
|
40
|
-
() => ({
|
|
41
|
-
useFetchProfiles: jest.fn(),
|
|
42
|
-
}),
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const { useAuthentication } =
|
|
46
|
-
await import("../src/providers/authentication/authentication/hook");
|
|
47
|
-
const { useCredentials } =
|
|
48
|
-
await import("../src/providers/authentication/credentials/hook");
|
|
49
|
-
const { useFetchProfiles } =
|
|
50
|
-
await import("../src/providers/authentication/terra/hooks/useFetchProfiles");
|
|
51
|
-
const { TerraProfileProvider } =
|
|
52
|
-
await import("../src/providers/authentication/terra/provider");
|
|
53
|
-
|
|
54
|
-
const MOCK_AUTHENTICATION_DISPATCH = jest.fn();
|
|
55
|
-
const MOCK_CREDENTIALS_DISPATCH = jest.fn();
|
|
56
|
-
const MOCK_USE_AUTHENTICATION = useAuthentication as jest.MockedFunction<
|
|
57
|
-
typeof useAuthentication
|
|
58
|
-
>;
|
|
59
|
-
const MOCK_USE_CREDENTIALS = useCredentials as jest.MockedFunction<
|
|
60
|
-
typeof useCredentials
|
|
61
|
-
>;
|
|
62
|
-
const MOCK_USE_FETCH_PROFILES = useFetchProfiles as jest.MockedFunction<
|
|
63
|
-
() => Partial<ReturnType<typeof useFetchProfiles>>
|
|
64
|
-
>;
|
|
65
|
-
|
|
66
|
-
describe("TerraProfileProvider", () => {
|
|
67
|
-
beforeEach(() => {
|
|
68
|
-
jest.clearAllMocks();
|
|
69
|
-
MOCK_USE_AUTHENTICATION.mockReturnValue({
|
|
70
|
-
authenticationDispatch: MOCK_AUTHENTICATION_DISPATCH,
|
|
71
|
-
authenticationState: DEFAULT_AUTHENTICATION_STATE,
|
|
72
|
-
});
|
|
73
|
-
MOCK_USE_CREDENTIALS.mockReturnValue({
|
|
74
|
-
credentialsDispatch: MOCK_CREDENTIALS_DISPATCH,
|
|
75
|
-
credentialsState: DEFAULT_CREDENTIALS_STATE,
|
|
76
|
-
});
|
|
77
|
-
MOCK_USE_FETCH_PROFILES.mockReturnValue(PROFILE_PENDING);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("does not dispatch actions when terra profile is incomplete", () => {
|
|
81
|
-
render(
|
|
82
|
-
<TerraProfileProvider token={TOKEN}>
|
|
83
|
-
<div>Child Component</div>
|
|
84
|
-
</TerraProfileProvider>,
|
|
85
|
-
);
|
|
86
|
-
expect(MOCK_AUTHENTICATION_DISPATCH).not.toHaveBeenCalled();
|
|
87
|
-
expect(MOCK_CREDENTIALS_DISPATCH).not.toHaveBeenCalled();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("calls authenticationComplete dispatch when terra profile is SETTLED and INACTIVE", () => {
|
|
91
|
-
MOCK_USE_FETCH_PROFILES.mockReturnValue(PROFILE_SETTLED_INACTIVE);
|
|
92
|
-
render(
|
|
93
|
-
<TerraProfileProvider token={TOKEN}>
|
|
94
|
-
<div>Child Component</div>
|
|
95
|
-
</TerraProfileProvider>,
|
|
96
|
-
);
|
|
97
|
-
expect(MOCK_AUTHENTICATION_DISPATCH).toHaveBeenCalledWith(
|
|
98
|
-
authenticationComplete(),
|
|
99
|
-
);
|
|
100
|
-
expect(MOCK_CREDENTIALS_DISPATCH).not.toHaveBeenCalled();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("dispatches authenticationComplete and updateCredentials when terra profile is SETTLED and ACTIVE", () => {
|
|
104
|
-
MOCK_USE_FETCH_PROFILES.mockReturnValue(PROFILE_SETTLED_ACTIVE);
|
|
105
|
-
render(
|
|
106
|
-
<TerraProfileProvider token={TOKEN}>
|
|
107
|
-
<div>Child Component</div>
|
|
108
|
-
</TerraProfileProvider>,
|
|
109
|
-
);
|
|
110
|
-
expect(MOCK_AUTHENTICATION_DISPATCH).toHaveBeenCalledWith(
|
|
111
|
-
authenticationComplete(),
|
|
112
|
-
);
|
|
113
|
-
expect(MOCK_CREDENTIALS_DISPATCH).toHaveBeenCalledWith(
|
|
114
|
-
updateCredentials(TOKEN),
|
|
115
|
-
);
|
|
116
|
-
});
|
|
117
|
-
});
|