@scality/data-browser-library 1.0.0-preview.13 → 1.0.0-preview.16
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/dist/components/DataBrowserUI.d.ts +6 -14
- package/dist/components/DataBrowserUI.js +79 -55
- package/dist/components/Editor.d.ts +1 -1
- package/dist/components/Editor.js +3 -3
- package/dist/components/__tests__/BucketCreate.test.js +102 -102
- package/dist/components/__tests__/BucketDetails.test.js +122 -123
- package/dist/components/__tests__/BucketLifecycleFormPage.test.js +177 -177
- package/dist/components/__tests__/BucketLifecycleList.test.js +85 -85
- package/dist/components/__tests__/BucketList.test.js +175 -176
- package/dist/components/__tests__/BucketNotificationCreatePage.test.js +84 -84
- package/dist/components/__tests__/BucketOverview.test.js +257 -201
- package/dist/components/__tests__/BucketPolicyPage.test.js +62 -62
- package/dist/components/__tests__/BucketReplicationFormPage.test.js +542 -542
- package/dist/components/__tests__/BucketReplicationList.test.js +106 -106
- package/dist/components/__tests__/CreateFolderButton.test.js +56 -56
- package/dist/components/__tests__/DeleteBucketButton.test.js +62 -62
- package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.js +47 -47
- package/dist/components/__tests__/DeleteObjectButton.test.js +63 -63
- package/dist/components/__tests__/EmptyBucketButton.test.js +56 -56
- package/dist/components/__tests__/MetadataSearch.test.js +65 -65
- package/dist/components/__tests__/ObjectList.test.js +252 -251
- package/dist/components/__tests__/UploadButton.test.js +45 -45
- package/dist/components/buckets/BucketCreate.d.ts +2 -2
- package/dist/components/buckets/BucketCreate.js +41 -41
- package/dist/components/buckets/BucketDetails.d.ts +2 -2
- package/dist/components/buckets/BucketDetails.js +48 -36
- package/dist/components/buckets/BucketLifecycleFormPage.js +161 -160
- package/dist/components/buckets/BucketLifecycleList.d.ts +2 -2
- package/dist/components/buckets/BucketLifecycleList.js +46 -46
- package/dist/components/buckets/BucketList.d.ts +2 -2
- package/dist/components/buckets/BucketList.js +28 -27
- package/dist/components/buckets/BucketLocation.js +3 -3
- package/dist/components/buckets/BucketOverview.d.ts +1 -1
- package/dist/components/buckets/BucketOverview.js +64 -65
- package/dist/components/buckets/BucketPage.js +19 -11
- package/dist/components/buckets/BucketPolicyButton.js +2 -2
- package/dist/components/buckets/BucketPolicyPage.js +27 -25
- package/dist/components/buckets/BucketReplicationFormPage.js +133 -132
- package/dist/components/buckets/BucketReplicationList.d.ts +2 -2
- package/dist/components/buckets/BucketReplicationList.js +41 -41
- package/dist/components/buckets/BucketVersioning.js +11 -11
- package/dist/components/buckets/DeleteBucketButton.js +5 -5
- package/dist/components/buckets/DeleteBucketConfigRuleButton.d.ts +2 -2
- package/dist/components/buckets/DeleteBucketConfigRuleButton.js +1 -1
- package/dist/components/buckets/EmptyBucketButton.js +19 -19
- package/dist/components/buckets/EmptyBucketSummary.d.ts +1 -1
- package/dist/components/buckets/EmptyBucketSummary.js +1 -1
- package/dist/components/buckets/EmptyBucketSummaryList.js +22 -22
- package/dist/components/buckets/__tests__/BucketVersioning.test.js +45 -45
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.js +34 -33
- package/dist/components/buckets/notifications/EventsSection.js +144 -28
- package/dist/components/buckets/notifications/__tests__/events.test.d.ts +1 -0
- package/dist/components/buckets/notifications/__tests__/events.test.js +56 -0
- package/dist/components/buckets/notifications/events.d.ts +71 -7
- package/dist/components/buckets/notifications/events.js +98 -16
- package/dist/components/index.d.ts +24 -22
- package/dist/components/index.js +5 -3
- package/dist/components/layouts/ArrowNavigation.d.ts +1 -2
- package/dist/components/layouts/ArrowNavigation.js +3 -3
- package/dist/components/layouts/BrowserPageLayout.d.ts +2 -3
- package/dist/components/layouts/BrowserPageLayout.js +1 -1
- package/dist/components/objects/CreateFolderButton.d.ts +2 -2
- package/dist/components/objects/CreateFolderButton.js +9 -9
- package/dist/components/objects/DeleteObjectButton.d.ts +1 -1
- package/dist/components/objects/DeleteObjectButton.js +20 -20
- package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +1 -1
- package/dist/components/objects/ObjectDetails/ObjectMetadata.js +56 -56
- package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +1 -1
- package/dist/components/objects/ObjectDetails/ObjectSummary.js +39 -39
- package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +1 -1
- package/dist/components/objects/ObjectDetails/ObjectTags.js +25 -25
- package/dist/components/objects/ObjectDetails/__tests__/ObjectDetails.test.js +119 -119
- package/dist/components/objects/ObjectDetails/__tests__/ObjectSummary.test.js +211 -211
- package/dist/components/objects/ObjectDetails/index.d.ts +1 -1
- package/dist/components/objects/ObjectDetails/index.js +30 -30
- package/dist/components/objects/ObjectList.d.ts +5 -5
- package/dist/components/objects/ObjectList.js +113 -112
- package/dist/components/objects/ObjectLock/EditRetentionButton.js +3 -3
- package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.js +14 -14
- package/dist/components/objects/ObjectLock/ObjectLockSettings.d.ts +1 -1
- package/dist/components/objects/ObjectLock/ObjectLockSettings.js +29 -28
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.d.ts +1 -1
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.js +6 -6
- package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.js +50 -50
- package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.js +77 -77
- package/dist/components/objects/ObjectPage.js +5 -4
- package/dist/components/objects/UploadButton.d.ts +3 -3
- package/dist/components/objects/UploadButton.js +5 -5
- package/dist/components/providers/DataBrowserProvider.d.ts +23 -12
- package/dist/components/providers/DataBrowserProvider.js +60 -38
- package/dist/components/providers/QueryProvider.d.ts +9 -0
- package/dist/components/providers/QueryProvider.js +22 -0
- package/dist/components/search/MetadataSearch.js +26 -25
- package/dist/components/search/SearchHints.js +1 -1
- package/dist/components/ui/ArrayFieldActions.js +4 -4
- package/dist/components/ui/ConfirmDeleteRuleModal.d.ts +1 -1
- package/dist/components/ui/ConfirmDeleteRuleModal.js +1 -1
- package/dist/components/ui/DeleteObjectModalContent.d.ts +1 -1
- package/dist/components/ui/DeleteObjectModalContent.js +12 -12
- package/dist/components/ui/FilterFormSection.d.ts +2 -2
- package/dist/components/ui/FilterFormSection.js +29 -29
- package/dist/components/ui/Search.elements.d.ts +1 -1
- package/dist/components/ui/Search.elements.js +7 -7
- package/dist/components/ui/Table.elements.js +5 -5
- package/dist/config/factory.d.ts +23 -10
- package/dist/config/factory.js +22 -7
- package/dist/config/types.d.ts +20 -3
- package/dist/contexts/DataBrowserUICustomizationContext.d.ts +2 -2
- package/dist/hooks/__tests__/useISVBucketDetection.test.js +42 -42
- package/dist/hooks/__tests__/useIsBucketEmpty.test.js +25 -25
- package/dist/hooks/bucketConfiguration.d.ts +1 -1
- package/dist/hooks/bucketConfiguration.js +48 -48
- package/dist/hooks/bucketOperations.d.ts +1 -1
- package/dist/hooks/bucketOperations.js +6 -6
- package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +78 -78
- package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +78 -78
- package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +42 -42
- package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +61 -61
- package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +63 -63
- package/dist/hooks/factories/index.d.ts +4 -4
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +15 -12
- package/dist/hooks/factories/useCreateS3LoginHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3MutationHook.d.ts +3 -3
- package/dist/hooks/factories/useCreateS3MutationHook.js +6 -1
- package/dist/hooks/factories/useCreateS3QueryHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3QueryHook.js +8 -5
- package/dist/hooks/index.d.ts +16 -13
- package/dist/hooks/index.js +4 -1
- package/dist/hooks/loginOperations.d.ts +1 -1
- package/dist/hooks/loginOperations.js +1 -1
- package/dist/hooks/objectOperations.d.ts +2 -2
- package/dist/hooks/objectOperations.js +49 -49
- package/dist/hooks/presignedOperations.d.ts +2 -2
- package/dist/hooks/presignedOperations.js +3 -3
- package/dist/hooks/useBatchObjectLegalHold.js +7 -4
- package/dist/hooks/useDataBrowserNavigate.d.ts +28 -0
- package/dist/hooks/useDataBrowserNavigate.js +24 -0
- package/dist/hooks/useDeleteBucketConfigRule.d.ts +2 -2
- package/dist/hooks/useDeleteBucketConfigRule.js +4 -4
- package/dist/hooks/useEmptyBucket.js +10 -10
- package/dist/hooks/useFeatures.d.ts +7 -0
- package/dist/hooks/useFeatures.js +8 -0
- package/dist/hooks/useISVBucketDetection.js +5 -5
- package/dist/hooks/useIsBucketEmpty.js +4 -4
- package/dist/hooks/useLoginMutation.d.ts +1 -1
- package/dist/hooks/useLoginMutation.js +1 -1
- package/dist/hooks/useS3Client.d.ts +6 -0
- package/dist/hooks/useS3Client.js +3 -2
- package/dist/hooks/useS3ConfigSwitch.d.ts +11 -0
- package/dist/hooks/useS3ConfigSwitch.js +37 -0
- package/dist/hooks/useSupportedNotificationEvents.d.ts +6 -0
- package/dist/hooks/useSupportedNotificationEvents.js +8 -0
- package/dist/index.d.ts +6 -6
- package/dist/test/msw/handlers/deleteBucket.d.ts +1 -1
- package/dist/test/msw/handlers/deleteBucket.js +20 -10
- package/dist/test/msw/handlers/getBucketAcl.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketAcl.js +29 -17
- package/dist/test/msw/handlers/getBucketLocation.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketLocation.js +29 -15
- package/dist/test/msw/handlers/getBucketPolicy.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketPolicy.js +52 -32
- package/dist/test/msw/handlers/headObject.d.ts +1 -1
- package/dist/test/msw/handlers/headObject.js +31 -13
- package/dist/test/msw/handlers/listBuckets.d.ts +1 -1
- package/dist/test/msw/handlers/listBuckets.js +5 -3
- package/dist/test/msw/handlers/listObjectVersions.d.ts +1 -1
- package/dist/test/msw/handlers/listObjectVersions.js +38 -26
- package/dist/test/msw/handlers/listObjects.d.ts +1 -1
- package/dist/test/msw/handlers/listObjects.js +35 -23
- package/dist/test/msw/handlers/objectLegalHold.d.ts +1 -1
- package/dist/test/msw/handlers/objectLegalHold.js +31 -16
- package/dist/test/msw/handlers/objectRetention.d.ts +1 -1
- package/dist/test/msw/handlers/objectRetention.js +31 -17
- package/dist/test/msw/handlers/putBucketAcl.d.ts +1 -1
- package/dist/test/msw/handlers/putBucketAcl.js +29 -14
- package/dist/test/msw/handlers/putObject.d.ts +1 -1
- package/dist/test/msw/handlers/putObject.js +27 -12
- package/dist/test/msw/handlers.d.ts +3 -3
- package/dist/test/msw/handlers.js +72 -49
- package/dist/test/msw/index.d.ts +2 -2
- package/dist/test/msw/server.d.ts +1 -1
- package/dist/test/msw/server.js +1 -1
- package/dist/test/msw/utils.js +2 -2
- package/dist/test/setup.d.ts +1 -1
- package/dist/test/setup.js +19 -19
- package/dist/test/testUtils.d.ts +9 -15
- package/dist/test/testUtils.js +73 -91
- package/dist/test/utils/errorHandling.test.js +119 -119
- package/dist/types/index.d.ts +6 -31
- package/dist/utils/__tests__/s3ConfigIdentifier.test.d.ts +1 -0
- package/dist/utils/__tests__/s3ConfigIdentifier.test.js +429 -0
- package/dist/utils/constants.js +8 -8
- package/dist/utils/deletion/index.d.ts +2 -2
- package/dist/utils/deletion/messages.d.ts +1 -1
- package/dist/utils/deletion/messages.js +4 -4
- package/dist/utils/errorHandling.d.ts +3 -3
- package/dist/utils/errorHandling.js +6 -6
- package/dist/utils/hooks.js +8 -8
- package/dist/utils/index.d.ts +5 -4
- package/dist/utils/index.js +2 -0
- package/dist/utils/proxyMiddleware.d.ts +1 -1
- package/dist/utils/proxyMiddleware.js +6 -11
- package/dist/utils/s3Client.d.ts +2 -2
- package/dist/utils/s3Client.js +1 -1
- package/dist/utils/s3ConfigIdentifier.d.ts +68 -0
- package/dist/utils/s3ConfigIdentifier.js +55 -0
- package/dist/utils/s3RuleUtils.d.ts +5 -5
- package/dist/utils/s3RuleUtils.js +17 -17
- package/package.json +2 -2
- package/dist/utils/useFeatures.d.ts +0 -1
- package/dist/utils/useFeatures.js +0 -7
package/dist/test/testUtils.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
4
|
-
import { QueryClient
|
|
4
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
5
5
|
import { fireEvent, renderHook, screen, waitFor } from "@testing-library/react";
|
|
6
6
|
import { coreUIAvailableThemes } from "@scality/core-ui/dist/style/theme";
|
|
7
|
-
import { CoreUiThemeProvider } from "@scality/core-ui/dist/next";
|
|
8
7
|
import { ToastProvider } from "@scality/core-ui";
|
|
9
8
|
import { DataBrowserProvider } from "../components/providers/DataBrowserProvider.js";
|
|
9
|
+
import { DataBrowserUICustomizationProvider } from "../contexts/DataBrowserUICustomizationContext.js";
|
|
10
10
|
import { overrideHandlers, setupMswServer } from "./msw/index.js";
|
|
11
11
|
var __webpack_require__ = {};
|
|
12
12
|
(()=>{
|
|
@@ -20,14 +20,14 @@ var __webpack_require__ = {};
|
|
|
20
20
|
})();
|
|
21
21
|
})();
|
|
22
22
|
const testConfig = {
|
|
23
|
-
endpoint:
|
|
24
|
-
region:
|
|
23
|
+
endpoint: 'https://s3.amazonaws.com',
|
|
24
|
+
region: 'us-east-1',
|
|
25
25
|
forcePathStyle: true
|
|
26
26
|
};
|
|
27
27
|
const testCredentials = {
|
|
28
|
-
accessKeyId:
|
|
29
|
-
secretAccessKey:
|
|
30
|
-
sessionToken:
|
|
28
|
+
accessKeyId: 'test-access-key',
|
|
29
|
+
secretAccessKey: 'test-secret-key',
|
|
30
|
+
sessionToken: 'test-session-token'
|
|
31
31
|
};
|
|
32
32
|
const mockS3Client = {
|
|
33
33
|
send: jest.fn()
|
|
@@ -81,44 +81,24 @@ function mockOffsetSize(width, height) {
|
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
const mockComputedStyle = {
|
|
84
|
-
fontSize:
|
|
85
|
-
paddingLeft:
|
|
86
|
-
paddingRight:
|
|
87
|
-
paddingTop:
|
|
88
|
-
paddingBottom:
|
|
84
|
+
fontSize: '14px',
|
|
85
|
+
paddingLeft: '0px',
|
|
86
|
+
paddingRight: '0px',
|
|
87
|
+
paddingTop: '0px',
|
|
88
|
+
paddingBottom: '0px',
|
|
89
89
|
getPropertyValue: jest.fn((prop)=>{
|
|
90
90
|
const styles = {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
'font-size': '14px',
|
|
92
|
+
'padding-left': '0px',
|
|
93
|
+
'padding-right': '0px',
|
|
94
|
+
'padding-top': '0px',
|
|
95
|
+
'padding-bottom': '0px'
|
|
96
96
|
};
|
|
97
|
-
return styles[prop] ||
|
|
97
|
+
return styles[prop] || '';
|
|
98
98
|
})
|
|
99
99
|
};
|
|
100
|
-
jest.spyOn(window,
|
|
100
|
+
jest.spyOn(window, 'getComputedStyle').mockImplementation(()=>mockComputedStyle);
|
|
101
101
|
}
|
|
102
|
-
const createQueryWrapper = ()=>{
|
|
103
|
-
const queryClient = new QueryClient({
|
|
104
|
-
defaultOptions: {
|
|
105
|
-
queries: {
|
|
106
|
-
retry: false
|
|
107
|
-
},
|
|
108
|
-
mutations: {
|
|
109
|
-
retry: false
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
const theme = coreUIAvailableThemes.darkRebrand;
|
|
114
|
-
return ({ children })=>/*#__PURE__*/ jsx(QueryClientProvider, {
|
|
115
|
-
client: queryClient,
|
|
116
|
-
children: /*#__PURE__*/ jsx(CoreUiThemeProvider, {
|
|
117
|
-
theme: theme,
|
|
118
|
-
children: children
|
|
119
|
-
})
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
102
|
const createTestWrapper = (config = testConfig, credentials = testCredentials)=>{
|
|
123
103
|
const queryClient = new QueryClient({
|
|
124
104
|
defaultOptions: {
|
|
@@ -140,8 +120,10 @@ const createTestWrapper = (config = testConfig, credentials = testCredentials)=>
|
|
|
140
120
|
getS3Config: getConfig,
|
|
141
121
|
theme: theme,
|
|
142
122
|
enableDevtools: false,
|
|
143
|
-
children: /*#__PURE__*/ jsx(
|
|
144
|
-
|
|
123
|
+
children: /*#__PURE__*/ jsx(DataBrowserUICustomizationProvider, {
|
|
124
|
+
config: {
|
|
125
|
+
basePath: ''
|
|
126
|
+
},
|
|
145
127
|
children: /*#__PURE__*/ jsx(ToastProvider, {
|
|
146
128
|
children: children
|
|
147
129
|
})
|
|
@@ -155,7 +137,7 @@ const renderHookWithWrapper = (hook, options)=>{
|
|
|
155
137
|
...renderOptions
|
|
156
138
|
});
|
|
157
139
|
};
|
|
158
|
-
const createTestFile = (name, content, type =
|
|
140
|
+
const createTestFile = (name, content, type = 'text/plain')=>new File([
|
|
159
141
|
content
|
|
160
142
|
], name, {
|
|
161
143
|
type
|
|
@@ -178,16 +160,16 @@ const overrideGlobalConfig = (overrides)=>{
|
|
|
178
160
|
};
|
|
179
161
|
const resetGlobalConfig = ()=>{
|
|
180
162
|
globalThis.__S3_CONFIG__ = {
|
|
181
|
-
endpoint:
|
|
182
|
-
region:
|
|
183
|
-
realHost:
|
|
163
|
+
endpoint: 'http://localhost:8000',
|
|
164
|
+
region: 'us-east-1',
|
|
165
|
+
realHost: 's3.amazonaws.com',
|
|
184
166
|
forcePathStyle: true
|
|
185
167
|
};
|
|
186
168
|
globalThis.__DEV_CONFIG__ = {
|
|
187
169
|
useProxy: false,
|
|
188
|
-
proxyEndpoint:
|
|
189
|
-
proxyBasePath:
|
|
190
|
-
proxyHost:
|
|
170
|
+
proxyEndpoint: 'http://localhost:3000/api/s3',
|
|
171
|
+
proxyBasePath: '/api/s3',
|
|
172
|
+
proxyHost: 'localhost',
|
|
191
173
|
proxyPort: 3000
|
|
192
174
|
};
|
|
193
175
|
globalThis.__IS_DEVELOPMENT__ = true;
|
|
@@ -201,37 +183,37 @@ const withGlobalConfig = (overrides, testFn)=>async ()=>{
|
|
|
201
183
|
resetGlobalConfig();
|
|
202
184
|
}
|
|
203
185
|
};
|
|
204
|
-
const createFactoryTestError = (testContext, operationName, details)=>new Error(`Factory Test Failure [${testContext}]: ${operationName} - ${details ||
|
|
186
|
+
const createFactoryTestError = (testContext, operationName, details)=>new Error(`Factory Test Failure [${testContext}]: ${operationName} - ${details || 'Unknown error'}. Check factory implementation and hook usage patterns.`);
|
|
205
187
|
const validateFactoryHook = (hook, operationName)=>{
|
|
206
|
-
if (
|
|
188
|
+
if ('function' != typeof hook) throw createFactoryTestError('Factory Validation', operationName, 'hook should be a function - check if useCreate*Hook factory is properly returning a hook function');
|
|
207
189
|
};
|
|
208
190
|
const validateHookResult = (result, hookType)=>{
|
|
209
191
|
const commonProps = [
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
192
|
+
'isError',
|
|
193
|
+
'isSuccess',
|
|
194
|
+
'data',
|
|
195
|
+
'error'
|
|
214
196
|
];
|
|
215
197
|
const queryProps = [
|
|
216
|
-
|
|
198
|
+
'isLoading'
|
|
217
199
|
];
|
|
218
200
|
const mutationProps = [
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
201
|
+
'mutate',
|
|
202
|
+
'mutateAsync',
|
|
203
|
+
'isPending'
|
|
222
204
|
];
|
|
223
205
|
const infiniteProps = [
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
206
|
+
'hasNextPage',
|
|
207
|
+
'fetchNextPage',
|
|
208
|
+
'isFetchingNextPage'
|
|
227
209
|
];
|
|
228
210
|
const expectedProps = [
|
|
229
211
|
...commonProps,
|
|
230
|
-
...
|
|
231
|
-
...
|
|
232
|
-
...
|
|
212
|
+
...'query' === hookType ? queryProps : [],
|
|
213
|
+
...'mutation' === hookType ? mutationProps : [],
|
|
214
|
+
...'infiniteQuery' === hookType ? infiniteProps : []
|
|
233
215
|
];
|
|
234
|
-
for (const prop of expectedProps)if (!(prop in result)) throw createFactoryTestError(
|
|
216
|
+
for (const prop of expectedProps)if (!(prop in result)) throw createFactoryTestError('Hook Validation', hookType, `Missing property '${prop}' - check if factory is returning proper React Query hook result`);
|
|
235
217
|
};
|
|
236
218
|
const createMockMutationResult = (mutate, overrides = {})=>({
|
|
237
219
|
mutate,
|
|
@@ -241,7 +223,7 @@ const createMockMutationResult = (mutate, overrides = {})=>({
|
|
|
241
223
|
isIdle: true,
|
|
242
224
|
isError: false,
|
|
243
225
|
isSuccess: false,
|
|
244
|
-
status:
|
|
226
|
+
status: 'idle',
|
|
245
227
|
data: void 0,
|
|
246
228
|
error: null,
|
|
247
229
|
variables: void 0,
|
|
@@ -260,7 +242,7 @@ const createMockQueryResult = (overrides = {})=>({
|
|
|
260
242
|
isLoadingError: false,
|
|
261
243
|
isRefetchError: false,
|
|
262
244
|
isSuccess: false,
|
|
263
|
-
status:
|
|
245
|
+
status: 'pending',
|
|
264
246
|
dataUpdatedAt: 0,
|
|
265
247
|
errorUpdatedAt: 0,
|
|
266
248
|
failureCount: 0,
|
|
@@ -284,15 +266,15 @@ const findToggleByLabel = (labelText)=>{
|
|
|
284
266
|
while(current && !current.querySelector('input[type="checkbox"]'))current = current.parentElement;
|
|
285
267
|
return current?.querySelector('input[type="checkbox"]');
|
|
286
268
|
};
|
|
287
|
-
const submitForm = async (buttonName =
|
|
269
|
+
const submitForm = async (buttonName = 'create')=>{
|
|
288
270
|
await waitFor(()=>{
|
|
289
|
-
const button = screen.getByRole(
|
|
290
|
-
name:
|
|
271
|
+
const button = screen.getByRole('button', {
|
|
272
|
+
name: 'create' === buttonName ? /create/i : /save/i
|
|
291
273
|
});
|
|
292
274
|
expect(button).toBeEnabled();
|
|
293
275
|
});
|
|
294
|
-
const button = screen.getByRole(
|
|
295
|
-
name:
|
|
276
|
+
const button = screen.getByRole('button', {
|
|
277
|
+
name: 'create' === buttonName ? /create/i : /save/i
|
|
296
278
|
});
|
|
297
279
|
fireEvent.click(button);
|
|
298
280
|
};
|
|
@@ -301,7 +283,7 @@ const mockSuccessSubmit = (mockMutate)=>{
|
|
|
301
283
|
options?.onSuccess?.();
|
|
302
284
|
});
|
|
303
285
|
};
|
|
304
|
-
const mockErrorSubmit = (mockMutate, errorMessage =
|
|
286
|
+
const mockErrorSubmit = (mockMutate, errorMessage = 'Network Error')=>{
|
|
305
287
|
const error = new Error(errorMessage);
|
|
306
288
|
mockMutate.mockImplementation((_, options)=>{
|
|
307
289
|
options?.onError?.(error);
|
|
@@ -310,72 +292,72 @@ const mockErrorSubmit = (mockMutate, errorMessage = "Network Error")=>{
|
|
|
310
292
|
const createDefaultBucketMocks = ()=>({
|
|
311
293
|
versioning: {
|
|
312
294
|
data: {
|
|
313
|
-
Status:
|
|
295
|
+
Status: 'Enabled'
|
|
314
296
|
},
|
|
315
|
-
status:
|
|
297
|
+
status: 'success'
|
|
316
298
|
},
|
|
317
299
|
acl: {
|
|
318
300
|
data: {
|
|
319
301
|
Owner: {
|
|
320
|
-
DisplayName:
|
|
302
|
+
DisplayName: 'test-owner'
|
|
321
303
|
},
|
|
322
304
|
Grants: [
|
|
323
305
|
{
|
|
324
306
|
Grantee: {
|
|
325
|
-
Type:
|
|
326
|
-
DisplayName:
|
|
307
|
+
Type: 'CanonicalUser',
|
|
308
|
+
DisplayName: 'test-grantee'
|
|
327
309
|
}
|
|
328
310
|
}
|
|
329
311
|
]
|
|
330
312
|
},
|
|
331
|
-
status:
|
|
313
|
+
status: 'success'
|
|
332
314
|
},
|
|
333
315
|
location: {
|
|
334
316
|
data: {
|
|
335
|
-
LocationConstraint:
|
|
317
|
+
LocationConstraint: 'us-west-2'
|
|
336
318
|
},
|
|
337
|
-
status:
|
|
319
|
+
status: 'success'
|
|
338
320
|
},
|
|
339
321
|
cors: {
|
|
340
322
|
data: {
|
|
341
323
|
CORSRules: []
|
|
342
324
|
},
|
|
343
|
-
status:
|
|
325
|
+
status: 'success'
|
|
344
326
|
},
|
|
345
327
|
objectLock: {
|
|
346
328
|
data: {
|
|
347
329
|
ObjectLockConfiguration: {
|
|
348
|
-
ObjectLockEnabled:
|
|
330
|
+
ObjectLockEnabled: 'Disabled'
|
|
349
331
|
}
|
|
350
332
|
},
|
|
351
|
-
status:
|
|
333
|
+
status: 'success'
|
|
352
334
|
},
|
|
353
335
|
policy: {
|
|
354
336
|
data: void 0,
|
|
355
337
|
error: null,
|
|
356
|
-
status:
|
|
338
|
+
status: 'success'
|
|
357
339
|
},
|
|
358
340
|
tagging: {
|
|
359
341
|
data: {
|
|
360
342
|
TagSet: []
|
|
361
343
|
},
|
|
362
|
-
status:
|
|
344
|
+
status: 'success'
|
|
363
345
|
},
|
|
364
346
|
lifecycle: {
|
|
365
347
|
data: {
|
|
366
348
|
Rules: []
|
|
367
349
|
},
|
|
368
|
-
status:
|
|
350
|
+
status: 'success',
|
|
369
351
|
error: null
|
|
370
352
|
},
|
|
371
353
|
replication: {
|
|
372
354
|
data: {
|
|
373
355
|
ReplicationConfiguration: {
|
|
374
|
-
Role:
|
|
356
|
+
Role: 'arn:aws:iam::123456789012:role/replication-role',
|
|
375
357
|
Rules: []
|
|
376
358
|
}
|
|
377
359
|
},
|
|
378
|
-
status:
|
|
360
|
+
status: 'success',
|
|
379
361
|
error: null
|
|
380
362
|
},
|
|
381
363
|
isvBucketStatus: {
|
|
@@ -384,7 +366,7 @@ const createDefaultBucketMocks = ()=>({
|
|
|
384
366
|
isISVManaged: false,
|
|
385
367
|
isvApplication: void 0,
|
|
386
368
|
isLoading: false,
|
|
387
|
-
bucketTagsStatus:
|
|
369
|
+
bucketTagsStatus: 'success'
|
|
388
370
|
},
|
|
389
371
|
features: false
|
|
390
372
|
});
|
|
@@ -406,4 +388,4 @@ const applyBucketMocks = (mocks, mockData = {})=>{
|
|
|
406
388
|
if (mocks.useGetBucketLifecycle) mocks.useGetBucketLifecycle.mockReturnValue(data.lifecycle);
|
|
407
389
|
if (mocks.useGetBucketReplication) mocks.useGetBucketReplication.mockReturnValue(data.replication);
|
|
408
390
|
};
|
|
409
|
-
export { MockedPutObjectCommand, MockedS3Client, applyBucketMocks, createDefaultBucketMocks, createFactoryTestError, createMockMutationResult, createMockQueryResult,
|
|
391
|
+
export { MockedPutObjectCommand, MockedS3Client, applyBucketMocks, createDefaultBucketMocks, createFactoryTestError, createMockMutationResult, createMockQueryResult, createTestFile, createTestWrapper, findToggleByLabel, mockErrorSubmit, mockOffsetSize, mockS3Client, mockSuccessSubmit, overrideGlobalConfig, overrideHandlers, renderHookWithWrapper, resetGlobalConfig, setupCommonMocks, setupMswServer, setupS3Mocks, submitForm, testConfig, testCredentials, validateFactoryHook, validateHookResult, withGlobalConfig };
|