@scality/data-browser-library 1.0.0-preview.13 → 1.0.0-preview.15
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 +15 -8
- 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 +121 -122
- 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 +256 -200
- 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 +251 -250
- 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 +62 -62
- 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 +23 -22
- package/dist/components/index.js +3 -2
- 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 +112 -111
- 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 +15 -4
- package/dist/components/providers/DataBrowserProvider.js +33 -11
- 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 +41 -41
- 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 +14 -13
- package/dist/hooks/index.js +2 -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 +14 -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/useISVBucketDetection.js +3 -3
- 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 +5 -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/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 +78 -92
- 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/dist/utils/useSupportedNotificationEvents.d.ts +6 -0
- package/dist/utils/useSupportedNotificationEvents.js +7 -0
- package/package.json +2 -2
package/dist/test/testUtils.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
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
7
|
import { CoreUiThemeProvider } from "@scality/core-ui/dist/next";
|
|
8
8
|
import { ToastProvider } from "@scality/core-ui";
|
|
9
9
|
import { DataBrowserProvider } from "../components/providers/DataBrowserProvider.js";
|
|
10
|
+
import { DataBrowserUICustomizationProvider } from "../contexts/DataBrowserUICustomizationContext.js";
|
|
10
11
|
import { overrideHandlers, setupMswServer } from "./msw/index.js";
|
|
11
12
|
var __webpack_require__ = {};
|
|
12
13
|
(()=>{
|
|
@@ -20,14 +21,14 @@ var __webpack_require__ = {};
|
|
|
20
21
|
})();
|
|
21
22
|
})();
|
|
22
23
|
const testConfig = {
|
|
23
|
-
endpoint:
|
|
24
|
-
region:
|
|
24
|
+
endpoint: 'https://s3.amazonaws.com',
|
|
25
|
+
region: 'us-east-1',
|
|
25
26
|
forcePathStyle: true
|
|
26
27
|
};
|
|
27
28
|
const testCredentials = {
|
|
28
|
-
accessKeyId:
|
|
29
|
-
secretAccessKey:
|
|
30
|
-
sessionToken:
|
|
29
|
+
accessKeyId: 'test-access-key',
|
|
30
|
+
secretAccessKey: 'test-secret-key',
|
|
31
|
+
sessionToken: 'test-session-token'
|
|
31
32
|
};
|
|
32
33
|
const mockS3Client = {
|
|
33
34
|
send: jest.fn()
|
|
@@ -81,44 +82,24 @@ function mockOffsetSize(width, height) {
|
|
|
81
82
|
}
|
|
82
83
|
});
|
|
83
84
|
const mockComputedStyle = {
|
|
84
|
-
fontSize:
|
|
85
|
-
paddingLeft:
|
|
86
|
-
paddingRight:
|
|
87
|
-
paddingTop:
|
|
88
|
-
paddingBottom:
|
|
85
|
+
fontSize: '14px',
|
|
86
|
+
paddingLeft: '0px',
|
|
87
|
+
paddingRight: '0px',
|
|
88
|
+
paddingTop: '0px',
|
|
89
|
+
paddingBottom: '0px',
|
|
89
90
|
getPropertyValue: jest.fn((prop)=>{
|
|
90
91
|
const styles = {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
'font-size': '14px',
|
|
93
|
+
'padding-left': '0px',
|
|
94
|
+
'padding-right': '0px',
|
|
95
|
+
'padding-top': '0px',
|
|
96
|
+
'padding-bottom': '0px'
|
|
96
97
|
};
|
|
97
|
-
return styles[prop] ||
|
|
98
|
+
return styles[prop] || '';
|
|
98
99
|
})
|
|
99
100
|
};
|
|
100
|
-
jest.spyOn(window,
|
|
101
|
+
jest.spyOn(window, 'getComputedStyle').mockImplementation(()=>mockComputedStyle);
|
|
101
102
|
}
|
|
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
103
|
const createTestWrapper = (config = testConfig, credentials = testCredentials)=>{
|
|
123
104
|
const queryClient = new QueryClient({
|
|
124
105
|
defaultOptions: {
|
|
@@ -140,10 +121,15 @@ const createTestWrapper = (config = testConfig, credentials = testCredentials)=>
|
|
|
140
121
|
getS3Config: getConfig,
|
|
141
122
|
theme: theme,
|
|
142
123
|
enableDevtools: false,
|
|
143
|
-
children: /*#__PURE__*/ jsx(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
124
|
+
children: /*#__PURE__*/ jsx(DataBrowserUICustomizationProvider, {
|
|
125
|
+
config: {
|
|
126
|
+
basePath: ''
|
|
127
|
+
},
|
|
128
|
+
children: /*#__PURE__*/ jsx(CoreUiThemeProvider, {
|
|
129
|
+
theme: theme,
|
|
130
|
+
children: /*#__PURE__*/ jsx(ToastProvider, {
|
|
131
|
+
children: children
|
|
132
|
+
})
|
|
147
133
|
})
|
|
148
134
|
})
|
|
149
135
|
});
|
|
@@ -155,7 +141,7 @@ const renderHookWithWrapper = (hook, options)=>{
|
|
|
155
141
|
...renderOptions
|
|
156
142
|
});
|
|
157
143
|
};
|
|
158
|
-
const createTestFile = (name, content, type =
|
|
144
|
+
const createTestFile = (name, content, type = 'text/plain')=>new File([
|
|
159
145
|
content
|
|
160
146
|
], name, {
|
|
161
147
|
type
|
|
@@ -178,16 +164,16 @@ const overrideGlobalConfig = (overrides)=>{
|
|
|
178
164
|
};
|
|
179
165
|
const resetGlobalConfig = ()=>{
|
|
180
166
|
globalThis.__S3_CONFIG__ = {
|
|
181
|
-
endpoint:
|
|
182
|
-
region:
|
|
183
|
-
realHost:
|
|
167
|
+
endpoint: 'http://localhost:8000',
|
|
168
|
+
region: 'us-east-1',
|
|
169
|
+
realHost: 's3.amazonaws.com',
|
|
184
170
|
forcePathStyle: true
|
|
185
171
|
};
|
|
186
172
|
globalThis.__DEV_CONFIG__ = {
|
|
187
173
|
useProxy: false,
|
|
188
|
-
proxyEndpoint:
|
|
189
|
-
proxyBasePath:
|
|
190
|
-
proxyHost:
|
|
174
|
+
proxyEndpoint: 'http://localhost:3000/api/s3',
|
|
175
|
+
proxyBasePath: '/api/s3',
|
|
176
|
+
proxyHost: 'localhost',
|
|
191
177
|
proxyPort: 3000
|
|
192
178
|
};
|
|
193
179
|
globalThis.__IS_DEVELOPMENT__ = true;
|
|
@@ -201,37 +187,37 @@ const withGlobalConfig = (overrides, testFn)=>async ()=>{
|
|
|
201
187
|
resetGlobalConfig();
|
|
202
188
|
}
|
|
203
189
|
};
|
|
204
|
-
const createFactoryTestError = (testContext, operationName, details)=>new Error(`Factory Test Failure [${testContext}]: ${operationName} - ${details ||
|
|
190
|
+
const createFactoryTestError = (testContext, operationName, details)=>new Error(`Factory Test Failure [${testContext}]: ${operationName} - ${details || 'Unknown error'}. Check factory implementation and hook usage patterns.`);
|
|
205
191
|
const validateFactoryHook = (hook, operationName)=>{
|
|
206
|
-
if (
|
|
192
|
+
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
193
|
};
|
|
208
194
|
const validateHookResult = (result, hookType)=>{
|
|
209
195
|
const commonProps = [
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
196
|
+
'isError',
|
|
197
|
+
'isSuccess',
|
|
198
|
+
'data',
|
|
199
|
+
'error'
|
|
214
200
|
];
|
|
215
201
|
const queryProps = [
|
|
216
|
-
|
|
202
|
+
'isLoading'
|
|
217
203
|
];
|
|
218
204
|
const mutationProps = [
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
205
|
+
'mutate',
|
|
206
|
+
'mutateAsync',
|
|
207
|
+
'isPending'
|
|
222
208
|
];
|
|
223
209
|
const infiniteProps = [
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
210
|
+
'hasNextPage',
|
|
211
|
+
'fetchNextPage',
|
|
212
|
+
'isFetchingNextPage'
|
|
227
213
|
];
|
|
228
214
|
const expectedProps = [
|
|
229
215
|
...commonProps,
|
|
230
|
-
...
|
|
231
|
-
...
|
|
232
|
-
...
|
|
216
|
+
...'query' === hookType ? queryProps : [],
|
|
217
|
+
...'mutation' === hookType ? mutationProps : [],
|
|
218
|
+
...'infiniteQuery' === hookType ? infiniteProps : []
|
|
233
219
|
];
|
|
234
|
-
for (const prop of expectedProps)if (!(prop in result)) throw createFactoryTestError(
|
|
220
|
+
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
221
|
};
|
|
236
222
|
const createMockMutationResult = (mutate, overrides = {})=>({
|
|
237
223
|
mutate,
|
|
@@ -241,7 +227,7 @@ const createMockMutationResult = (mutate, overrides = {})=>({
|
|
|
241
227
|
isIdle: true,
|
|
242
228
|
isError: false,
|
|
243
229
|
isSuccess: false,
|
|
244
|
-
status:
|
|
230
|
+
status: 'idle',
|
|
245
231
|
data: void 0,
|
|
246
232
|
error: null,
|
|
247
233
|
variables: void 0,
|
|
@@ -260,7 +246,7 @@ const createMockQueryResult = (overrides = {})=>({
|
|
|
260
246
|
isLoadingError: false,
|
|
261
247
|
isRefetchError: false,
|
|
262
248
|
isSuccess: false,
|
|
263
|
-
status:
|
|
249
|
+
status: 'pending',
|
|
264
250
|
dataUpdatedAt: 0,
|
|
265
251
|
errorUpdatedAt: 0,
|
|
266
252
|
failureCount: 0,
|
|
@@ -284,15 +270,15 @@ const findToggleByLabel = (labelText)=>{
|
|
|
284
270
|
while(current && !current.querySelector('input[type="checkbox"]'))current = current.parentElement;
|
|
285
271
|
return current?.querySelector('input[type="checkbox"]');
|
|
286
272
|
};
|
|
287
|
-
const submitForm = async (buttonName =
|
|
273
|
+
const submitForm = async (buttonName = 'create')=>{
|
|
288
274
|
await waitFor(()=>{
|
|
289
|
-
const button = screen.getByRole(
|
|
290
|
-
name:
|
|
275
|
+
const button = screen.getByRole('button', {
|
|
276
|
+
name: 'create' === buttonName ? /create/i : /save/i
|
|
291
277
|
});
|
|
292
278
|
expect(button).toBeEnabled();
|
|
293
279
|
});
|
|
294
|
-
const button = screen.getByRole(
|
|
295
|
-
name:
|
|
280
|
+
const button = screen.getByRole('button', {
|
|
281
|
+
name: 'create' === buttonName ? /create/i : /save/i
|
|
296
282
|
});
|
|
297
283
|
fireEvent.click(button);
|
|
298
284
|
};
|
|
@@ -301,7 +287,7 @@ const mockSuccessSubmit = (mockMutate)=>{
|
|
|
301
287
|
options?.onSuccess?.();
|
|
302
288
|
});
|
|
303
289
|
};
|
|
304
|
-
const mockErrorSubmit = (mockMutate, errorMessage =
|
|
290
|
+
const mockErrorSubmit = (mockMutate, errorMessage = 'Network Error')=>{
|
|
305
291
|
const error = new Error(errorMessage);
|
|
306
292
|
mockMutate.mockImplementation((_, options)=>{
|
|
307
293
|
options?.onError?.(error);
|
|
@@ -310,72 +296,72 @@ const mockErrorSubmit = (mockMutate, errorMessage = "Network Error")=>{
|
|
|
310
296
|
const createDefaultBucketMocks = ()=>({
|
|
311
297
|
versioning: {
|
|
312
298
|
data: {
|
|
313
|
-
Status:
|
|
299
|
+
Status: 'Enabled'
|
|
314
300
|
},
|
|
315
|
-
status:
|
|
301
|
+
status: 'success'
|
|
316
302
|
},
|
|
317
303
|
acl: {
|
|
318
304
|
data: {
|
|
319
305
|
Owner: {
|
|
320
|
-
DisplayName:
|
|
306
|
+
DisplayName: 'test-owner'
|
|
321
307
|
},
|
|
322
308
|
Grants: [
|
|
323
309
|
{
|
|
324
310
|
Grantee: {
|
|
325
|
-
Type:
|
|
326
|
-
DisplayName:
|
|
311
|
+
Type: 'CanonicalUser',
|
|
312
|
+
DisplayName: 'test-grantee'
|
|
327
313
|
}
|
|
328
314
|
}
|
|
329
315
|
]
|
|
330
316
|
},
|
|
331
|
-
status:
|
|
317
|
+
status: 'success'
|
|
332
318
|
},
|
|
333
319
|
location: {
|
|
334
320
|
data: {
|
|
335
|
-
LocationConstraint:
|
|
321
|
+
LocationConstraint: 'us-west-2'
|
|
336
322
|
},
|
|
337
|
-
status:
|
|
323
|
+
status: 'success'
|
|
338
324
|
},
|
|
339
325
|
cors: {
|
|
340
326
|
data: {
|
|
341
327
|
CORSRules: []
|
|
342
328
|
},
|
|
343
|
-
status:
|
|
329
|
+
status: 'success'
|
|
344
330
|
},
|
|
345
331
|
objectLock: {
|
|
346
332
|
data: {
|
|
347
333
|
ObjectLockConfiguration: {
|
|
348
|
-
ObjectLockEnabled:
|
|
334
|
+
ObjectLockEnabled: 'Disabled'
|
|
349
335
|
}
|
|
350
336
|
},
|
|
351
|
-
status:
|
|
337
|
+
status: 'success'
|
|
352
338
|
},
|
|
353
339
|
policy: {
|
|
354
340
|
data: void 0,
|
|
355
341
|
error: null,
|
|
356
|
-
status:
|
|
342
|
+
status: 'success'
|
|
357
343
|
},
|
|
358
344
|
tagging: {
|
|
359
345
|
data: {
|
|
360
346
|
TagSet: []
|
|
361
347
|
},
|
|
362
|
-
status:
|
|
348
|
+
status: 'success'
|
|
363
349
|
},
|
|
364
350
|
lifecycle: {
|
|
365
351
|
data: {
|
|
366
352
|
Rules: []
|
|
367
353
|
},
|
|
368
|
-
status:
|
|
354
|
+
status: 'success',
|
|
369
355
|
error: null
|
|
370
356
|
},
|
|
371
357
|
replication: {
|
|
372
358
|
data: {
|
|
373
359
|
ReplicationConfiguration: {
|
|
374
|
-
Role:
|
|
360
|
+
Role: 'arn:aws:iam::123456789012:role/replication-role',
|
|
375
361
|
Rules: []
|
|
376
362
|
}
|
|
377
363
|
},
|
|
378
|
-
status:
|
|
364
|
+
status: 'success',
|
|
379
365
|
error: null
|
|
380
366
|
},
|
|
381
367
|
isvBucketStatus: {
|
|
@@ -384,7 +370,7 @@ const createDefaultBucketMocks = ()=>({
|
|
|
384
370
|
isISVManaged: false,
|
|
385
371
|
isvApplication: void 0,
|
|
386
372
|
isLoading: false,
|
|
387
|
-
bucketTagsStatus:
|
|
373
|
+
bucketTagsStatus: 'success'
|
|
388
374
|
},
|
|
389
375
|
features: false
|
|
390
376
|
});
|
|
@@ -406,4 +392,4 @@ const applyBucketMocks = (mocks, mockData = {})=>{
|
|
|
406
392
|
if (mocks.useGetBucketLifecycle) mocks.useGetBucketLifecycle.mockReturnValue(data.lifecycle);
|
|
407
393
|
if (mocks.useGetBucketReplication) mocks.useGetBucketReplication.mockReturnValue(data.replication);
|
|
408
394
|
};
|
|
409
|
-
export { MockedPutObjectCommand, MockedS3Client, applyBucketMocks, createDefaultBucketMocks, createFactoryTestError, createMockMutationResult, createMockQueryResult,
|
|
395
|
+
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 };
|