@databiosphere/findable-ui 16.0.0 → 17.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 +18 -0
- package/lib/components/Export/components/DownloadCurlCommand/downloadCurlCommand.d.ts +3 -2
- package/lib/components/Export/components/DownloadCurlCommand/downloadCurlCommand.js +6 -4
- package/lib/components/Export/components/ExportForm/components/ExportManifestDownloadFormatForm/exportManifestDownloadFormatForm.d.ts +3 -2
- package/lib/components/Export/components/ExportForm/components/ExportManifestDownloadFormatForm/exportManifestDownloadFormatForm.js +2 -12
- package/lib/components/Export/components/ExportToTerra/components/ExportToTerraForm/exportToTerraForm.d.ts +5 -2
- package/lib/components/Export/components/ExportToTerra/components/ExportToTerraForm/exportToTerraForm.js +2 -2
- package/lib/components/Export/components/ExportToTerra/components/ExportToTerraNotStarted/exportToTerraNotStarted.d.ts +3 -1
- package/lib/components/Export/components/ExportToTerra/components/ExportToTerraNotStarted/exportToTerraNotStarted.js +2 -2
- package/lib/components/Export/components/ExportToTerra/exportToTerra.d.ts +1 -1
- package/lib/components/Export/components/ExportToTerra/exportToTerra.js +9 -6
- package/lib/components/Export/components/ManifestDownload/components/ManifestDownloadEntity/manifestDownloadEntity.d.ts +3 -1
- package/lib/components/Export/components/ManifestDownload/components/ManifestDownloadEntity/manifestDownloadEntity.js +3 -4
- package/lib/components/Export/components/ManifestDownload/manifestDownload.d.ts +3 -2
- package/lib/components/Export/components/ManifestDownload/manifestDownload.js +6 -4
- package/lib/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.js +4 -3
- package/lib/hooks/types.d.ts +4 -0
- package/lib/hooks/types.js +5 -0
- package/lib/hooks/useFileManifest/common/entities.d.ts +0 -5
- package/lib/hooks/useFileManifest/common/entities.js +0 -6
- package/lib/hooks/useFileManifest/useFileManifest.d.ts +8 -5
- package/lib/hooks/useFileManifest/useFileManifest.js +29 -8
- package/lib/hooks/useFileManifest/useFileManifestDownload.js +10 -9
- package/lib/hooks/useFileManifest/useFileManifestFormat.d.ts +12 -0
- package/lib/hooks/useFileManifest/useFileManifestFormat.js +10 -0
- package/lib/hooks/useRequestFileLocation.d.ts +1 -4
- package/lib/hooks/useRequestFileLocation.js +1 -5
- package/lib/hooks/useRequestManifest/constants.d.ts +2 -0
- package/lib/hooks/useRequestManifest/constants.js +4 -0
- package/lib/hooks/useRequestManifest/types.d.ts +6 -0
- package/lib/hooks/useRequestManifest/types.js +1 -0
- package/lib/hooks/useRequestManifest/useRequestManifest.d.ts +10 -0
- package/lib/hooks/useRequestManifest/useRequestManifest.js +30 -0
- package/lib/hooks/useRequestManifest/utils.d.ts +65 -0
- package/lib/hooks/useRequestManifest/utils.js +118 -0
- package/lib/mocks/useRequestFileManifest.mocks.d.ts +11 -0
- package/lib/mocks/useRequestFileManifest.mocks.js +100 -0
- package/lib/providers/fileManifestState/constants.d.ts +0 -2
- package/lib/providers/fileManifestState/constants.js +0 -11
- package/lib/providers/fileManifestState.d.ts +3 -25
- package/lib/providers/fileManifestState.js +3 -36
- package/lib/views/ExportView/exportView.js +2 -2
- package/package.json +1 -1
- package/src/components/Export/components/DownloadCurlCommand/downloadCurlCommand.tsx +17 -10
- package/src/components/Export/components/ExportForm/components/ExportManifestDownloadFormatForm/exportManifestDownloadFormatForm.tsx +7 -16
- package/src/components/Export/components/ExportToTerra/components/ExportToTerraForm/exportToTerraForm.tsx +8 -4
- package/src/components/Export/components/ExportToTerra/components/ExportToTerraNotStarted/exportToTerraNotStarted.tsx +4 -1
- package/src/components/Export/components/ExportToTerra/exportToTerra.tsx +13 -9
- package/src/components/Export/components/ManifestDownload/components/ManifestDownloadEntity/manifestDownloadEntity.tsx +4 -9
- package/src/components/Export/components/ManifestDownload/manifestDownload.tsx +17 -11
- package/src/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.tsx +6 -3
- package/src/hooks/types.ts +4 -0
- package/src/hooks/useFileManifest/common/entities.ts +0 -6
- package/src/hooks/useFileManifest/useFileManifest.ts +34 -13
- package/src/hooks/useFileManifest/useFileManifestDownload.ts +21 -16
- package/src/hooks/useFileManifest/useFileManifestFormat.ts +23 -0
- package/src/hooks/useRequestFileLocation.ts +1 -5
- package/src/hooks/useRequestManifest/constants.ts +6 -0
- package/src/hooks/useRequestManifest/types.ts +7 -0
- package/src/hooks/useRequestManifest/useRequestManifest.ts +49 -0
- package/src/hooks/useRequestManifest/utils.ts +153 -0
- package/src/mocks/useRequestFileManifest.mocks.ts +121 -0
- package/src/providers/fileManifestState/constants.ts +0 -15
- package/src/providers/fileManifestState.tsx +5 -77
- package/src/views/ExportView/exportView.tsx +2 -2
- package/tests/buildRequestFilters.test.ts +68 -0
- package/tests/buildRequestManifest.test.ts +103 -0
- package/tests/useRequestManifest.test.ts +193 -0
- package/lib/hooks/useFileManifest/common/buildFileManifestRequestURL.d.ts +0 -15
- package/lib/hooks/useFileManifest/common/buildFileManifestRequestURL.js +0 -28
- package/lib/hooks/useFileManifest/useFileManifestURL.d.ts +0 -5
- package/lib/hooks/useFileManifest/useFileManifestURL.js +0 -11
- package/lib/hooks/useFileManifest/useRequestFileManifest.d.ts +0 -11
- package/lib/hooks/useFileManifest/useRequestFileManifest.js +0 -40
- package/lib/providers/fileManifestState/actions.d.ts +0 -9
- package/lib/providers/fileManifestState/actions.js +0 -19
- package/lib/providers/fileManifestState/utils.d.ts +0 -34
- package/lib/providers/fileManifestState/utils.js +0 -80
- package/src/hooks/useFileManifest/common/buildFileManifestRequestURL.ts +0 -44
- package/src/hooks/useFileManifest/useFileManifestURL.ts +0 -12
- package/src/hooks/useFileManifest/useRequestFileManifest.ts +0 -51
- package/src/providers/fileManifestState/actions.ts +0 -34
- package/src/providers/fileManifestState/utils.ts +0 -108
- package/tests/fileManifestRequestFilters.test.ts +0 -160
- package/tests/updateFilesFacetsStatus.test.ts +0 -84
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { Filters } from "../../common/entities";
|
|
2
|
-
import {
|
|
3
|
-
FileFacet,
|
|
4
|
-
FILES_FACETS_STATUS,
|
|
5
|
-
} from "../../hooks/useFileManifest/common/entities";
|
|
6
|
-
import { findFacet } from "../../hooks/useFileManifest/common/utils";
|
|
7
|
-
import {
|
|
8
|
-
FileManifestState,
|
|
9
|
-
UpdateFileManifestPayload,
|
|
10
|
-
} from "../fileManifestState";
|
|
11
|
-
import { ENTITIES_FILE_MANIFEST_TYPES } from "./constants";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Generates the filters for a request URL based on the file manifest state.
|
|
15
|
-
* If all terms in a facet are selected, the corresponding facet is excluded.
|
|
16
|
-
* @param state - File manifest state.
|
|
17
|
-
* @returns filters for the request URL.
|
|
18
|
-
*/
|
|
19
|
-
export function getRequestFilters(
|
|
20
|
-
state: FileManifestState
|
|
21
|
-
): Filters | undefined {
|
|
22
|
-
if (state.filesFacetsStatus !== FILES_FACETS_STATUS.COMPLETED) return;
|
|
23
|
-
// Determine if the filters are user-selected.
|
|
24
|
-
if (isFiltersUserSelected(state)) {
|
|
25
|
-
return state.filters;
|
|
26
|
-
}
|
|
27
|
-
for (const filter of state.filters) {
|
|
28
|
-
const facet = findFacet(state.filesFacets, filter.categoryKey);
|
|
29
|
-
if (!facet) return [filter]; // The entity identifier related filter will not have a corresponding term facet.
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Returns true if filter values for each selected facet are partially selected.
|
|
35
|
-
* @param filters - Selected filters.
|
|
36
|
-
* @param filesFacets - Files facets.
|
|
37
|
-
* @returns true if the filters are partially selected.
|
|
38
|
-
*/
|
|
39
|
-
function isFiltersPartiallySelected(
|
|
40
|
-
filters: Filters,
|
|
41
|
-
filesFacets: FileFacet[]
|
|
42
|
-
): boolean {
|
|
43
|
-
for (const { categoryKey, value } of filters) {
|
|
44
|
-
const facet = findFacet(filesFacets, categoryKey);
|
|
45
|
-
if (!facet) continue; // Continue; the entity identifier related filter will not have a corresponding term facet.
|
|
46
|
-
if (value.length < facet.termCount) return true;
|
|
47
|
-
}
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Returns true if the filters are user-selected, when:
|
|
53
|
-
* - The file manifest type is not set.
|
|
54
|
-
* - The file manifest type is an entity list related type.
|
|
55
|
-
* - Filter values for each selected facet are partially selected.
|
|
56
|
-
* @param state - File manifest state.
|
|
57
|
-
* @returns true if the filters are user-selected.
|
|
58
|
-
*/
|
|
59
|
-
export function isFiltersUserSelected(state: FileManifestState): boolean {
|
|
60
|
-
if (!state.fileManifestType) return true;
|
|
61
|
-
if (ENTITIES_FILE_MANIFEST_TYPES.includes(state.fileManifestType))
|
|
62
|
-
return true;
|
|
63
|
-
return isFiltersPartiallySelected(state.filters, state.filesFacets);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Transitions the files facets' status.
|
|
68
|
-
* @param shouldTransition - True if transitioning, false otherwise.
|
|
69
|
-
* @param nextStatus - Next files facets' status.
|
|
70
|
-
* @param currentStatus - Current files facets' status.
|
|
71
|
-
* @returns files facets' status.
|
|
72
|
-
*/
|
|
73
|
-
export function transitionFilesFacetsStatus(
|
|
74
|
-
shouldTransition: boolean,
|
|
75
|
-
nextStatus: FILES_FACETS_STATUS,
|
|
76
|
-
currentStatus: FILES_FACETS_STATUS
|
|
77
|
-
): FILES_FACETS_STATUS {
|
|
78
|
-
return shouldTransition ? nextStatus : currentStatus;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Returns the updated files facets' status.
|
|
83
|
-
* @param state - File manifest state.
|
|
84
|
-
* @param payload - Update file manifest payload.
|
|
85
|
-
* @returns files facets' status.
|
|
86
|
-
*/
|
|
87
|
-
export function updateFilesFacetsStatus(
|
|
88
|
-
state: FileManifestState,
|
|
89
|
-
payload: UpdateFileManifestPayload
|
|
90
|
-
): FILES_FACETS_STATUS {
|
|
91
|
-
if (state.filesFacetsStatus === FILES_FACETS_STATUS.NOT_STARTED) {
|
|
92
|
-
// If the current status is NOT_STARTED, transition to IN_PROGRESS if facets are loading.
|
|
93
|
-
return transitionFilesFacetsStatus(
|
|
94
|
-
payload.isFacetsLoading,
|
|
95
|
-
FILES_FACETS_STATUS.IN_PROGRESS,
|
|
96
|
-
FILES_FACETS_STATUS.NOT_STARTED
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
if (state.filesFacetsStatus === FILES_FACETS_STATUS.IN_PROGRESS) {
|
|
100
|
-
// If the current status is IN_PROGRESS, transition to COMPLETED if facets are successfully loaded.
|
|
101
|
-
return transitionFilesFacetsStatus(
|
|
102
|
-
payload.isFacetsSuccess,
|
|
103
|
-
FILES_FACETS_STATUS.COMPLETED,
|
|
104
|
-
FILES_FACETS_STATUS.IN_PROGRESS
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
return FILES_FACETS_STATUS.COMPLETED;
|
|
108
|
-
}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { Filters, SelectedFilter } from "../src/common/entities";
|
|
2
|
-
import {
|
|
3
|
-
FILE_MANIFEST_TYPE,
|
|
4
|
-
FileFacet,
|
|
5
|
-
FILES_FACETS_STATUS,
|
|
6
|
-
} from "../src/hooks/useFileManifest/common/entities";
|
|
7
|
-
import { FileManifestState } from "../src/providers/fileManifestState";
|
|
8
|
-
import { FILE_MANIFEST_STATE } from "../src/providers/fileManifestState/constants";
|
|
9
|
-
import { getRequestFilters } from "../src/providers/fileManifestState/utils";
|
|
10
|
-
|
|
11
|
-
const FILE_MANIFEST_STATE_NOT_STARTED: FileManifestState = {
|
|
12
|
-
...FILE_MANIFEST_STATE,
|
|
13
|
-
filesFacetsStatus: FILES_FACETS_STATUS.NOT_STARTED,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const FILE_MANIFEST_STATE_IN_PROGRESS: FileManifestState = {
|
|
17
|
-
...FILE_MANIFEST_STATE,
|
|
18
|
-
filesFacetsStatus: FILES_FACETS_STATUS.IN_PROGRESS,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const FILE_MANIFEST_STATE_COMPLETED: FileManifestState = {
|
|
22
|
-
...FILE_MANIFEST_STATE,
|
|
23
|
-
filesFacetsStatus: FILES_FACETS_STATUS.COMPLETED,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const FILES_FACETS: Partial<FileFacet>[] = [
|
|
27
|
-
{
|
|
28
|
-
name: "category01",
|
|
29
|
-
termCount: 2,
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: "category02",
|
|
33
|
-
termCount: 3,
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
const FILTER_IDENTIFIER: SelectedFilter = {
|
|
38
|
-
categoryKey: "identifier",
|
|
39
|
-
value: ["value05"],
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const FILTERS_COMPLETE_SET: Filters = [
|
|
43
|
-
{ categoryKey: "category01", value: ["value01", "value02"] },
|
|
44
|
-
{ categoryKey: "category02", value: ["value02", "value03", "value04"] },
|
|
45
|
-
];
|
|
46
|
-
|
|
47
|
-
const FILTERS_SUBSET: Filters = [
|
|
48
|
-
{ categoryKey: "category01", value: ["value01"] },
|
|
49
|
-
{ categoryKey: "category02", value: ["value02", "value03", "value04"] },
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
const FILE_MANIFEST_STATE_USER_SELECT_FILTERS: FileManifestState = {
|
|
53
|
-
...FILE_MANIFEST_STATE,
|
|
54
|
-
filesFacetsStatus: FILES_FACETS_STATUS.COMPLETED,
|
|
55
|
-
filters: FILTERS_SUBSET,
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
describe("fileManifestRequestFilters", () => {
|
|
59
|
-
describe("when filters and facets are undefined or empty", () => {
|
|
60
|
-
test("returns undefined for empty filters and facets", () => {
|
|
61
|
-
expect(
|
|
62
|
-
getRequestFilters({
|
|
63
|
-
...FILE_MANIFEST_STATE,
|
|
64
|
-
})
|
|
65
|
-
).toBeUndefined();
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe("when checking filesFacetsStatus", () => {
|
|
70
|
-
test("returns undefined when status is NOT_STARTED", () => {
|
|
71
|
-
expect(
|
|
72
|
-
getRequestFilters(FILE_MANIFEST_STATE_NOT_STARTED)
|
|
73
|
-
).toBeUndefined();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test("returns undefined when status is IN_PROGRESS", () => {
|
|
77
|
-
expect(
|
|
78
|
-
getRequestFilters(FILE_MANIFEST_STATE_IN_PROGRESS)
|
|
79
|
-
).toBeUndefined();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test("returns request filters when status is COMPLETED", () => {
|
|
83
|
-
expect(FILE_MANIFEST_STATE_COMPLETED.fileManifestType).toBeUndefined();
|
|
84
|
-
expect(getRequestFilters(FILE_MANIFEST_STATE_COMPLETED)).toEqual([]);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe("when filters are user-selected", () => {
|
|
89
|
-
describe("and fileManifestType is undefined", () => {
|
|
90
|
-
test("returns user-selected filters", () => {
|
|
91
|
-
expect(
|
|
92
|
-
getRequestFilters(FILE_MANIFEST_STATE_USER_SELECT_FILTERS)
|
|
93
|
-
).toEqual(FILTERS_SUBSET);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
describe("and fileManifestType is ENTITY LIST", () => {
|
|
98
|
-
test("returns user-selected filters for BULK_DOWNLOAD", () => {
|
|
99
|
-
expect(
|
|
100
|
-
getRequestFilters({
|
|
101
|
-
...FILE_MANIFEST_STATE_USER_SELECT_FILTERS,
|
|
102
|
-
fileManifestType: FILE_MANIFEST_TYPE.BULK_DOWNLOAD,
|
|
103
|
-
})
|
|
104
|
-
).toEqual(FILTERS_SUBSET);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
test("returns user-selected filters for DOWNLOAD_MANIFEST", () => {
|
|
108
|
-
expect(
|
|
109
|
-
getRequestFilters({
|
|
110
|
-
...FILE_MANIFEST_STATE_USER_SELECT_FILTERS,
|
|
111
|
-
fileManifestType: FILE_MANIFEST_TYPE.DOWNLOAD_MANIFEST,
|
|
112
|
-
})
|
|
113
|
-
).toEqual(FILTERS_SUBSET);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
test("returns user-selected filters for EXPORT_TO_TERRA", () => {
|
|
117
|
-
expect(
|
|
118
|
-
getRequestFilters({
|
|
119
|
-
...FILE_MANIFEST_STATE_USER_SELECT_FILTERS,
|
|
120
|
-
fileManifestType: FILE_MANIFEST_TYPE.EXPORT_TO_TERRA,
|
|
121
|
-
})
|
|
122
|
-
).toEqual(FILTERS_SUBSET);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
test("returns user-selected filters that are a subset of facet terms", () => {
|
|
127
|
-
expect(
|
|
128
|
-
getRequestFilters({
|
|
129
|
-
...FILE_MANIFEST_STATE_USER_SELECT_FILTERS,
|
|
130
|
-
fileManifestType: FILE_MANIFEST_TYPE.ENTITY_BULK_DOWNLOAD, // FILE_MANIFEST_TYPE is NOT ENTITY LIST.
|
|
131
|
-
filesFacets: FILES_FACETS as FileFacet[],
|
|
132
|
-
})
|
|
133
|
-
).toEqual(FILTERS_SUBSET);
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
describe("when filters are NOT user-selected", () => {
|
|
138
|
-
test("returns undefined when all terms are included, and identifier filter is not defined", () => {
|
|
139
|
-
expect(
|
|
140
|
-
getRequestFilters({
|
|
141
|
-
...FILE_MANIFEST_STATE_USER_SELECT_FILTERS,
|
|
142
|
-
fileManifestType: FILE_MANIFEST_TYPE.ENTITY_BULK_DOWNLOAD, // FILE_MANIFEST_TYPE is NOT ENTITY LIST.
|
|
143
|
-
filesFacets: FILES_FACETS as FileFacet[],
|
|
144
|
-
filters: FILTERS_COMPLETE_SET,
|
|
145
|
-
})
|
|
146
|
-
).toBeUndefined();
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
test("returns identifier filter when all terms are included, and identifier filter is defined", () => {
|
|
150
|
-
const filters = getRequestFilters({
|
|
151
|
-
...FILE_MANIFEST_STATE_USER_SELECT_FILTERS,
|
|
152
|
-
fileManifestType: FILE_MANIFEST_TYPE.ENTITY_BULK_DOWNLOAD, // FILE_MANIFEST_TYPE is NOT ENTITY LIST.
|
|
153
|
-
filesFacets: FILES_FACETS as FileFacet[],
|
|
154
|
-
filters: [...FILTERS_COMPLETE_SET, FILTER_IDENTIFIER],
|
|
155
|
-
});
|
|
156
|
-
expect(filters?.length).toBe(1);
|
|
157
|
-
expect(filters?.[0].categoryKey).toBe(FILTER_IDENTIFIER.categoryKey);
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { FILES_FACETS_STATUS } from "../src/hooks/useFileManifest/common/entities";
|
|
2
|
-
import {
|
|
3
|
-
FileManifestState,
|
|
4
|
-
UpdateFileManifestPayload,
|
|
5
|
-
} from "../src/providers/fileManifestState";
|
|
6
|
-
import { FILE_MANIFEST_STATE } from "../src/providers/fileManifestState/constants";
|
|
7
|
-
import { updateFilesFacetsStatus } from "../src/providers/fileManifestState/utils";
|
|
8
|
-
|
|
9
|
-
const FILE_MANIFEST_STATE_NOT_STARTED: FileManifestState = {
|
|
10
|
-
...FILE_MANIFEST_STATE,
|
|
11
|
-
filesFacetsStatus: FILES_FACETS_STATUS.NOT_STARTED,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const FILE_MANIFEST_STATE_IN_PROGRESS: FileManifestState = {
|
|
15
|
-
...FILE_MANIFEST_STATE,
|
|
16
|
-
filesFacetsStatus: FILES_FACETS_STATUS.IN_PROGRESS,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const FILE_MANIFEST_STATE_COMPLETED: FileManifestState = {
|
|
20
|
-
...FILE_MANIFEST_STATE,
|
|
21
|
-
filesFacetsStatus: FILES_FACETS_STATUS.COMPLETED,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const UPDATE_FILE_MANIFEST_PAYLOAD_IDLE = {
|
|
25
|
-
isFacetsLoading: false,
|
|
26
|
-
isFacetsSuccess: false,
|
|
27
|
-
} as UpdateFileManifestPayload;
|
|
28
|
-
|
|
29
|
-
const UPDATE_FILE_MANIFEST_PAYLOAD_LOADING = {
|
|
30
|
-
isFacetsLoading: true,
|
|
31
|
-
isFacetsSuccess: false,
|
|
32
|
-
} as UpdateFileManifestPayload;
|
|
33
|
-
|
|
34
|
-
const UPDATE_FILE_MANIFEST_PAYLOAD_SUCCESS = {
|
|
35
|
-
isFacetsLoading: false,
|
|
36
|
-
isFacetsSuccess: true,
|
|
37
|
-
} as UpdateFileManifestPayload;
|
|
38
|
-
|
|
39
|
-
describe("updateFilesFacetsStatus", () => {
|
|
40
|
-
test("files facets NOT_STARTED, request is IDLE", () => {
|
|
41
|
-
expect(
|
|
42
|
-
updateFilesFacetsStatus(
|
|
43
|
-
FILE_MANIFEST_STATE_NOT_STARTED,
|
|
44
|
-
UPDATE_FILE_MANIFEST_PAYLOAD_IDLE
|
|
45
|
-
)
|
|
46
|
-
).toBe(FILES_FACETS_STATUS.NOT_STARTED);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test("files facets NOT_STARTED, request is LOADING", () => {
|
|
50
|
-
expect(
|
|
51
|
-
updateFilesFacetsStatus(
|
|
52
|
-
FILE_MANIFEST_STATE_NOT_STARTED,
|
|
53
|
-
UPDATE_FILE_MANIFEST_PAYLOAD_LOADING
|
|
54
|
-
)
|
|
55
|
-
).toBe(FILES_FACETS_STATUS.IN_PROGRESS);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test("files facets IN_PROGRESS, request is LOADING", () => {
|
|
59
|
-
expect(
|
|
60
|
-
updateFilesFacetsStatus(
|
|
61
|
-
FILE_MANIFEST_STATE_IN_PROGRESS,
|
|
62
|
-
UPDATE_FILE_MANIFEST_PAYLOAD_LOADING
|
|
63
|
-
)
|
|
64
|
-
).toBe(FILES_FACETS_STATUS.IN_PROGRESS);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
test("files facets IN_PROGRESS, request is SUCCESS", () => {
|
|
68
|
-
expect(
|
|
69
|
-
updateFilesFacetsStatus(
|
|
70
|
-
FILE_MANIFEST_STATE_IN_PROGRESS,
|
|
71
|
-
UPDATE_FILE_MANIFEST_PAYLOAD_SUCCESS
|
|
72
|
-
)
|
|
73
|
-
).toBe(FILES_FACETS_STATUS.COMPLETED);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test("files facets COMPLETED, request is SUCCESS", () => {
|
|
77
|
-
expect(
|
|
78
|
-
updateFilesFacetsStatus(
|
|
79
|
-
FILE_MANIFEST_STATE_COMPLETED,
|
|
80
|
-
UPDATE_FILE_MANIFEST_PAYLOAD_SUCCESS
|
|
81
|
-
)
|
|
82
|
-
).toBe(FILES_FACETS_STATUS.COMPLETED);
|
|
83
|
-
});
|
|
84
|
-
});
|