@scality/data-browser-library 1.0.0-preview.8 → 1.0.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/dist/components/DataBrowserUI.d.ts +12 -0
- package/dist/components/DataBrowserUI.js +99 -0
- package/dist/components/Editor.d.ts +1 -1
- package/dist/components/Editor.js +3 -3
- package/dist/components/__tests__/BucketAccessor.test.js +214 -0
- package/dist/components/__tests__/BucketCorsPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketCorsPage.test.js +263 -0
- package/dist/components/__tests__/BucketCreate.test.d.ts +1 -0
- package/dist/components/__tests__/BucketCreate.test.js +574 -0
- package/dist/components/__tests__/BucketDetails.test.d.ts +1 -0
- package/dist/components/__tests__/BucketDetails.test.js +421 -0
- package/dist/components/__tests__/BucketLifecycleFormPage.test.d.ts +14 -0
- package/dist/components/__tests__/BucketLifecycleFormPage.test.js +618 -0
- package/dist/components/__tests__/BucketLifecycleList.test.d.ts +1 -0
- package/dist/components/__tests__/BucketLifecycleList.test.js +325 -0
- package/dist/components/__tests__/BucketList.test.js +495 -81
- package/dist/components/__tests__/BucketNotificationFormPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketNotificationFormPage.test.js +348 -0
- package/dist/components/__tests__/BucketNotificationList.test.d.ts +1 -0
- package/dist/components/__tests__/BucketNotificationList.test.js +379 -0
- package/dist/components/__tests__/BucketOverview.test.js +484 -179
- package/dist/components/__tests__/BucketPolicyPage.test.js +151 -99
- package/dist/components/__tests__/BucketReplicationFormPage.test.d.ts +16 -0
- package/dist/components/__tests__/BucketReplicationFormPage.test.js +1757 -0
- package/dist/components/__tests__/BucketReplicationList.test.d.ts +1 -0
- package/dist/components/__tests__/BucketReplicationList.test.js +344 -0
- package/dist/components/__tests__/CreateFolderButton.test.js +56 -56
- package/dist/components/__tests__/DeleteBucketButton.test.js +64 -64
- package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.d.ts +1 -0
- package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.js +196 -0
- package/dist/components/__tests__/DeleteObjectButton.test.js +64 -64
- package/dist/components/__tests__/EmptyBucketButton.test.d.ts +1 -0
- package/dist/components/__tests__/EmptyBucketButton.test.js +302 -0
- package/dist/components/__tests__/MetadataSearch.test.js +65 -65
- package/dist/components/__tests__/ObjectList.test.js +741 -240
- package/dist/components/__tests__/UploadButton.test.js +45 -45
- package/dist/components/breadcrumb/Breadcrumb.d.ts +6 -0
- package/dist/components/breadcrumb/Breadcrumb.js +37 -0
- package/dist/components/breadcrumb/DataBrowserBreadcrumb.d.ts +1 -0
- package/dist/components/breadcrumb/DataBrowserBreadcrumb.js +10 -0
- package/dist/components/breadcrumb/__tests__/Breadcrumb.test.d.ts +1 -0
- package/dist/components/breadcrumb/__tests__/Breadcrumb.test.js +196 -0
- package/dist/components/breadcrumb/__tests__/DataBrowserBreadcrumb.test.d.ts +1 -0
- package/dist/components/breadcrumb/__tests__/DataBrowserBreadcrumb.test.js +153 -0
- package/dist/components/breadcrumb/__tests__/useBreadcrumbPaths.test.d.ts +1 -0
- package/dist/components/breadcrumb/__tests__/useBreadcrumbPaths.test.js +134 -0
- package/dist/components/breadcrumb/index.d.ts +8 -0
- package/dist/components/breadcrumb/index.js +4 -0
- package/dist/components/breadcrumb/useBreadcrumbPaths.d.ts +2 -0
- package/dist/components/breadcrumb/useBreadcrumbPaths.js +82 -0
- package/dist/components/buckets/BucketAccessor.d.ts +2 -0
- package/dist/components/buckets/BucketAccessor.js +125 -0
- package/dist/components/buckets/BucketConfigEditButton.d.ts +8 -0
- package/dist/components/buckets/{BucketPolicyButton.js → BucketConfigEditButton.js} +9 -5
- package/dist/components/buckets/BucketCorsPage.d.ts +1 -0
- package/dist/components/buckets/BucketCorsPage.js +234 -0
- package/dist/components/buckets/BucketCreate.d.ts +50 -0
- package/dist/components/buckets/BucketCreate.js +279 -0
- package/dist/components/buckets/BucketDetails.d.ts +42 -0
- package/dist/components/buckets/BucketDetails.js +256 -40
- package/dist/components/buckets/BucketLifecycleFormPage.d.ts +15 -0
- package/dist/components/buckets/BucketLifecycleFormPage.js +1086 -0
- package/dist/components/buckets/BucketLifecycleList.d.ts +10 -0
- package/dist/components/buckets/BucketLifecycleList.js +270 -0
- package/dist/components/buckets/BucketList.d.ts +6 -4
- package/dist/components/buckets/BucketList.js +161 -94
- package/dist/components/buckets/BucketLocation.js +4 -4
- package/dist/components/buckets/BucketOverview.d.ts +86 -5
- package/dist/components/buckets/BucketOverview.js +481 -192
- package/dist/components/buckets/BucketPage.js +44 -22
- package/dist/components/buckets/BucketPolicyPage.js +155 -127
- package/dist/components/buckets/BucketReplicationFormPage.d.ts +1 -0
- package/dist/components/buckets/BucketReplicationFormPage.js +835 -0
- package/dist/components/buckets/BucketReplicationList.d.ts +11 -0
- package/dist/components/buckets/BucketReplicationList.js +189 -0
- package/dist/components/buckets/BucketVersioning.d.ts +4 -0
- package/dist/components/buckets/BucketVersioning.js +76 -0
- package/dist/components/buckets/DeleteBucketButton.js +8 -8
- package/dist/components/buckets/DeleteBucketConfigRuleButton.d.ts +18 -0
- package/dist/components/buckets/DeleteBucketConfigRuleButton.js +53 -0
- package/dist/components/buckets/EmptyBucketButton.d.ts +5 -0
- package/dist/components/buckets/EmptyBucketButton.js +232 -0
- package/dist/components/buckets/EmptyBucketSummary.d.ts +9 -0
- package/dist/components/buckets/EmptyBucketSummary.js +60 -0
- package/dist/components/buckets/EmptyBucketSummaryList.d.ts +13 -0
- package/dist/components/buckets/EmptyBucketSummaryList.js +140 -0
- package/dist/components/buckets/__tests__/BucketVersioning.test.d.ts +1 -0
- package/dist/components/buckets/__tests__/BucketVersioning.test.js +163 -0
- package/dist/components/buckets/notifications/BucketNotificationFormPage.d.ts +1 -0
- package/dist/components/buckets/notifications/BucketNotificationFormPage.js +316 -0
- package/dist/components/buckets/notifications/BucketNotificationList.d.ts +10 -0
- package/dist/components/buckets/notifications/BucketNotificationList.js +267 -0
- package/dist/components/buckets/notifications/EventsSection.js +145 -29
- 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 +27 -13
- package/dist/components/index.js +20 -6
- package/dist/components/layouts/ArrowNavigation.d.ts +3 -0
- package/dist/components/layouts/ArrowNavigation.js +28 -0
- package/dist/components/layouts/BrowserPageLayout.d.ts +5 -1
- package/dist/components/layouts/BrowserPageLayout.js +10 -5
- package/dist/components/objects/CreateFolderButton.d.ts +2 -2
- package/dist/components/objects/CreateFolderButton.js +12 -12
- package/dist/components/objects/DeleteObjectButton.d.ts +1 -1
- package/dist/components/objects/DeleteObjectButton.js +19 -21
- package/dist/components/objects/GetPresignedUrlButton.d.ts +7 -0
- package/dist/components/objects/GetPresignedUrlButton.js +255 -0
- package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +2 -2
- package/dist/components/objects/ObjectDetails/ObjectMetadata.js +263 -230
- package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +2 -2
- package/dist/components/objects/ObjectDetails/ObjectSummary.js +540 -138
- package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +2 -2
- package/dist/components/objects/ObjectDetails/ObjectTags.js +95 -123
- package/dist/components/objects/ObjectDetails/__tests__/ObjectDetails.test.d.ts +1 -0
- package/dist/components/objects/ObjectDetails/__tests__/ObjectDetails.test.js +516 -0
- package/dist/components/objects/ObjectDetails/__tests__/ObjectSummary.test.d.ts +1 -0
- package/dist/components/objects/ObjectDetails/__tests__/ObjectSummary.test.js +1064 -0
- package/dist/components/objects/ObjectDetails/index.d.ts +18 -2
- package/dist/components/objects/ObjectDetails/index.js +152 -40
- package/dist/components/objects/ObjectList.d.ts +12 -10
- package/dist/components/objects/ObjectList.js +590 -263
- package/dist/components/objects/ObjectLock/EditRetentionButton.d.ts +4 -0
- package/dist/components/objects/ObjectLock/EditRetentionButton.js +32 -0
- package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.d.ts +3 -0
- package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.js +211 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettings.d.ts +9 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettings.js +159 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.d.ts +8 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.js +39 -0
- package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.d.ts +1 -0
- package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.js +204 -0
- package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.d.ts +1 -0
- package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.js +374 -0
- package/dist/components/objects/ObjectPage.js +12 -8
- package/dist/components/objects/UploadButton.d.ts +3 -3
- package/dist/components/objects/UploadButton.js +10 -10
- package/dist/components/objects/__tests__/GetPresignedUrlButton.test.d.ts +1 -0
- package/dist/components/objects/__tests__/GetPresignedUrlButton.test.js +531 -0
- 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 +21 -0
- package/dist/components/search/MetadataSearch.js +29 -28
- package/dist/components/search/SearchHints.js +1 -1
- package/dist/components/ui/ArrayFieldActions.d.ts +36 -0
- package/dist/components/ui/ArrayFieldActions.js +43 -0
- package/dist/components/ui/ConfirmDeleteRuleModal.d.ts +16 -0
- package/dist/components/ui/ConfirmDeleteRuleModal.js +48 -0
- package/dist/components/ui/DeleteObjectModalContent.d.ts +1 -1
- package/dist/components/ui/DeleteObjectModalContent.js +12 -12
- package/dist/components/ui/FilterFormSection.d.ts +44 -0
- package/dist/components/ui/FilterFormSection.js +159 -0
- package/dist/components/ui/Search.elements.d.ts +2 -2
- package/dist/components/ui/Search.elements.js +7 -7
- package/dist/components/ui/Table.elements.d.ts +2 -1
- package/dist/components/ui/Table.elements.js +18 -12
- package/dist/config/__tests__/factory.test.d.ts +1 -0
- package/dist/config/__tests__/factory.test.js +311 -0
- package/dist/config/factory.d.ts +14 -49
- package/dist/config/factory.js +23 -68
- package/dist/config/types.d.ts +212 -34
- package/dist/contexts/DataBrowserUICustomizationContext.d.ts +27 -0
- package/dist/contexts/DataBrowserUICustomizationContext.js +13 -0
- package/dist/hooks/__tests__/useAccessibleBuckets.test.d.ts +1 -0
- package/dist/hooks/__tests__/useAccessibleBuckets.test.js +145 -0
- package/dist/hooks/__tests__/useISVBucketDetection.test.d.ts +1 -0
- package/dist/hooks/__tests__/useISVBucketDetection.test.js +188 -0
- package/dist/hooks/__tests__/useIsBucketEmpty.test.js +27 -27
- package/dist/hooks/__tests__/useLoginMutation.test.d.ts +1 -0
- package/dist/hooks/__tests__/useLoginMutation.test.js +194 -0
- package/dist/hooks/bucketConfiguration.d.ts +8 -1
- package/dist/hooks/bucketConfiguration.js +52 -51
- package/dist/hooks/bucketOperations.d.ts +10 -1
- package/dist/hooks/bucketOperations.js +10 -9
- package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +80 -80
- package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +80 -80
- package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +44 -44
- package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +63 -63
- package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +95 -52
- package/dist/hooks/factories/index.d.ts +4 -4
- package/dist/hooks/factories/index.js +2 -2
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +16 -13
- package/dist/hooks/factories/useCreateS3LoginHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3LoginHook.js +1 -1
- package/dist/hooks/factories/useCreateS3MutationHook.d.ts +3 -3
- package/dist/hooks/factories/useCreateS3MutationHook.js +7 -2
- package/dist/hooks/factories/useCreateS3QueryHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3QueryHook.js +29 -3
- package/dist/hooks/index.d.ts +19 -8
- package/dist/hooks/index.js +16 -5
- 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 +50 -49
- package/dist/hooks/presignedOperations.d.ts +4 -4
- package/dist/hooks/presignedOperations.js +5 -5
- package/dist/hooks/useAccessibleBuckets.d.ts +11 -0
- package/dist/hooks/useAccessibleBuckets.js +115 -0
- package/dist/hooks/useBatchObjectLegalHold.d.ts +11 -0
- package/dist/hooks/useBatchObjectLegalHold.js +48 -0
- package/dist/hooks/useBucketConfigEditor.d.ts +31 -0
- package/dist/hooks/useBucketConfigEditor.js +82 -0
- package/dist/hooks/useDataBrowserNavigate.d.ts +28 -0
- package/dist/hooks/useDataBrowserNavigate.js +24 -0
- package/dist/hooks/useDeleteBucketConfigRule.d.ts +26 -0
- package/dist/hooks/useDeleteBucketConfigRule.js +46 -0
- package/dist/hooks/useEmptyBucket.d.ts +27 -0
- package/dist/hooks/useEmptyBucket.js +116 -0
- package/dist/hooks/useFeatures.d.ts +7 -0
- package/dist/hooks/useFeatures.js +8 -0
- package/dist/hooks/useISVBucketDetection.d.ts +15 -0
- package/dist/hooks/useISVBucketDetection.js +27 -0
- package/dist/hooks/useIsBucketEmpty.js +4 -4
- package/dist/hooks/useLimitedAccessFlow.d.ts +48 -0
- package/dist/hooks/useLimitedAccessFlow.js +23 -0
- 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/hooks/useTableRowSelection.d.ts +9 -0
- package/dist/hooks/useTableRowSelection.js +45 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +2 -2
- package/dist/schemas/bucketPolicySchema.json +3 -13
- 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 +32 -17
- 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 +77 -54
- package/dist/test/msw/index.d.ts +2 -2
- package/dist/test/msw/index.js +1 -1
- 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 +13 -30
- package/dist/test/testUtils.d.ts +170 -36
- package/dist/test/testUtils.js +229 -116
- package/dist/test/utils/errorHandling.test.js +146 -108
- package/dist/types/index.d.ts +49 -36
- package/dist/types/monaco.d.ts +13 -0
- package/dist/types/monaco.js +0 -0
- package/dist/utils/__tests__/proxyMiddleware.test.d.ts +1 -0
- package/dist/utils/__tests__/proxyMiddleware.test.js +579 -0
- package/dist/utils/__tests__/s3Client.test.d.ts +1 -0
- package/dist/utils/__tests__/s3Client.test.js +340 -0
- package/dist/utils/__tests__/s3ConfigIdentifier.test.d.ts +1 -0
- package/dist/utils/__tests__/s3ConfigIdentifier.test.js +437 -0
- package/dist/utils/constants.d.ts +22 -0
- package/dist/utils/constants.js +19 -0
- package/dist/utils/deletion/index.d.ts +2 -2
- package/dist/utils/deletion/index.js +1 -1
- package/dist/utils/deletion/messages.d.ts +1 -1
- package/dist/utils/deletion/messages.js +4 -4
- package/dist/utils/errorHandling.d.ts +12 -3
- package/dist/utils/errorHandling.js +12 -7
- package/dist/utils/hooks.js +8 -8
- package/dist/utils/index.d.ts +5 -2
- package/dist/utils/index.js +5 -1
- package/dist/utils/proxyMiddleware.d.ts +32 -13
- package/dist/utils/proxyMiddleware.js +90 -36
- package/dist/utils/s3Client.d.ts +14 -4
- package/dist/utils/s3Client.js +5 -26
- package/dist/utils/s3ConfigIdentifier.d.ts +79 -0
- package/dist/utils/s3ConfigIdentifier.js +57 -0
- package/dist/utils/s3RuleUtils.d.ts +53 -0
- package/dist/utils/s3RuleUtils.js +101 -0
- package/package.json +10 -8
- package/dist/components/__tests__/BucketNotificationCreatePage.test.js +0 -316
- package/dist/components/buckets/BucketPolicyButton.d.ts +0 -7
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.d.ts +0 -1
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.js +0 -234
- package/dist/hooks/useLoginMutation.d.ts +0 -21
- package/dist/hooks/useLoginMutation.js +0 -9
- package/dist/utils/useFeatures.d.ts +0 -1
- package/dist/utils/useFeatures.js +0 -7
- /package/dist/components/__tests__/{BucketNotificationCreatePage.test.d.ts → BucketAccessor.test.d.ts} +0 -0
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
3
|
-
import { MemoryRouter, Route, Routes } from "react-router
|
|
4
|
-
import {
|
|
3
|
+
import { MemoryRouter, Route, Routes } from "react-router";
|
|
4
|
+
import { useGetBucketPolicy, useISVBucketStatus, useSetBucketPolicy } from "../../hooks/index.js";
|
|
5
|
+
import { createMockMutationResult, createMockQueryResult, createTestWrapper } from "../../test/testUtils.js";
|
|
5
6
|
import { BucketPolicyPage } from "../buckets/BucketPolicyPage.js";
|
|
6
|
-
|
|
7
|
-
jest.mock("../../hooks", ()=>({
|
|
7
|
+
jest.mock('../../hooks', ()=>({
|
|
8
8
|
useGetBucketPolicy: jest.fn(),
|
|
9
|
-
useSetBucketPolicy: jest.fn()
|
|
9
|
+
useSetBucketPolicy: jest.fn(),
|
|
10
|
+
useISVBucketStatus: jest.fn(),
|
|
11
|
+
useBucketConfigEditor: jest.requireActual('../../hooks').useBucketConfigEditor
|
|
10
12
|
}));
|
|
11
|
-
jest.mock(
|
|
13
|
+
jest.mock('../Editor', ()=>({
|
|
12
14
|
Editor: ({ value, onChange })=>/*#__PURE__*/ jsx("textarea", {
|
|
13
15
|
"data-testid": "policy-editor",
|
|
14
16
|
value: value,
|
|
@@ -17,24 +19,36 @@ jest.mock("../Editor", ()=>({
|
|
|
17
19
|
}));
|
|
18
20
|
const mockUseGetBucketPolicy = jest.mocked(useGetBucketPolicy);
|
|
19
21
|
const mockUseSetBucketPolicy = jest.mocked(useSetBucketPolicy);
|
|
22
|
+
const mockUseISVBucketStatus = jest.mocked(useISVBucketStatus);
|
|
20
23
|
const mockNavigate = jest.fn();
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
const createNoSuchPolicyError = ()=>{
|
|
25
|
+
const error = new Error('Policy does not exist');
|
|
26
|
+
error.name = 'NoSuchBucketPolicy';
|
|
27
|
+
return error;
|
|
28
|
+
};
|
|
29
|
+
const mockNoPolicyExists = ()=>{
|
|
30
|
+
mockUseGetBucketPolicy.mockReturnValue(createMockQueryResult({
|
|
31
|
+
status: 'error',
|
|
32
|
+
error: createNoSuchPolicyError()
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
jest.mock('react-router', ()=>({
|
|
36
|
+
...jest.requireActual('react-router'),
|
|
23
37
|
useNavigate: ()=>mockNavigate
|
|
24
38
|
}));
|
|
25
39
|
const existingPolicy = {
|
|
26
|
-
Version:
|
|
40
|
+
Version: '2012-10-17',
|
|
27
41
|
Statement: [
|
|
28
42
|
{
|
|
29
|
-
Sid:
|
|
30
|
-
Effect:
|
|
31
|
-
Principal:
|
|
32
|
-
Action:
|
|
33
|
-
Resource:
|
|
43
|
+
Sid: 'ExistingStatement',
|
|
44
|
+
Effect: 'Allow',
|
|
45
|
+
Principal: '*',
|
|
46
|
+
Action: 's3:GetObject',
|
|
47
|
+
Resource: 'arn:aws:s3:::test-bucket/*'
|
|
34
48
|
}
|
|
35
49
|
]
|
|
36
50
|
};
|
|
37
|
-
const renderBucketPolicyPage = (bucketName =
|
|
51
|
+
const renderBucketPolicyPage = (bucketName = 'test-bucket')=>{
|
|
38
52
|
const Wrapper = createTestWrapper();
|
|
39
53
|
return render(/*#__PURE__*/ jsx(MemoryRouter, {
|
|
40
54
|
initialEntries: [
|
|
@@ -50,90 +64,77 @@ const renderBucketPolicyPage = (bucketName = "test-bucket")=>{
|
|
|
50
64
|
})
|
|
51
65
|
}));
|
|
52
66
|
};
|
|
53
|
-
describe(
|
|
67
|
+
describe('BucketPolicyPage', ()=>{
|
|
54
68
|
const mockMutate = jest.fn();
|
|
55
69
|
beforeEach(()=>{
|
|
56
70
|
jest.clearAllMocks();
|
|
57
71
|
mockNavigate.mockClear();
|
|
58
|
-
mockUseSetBucketPolicy.mockReturnValue(
|
|
59
|
-
|
|
60
|
-
|
|
72
|
+
mockUseSetBucketPolicy.mockReturnValue(createMockMutationResult(mockMutate));
|
|
73
|
+
mockUseISVBucketStatus.mockReturnValue({
|
|
74
|
+
isVeeamBucket: false,
|
|
75
|
+
isCommvaultBucket: false,
|
|
76
|
+
isISVManaged: false,
|
|
77
|
+
isvApplication: void 0,
|
|
78
|
+
isLoading: false,
|
|
79
|
+
bucketTagsStatus: 'success'
|
|
61
80
|
});
|
|
62
81
|
});
|
|
63
|
-
it(
|
|
64
|
-
mockUseGetBucketPolicy.mockReturnValue({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
error: null
|
|
68
|
-
});
|
|
82
|
+
it('shows loading state while fetching policy', ()=>{
|
|
83
|
+
mockUseGetBucketPolicy.mockReturnValue(createMockQueryResult({
|
|
84
|
+
status: 'pending'
|
|
85
|
+
}));
|
|
69
86
|
renderBucketPolicyPage();
|
|
70
|
-
expect(screen.getByText(
|
|
87
|
+
expect(screen.getByText('Loading policy...')).toBeInTheDocument();
|
|
71
88
|
});
|
|
72
|
-
it(
|
|
73
|
-
|
|
74
|
-
noSuchPolicyError.name = "NoSuchBucketPolicy";
|
|
75
|
-
mockUseGetBucketPolicy.mockReturnValue({
|
|
76
|
-
data: void 0,
|
|
77
|
-
status: "error",
|
|
78
|
-
error: noSuchPolicyError
|
|
79
|
-
});
|
|
89
|
+
it('renders create mode with default policy template when no policy exists', async ()=>{
|
|
90
|
+
mockNoPolicyExists();
|
|
80
91
|
renderBucketPolicyPage();
|
|
81
92
|
await waitFor(()=>{
|
|
82
|
-
expect(screen.getByText(
|
|
93
|
+
expect(screen.getByText('Create Bucket Policy')).toBeInTheDocument();
|
|
83
94
|
});
|
|
84
|
-
const editor = screen.getByTestId(
|
|
85
|
-
expect(editor.value).toContain(
|
|
95
|
+
const editor = screen.getByTestId('policy-editor');
|
|
96
|
+
expect(editor.value).toContain('ExampleStatement');
|
|
86
97
|
});
|
|
87
|
-
it(
|
|
88
|
-
mockUseGetBucketPolicy.mockReturnValue({
|
|
98
|
+
it('renders edit mode with existing policy', async ()=>{
|
|
99
|
+
mockUseGetBucketPolicy.mockReturnValue(createMockQueryResult({
|
|
89
100
|
data: {
|
|
90
|
-
Policy: JSON.stringify(existingPolicy)
|
|
101
|
+
Policy: JSON.stringify(existingPolicy),
|
|
102
|
+
$metadata: {}
|
|
91
103
|
},
|
|
92
|
-
status:
|
|
93
|
-
|
|
94
|
-
});
|
|
104
|
+
status: 'success'
|
|
105
|
+
}));
|
|
95
106
|
renderBucketPolicyPage();
|
|
96
107
|
await waitFor(()=>{
|
|
97
|
-
expect(screen.getByText(
|
|
108
|
+
expect(screen.getByText('Edit Bucket Policy')).toBeInTheDocument();
|
|
98
109
|
});
|
|
99
|
-
const editor = screen.getByTestId(
|
|
110
|
+
const editor = screen.getByTestId('policy-editor');
|
|
100
111
|
expect(JSON.parse(editor.value)).toEqual(existingPolicy);
|
|
101
112
|
});
|
|
102
|
-
it(
|
|
103
|
-
|
|
104
|
-
noSuchPolicyError.name = "NoSuchBucketPolicy";
|
|
105
|
-
mockUseGetBucketPolicy.mockReturnValue({
|
|
106
|
-
data: void 0,
|
|
107
|
-
status: "error",
|
|
108
|
-
error: noSuchPolicyError
|
|
109
|
-
});
|
|
113
|
+
it('disables save button for invalid JSON format', async ()=>{
|
|
114
|
+
mockNoPolicyExists();
|
|
110
115
|
renderBucketPolicyPage();
|
|
111
116
|
await waitFor(()=>{
|
|
112
|
-
expect(screen.getByTestId(
|
|
117
|
+
expect(screen.getByTestId('policy-editor')).toBeInTheDocument();
|
|
113
118
|
});
|
|
114
|
-
const editor = screen.getByTestId(
|
|
119
|
+
const editor = screen.getByTestId('policy-editor');
|
|
115
120
|
fireEvent.change(editor, {
|
|
116
121
|
target: {
|
|
117
|
-
value:
|
|
122
|
+
value: '{ invalid json'
|
|
118
123
|
}
|
|
119
124
|
});
|
|
120
125
|
await waitFor(()=>{
|
|
121
|
-
expect(screen.
|
|
126
|
+
expect(screen.getByRole('button', {
|
|
127
|
+
name: /save/i
|
|
128
|
+
})).toBeDisabled();
|
|
122
129
|
});
|
|
123
130
|
});
|
|
124
|
-
it(
|
|
125
|
-
|
|
126
|
-
noSuchPolicyError.name = "NoSuchBucketPolicy";
|
|
127
|
-
mockUseGetBucketPolicy.mockReturnValue({
|
|
128
|
-
data: void 0,
|
|
129
|
-
status: "error",
|
|
130
|
-
error: noSuchPolicyError
|
|
131
|
-
});
|
|
131
|
+
it('saves valid policy and navigates back on success', async ()=>{
|
|
132
|
+
mockNoPolicyExists();
|
|
132
133
|
renderBucketPolicyPage();
|
|
133
134
|
await waitFor(()=>{
|
|
134
|
-
expect(screen.getByTestId(
|
|
135
|
+
expect(screen.getByTestId('policy-editor')).toBeInTheDocument();
|
|
135
136
|
});
|
|
136
|
-
const editor = screen.getByTestId(
|
|
137
|
+
const editor = screen.getByTestId('policy-editor');
|
|
137
138
|
const validPolicy = JSON.stringify(existingPolicy, null, 2);
|
|
138
139
|
fireEvent.change(editor, {
|
|
139
140
|
target: {
|
|
@@ -143,71 +144,122 @@ describe("BucketPolicyPage", ()=>{
|
|
|
143
144
|
mockMutate.mockImplementation((_, options)=>{
|
|
144
145
|
options?.onSuccess?.();
|
|
145
146
|
});
|
|
146
|
-
const saveButton = screen.getByRole(
|
|
147
|
+
const saveButton = screen.getByRole('button', {
|
|
147
148
|
name: /save/i
|
|
148
149
|
});
|
|
149
|
-
await waitFor(()=>{
|
|
150
|
-
expect(saveButton).not.toBeDisabled();
|
|
151
|
-
});
|
|
152
150
|
fireEvent.click(saveButton);
|
|
153
151
|
await waitFor(()=>{
|
|
154
152
|
expect(mockMutate).toHaveBeenCalledWith({
|
|
155
|
-
Bucket:
|
|
153
|
+
Bucket: 'test-bucket',
|
|
156
154
|
Policy: JSON.stringify(existingPolicy)
|
|
157
155
|
}, expect.any(Object));
|
|
158
|
-
expect(mockNavigate).toHaveBeenCalledWith(
|
|
156
|
+
expect(mockNavigate).toHaveBeenCalledWith('/buckets/test-bucket');
|
|
159
157
|
});
|
|
160
158
|
});
|
|
161
|
-
it(
|
|
162
|
-
|
|
163
|
-
noSuchPolicyError.name = "NoSuchBucketPolicy";
|
|
164
|
-
mockUseGetBucketPolicy.mockReturnValue({
|
|
165
|
-
data: void 0,
|
|
166
|
-
status: "error",
|
|
167
|
-
error: noSuchPolicyError
|
|
168
|
-
});
|
|
159
|
+
it('stays on page and displays error message when save fails', async ()=>{
|
|
160
|
+
mockNoPolicyExists();
|
|
169
161
|
renderBucketPolicyPage();
|
|
170
162
|
await waitFor(()=>{
|
|
171
|
-
expect(screen.getByTestId(
|
|
163
|
+
expect(screen.getByTestId('policy-editor')).toBeInTheDocument();
|
|
172
164
|
});
|
|
173
|
-
const editor = screen.getByTestId(
|
|
165
|
+
const editor = screen.getByTestId('policy-editor');
|
|
174
166
|
const validPolicy = JSON.stringify(existingPolicy, null, 2);
|
|
175
167
|
fireEvent.change(editor, {
|
|
176
168
|
target: {
|
|
177
169
|
value: validPolicy
|
|
178
170
|
}
|
|
179
171
|
});
|
|
180
|
-
const saveError = new Error(
|
|
172
|
+
const saveError = new Error('Access Denied');
|
|
181
173
|
mockMutate.mockImplementation((_, options)=>{
|
|
182
174
|
options?.onError?.(saveError);
|
|
183
175
|
});
|
|
184
|
-
const saveButton = screen.getByRole(
|
|
176
|
+
const saveButton = screen.getByRole('button', {
|
|
185
177
|
name: /save/i
|
|
186
178
|
});
|
|
187
|
-
await waitFor(()=>{
|
|
188
|
-
expect(saveButton).not.toBeDisabled();
|
|
189
|
-
});
|
|
190
179
|
fireEvent.click(saveButton);
|
|
191
180
|
await waitFor(()=>{
|
|
192
|
-
expect(screen.getByText(/Save policy error: Access Denied/i)).toBeInTheDocument();
|
|
193
181
|
expect(mockNavigate).not.toHaveBeenCalled();
|
|
182
|
+
expect(screen.getByText('Access Denied')).toBeInTheDocument();
|
|
194
183
|
});
|
|
195
184
|
});
|
|
196
|
-
it(
|
|
197
|
-
|
|
198
|
-
noSuchPolicyError.name = "NoSuchBucketPolicy";
|
|
199
|
-
mockUseGetBucketPolicy.mockReturnValue({
|
|
200
|
-
data: void 0,
|
|
201
|
-
status: "error",
|
|
202
|
-
error: noSuchPolicyError
|
|
203
|
-
});
|
|
185
|
+
it('handles cancel button click and navigates back', async ()=>{
|
|
186
|
+
mockNoPolicyExists();
|
|
204
187
|
renderBucketPolicyPage();
|
|
205
188
|
await waitFor(()=>{
|
|
206
|
-
const cancelButton = screen.getByRole(
|
|
189
|
+
const cancelButton = screen.getByRole('button', {
|
|
207
190
|
name: /cancel/i
|
|
208
191
|
});
|
|
209
192
|
fireEvent.click(cancelButton);
|
|
210
193
|
});
|
|
211
|
-
expect(mockNavigate).toHaveBeenCalledWith(
|
|
194
|
+
expect(mockNavigate).toHaveBeenCalledWith('/buckets/test-bucket');
|
|
195
|
+
});
|
|
196
|
+
it('shows loading state when ISV bucket status is loading', ()=>{
|
|
197
|
+
mockUseGetBucketPolicy.mockReturnValue(createMockQueryResult({
|
|
198
|
+
status: 'success',
|
|
199
|
+
data: {
|
|
200
|
+
Policy: JSON.stringify(existingPolicy),
|
|
201
|
+
$metadata: {}
|
|
202
|
+
}
|
|
203
|
+
}));
|
|
204
|
+
mockUseISVBucketStatus.mockReturnValue({
|
|
205
|
+
isVeeamBucket: false,
|
|
206
|
+
isCommvaultBucket: false,
|
|
207
|
+
isISVManaged: false,
|
|
208
|
+
isvApplication: void 0,
|
|
209
|
+
isLoading: true,
|
|
210
|
+
bucketTagsStatus: 'pending'
|
|
211
|
+
});
|
|
212
|
+
renderBucketPolicyPage();
|
|
213
|
+
expect(screen.getByText('Loading policy...')).toBeInTheDocument();
|
|
214
|
+
});
|
|
215
|
+
it('displays warning banner when bucket is managed by Veeam', async ()=>{
|
|
216
|
+
mockNoPolicyExists();
|
|
217
|
+
mockUseISVBucketStatus.mockReturnValue({
|
|
218
|
+
isVeeamBucket: true,
|
|
219
|
+
isCommvaultBucket: false,
|
|
220
|
+
isISVManaged: true,
|
|
221
|
+
isvApplication: 'Veeam',
|
|
222
|
+
isLoading: false,
|
|
223
|
+
bucketTagsStatus: 'success'
|
|
224
|
+
});
|
|
225
|
+
renderBucketPolicyPage();
|
|
226
|
+
await waitFor(()=>{
|
|
227
|
+
expect(screen.getByTestId('policy-editor')).toBeInTheDocument();
|
|
228
|
+
});
|
|
229
|
+
expect(screen.getByText(/Warning:/i)).toBeInTheDocument();
|
|
230
|
+
expect(screen.getByText(/Veeam/i)).toBeInTheDocument();
|
|
231
|
+
});
|
|
232
|
+
it('displays warning banner when bucket is managed by Commvault', async ()=>{
|
|
233
|
+
mockNoPolicyExists();
|
|
234
|
+
mockUseISVBucketStatus.mockReturnValue({
|
|
235
|
+
isVeeamBucket: false,
|
|
236
|
+
isCommvaultBucket: true,
|
|
237
|
+
isISVManaged: true,
|
|
238
|
+
isvApplication: 'Commvault',
|
|
239
|
+
isLoading: false,
|
|
240
|
+
bucketTagsStatus: 'success'
|
|
241
|
+
});
|
|
242
|
+
renderBucketPolicyPage();
|
|
243
|
+
await waitFor(()=>{
|
|
244
|
+
expect(screen.getByTestId('policy-editor')).toBeInTheDocument();
|
|
245
|
+
});
|
|
246
|
+
expect(screen.getByText(/Warning:/i)).toBeInTheDocument();
|
|
247
|
+
expect(screen.getByText(/Commvault/i)).toBeInTheDocument();
|
|
248
|
+
});
|
|
249
|
+
it('does not display warning banner when bucket is not ISV managed', async ()=>{
|
|
250
|
+
mockNoPolicyExists();
|
|
251
|
+
mockUseISVBucketStatus.mockReturnValue({
|
|
252
|
+
isVeeamBucket: false,
|
|
253
|
+
isCommvaultBucket: false,
|
|
254
|
+
isISVManaged: false,
|
|
255
|
+
isvApplication: void 0,
|
|
256
|
+
isLoading: false,
|
|
257
|
+
bucketTagsStatus: 'success'
|
|
258
|
+
});
|
|
259
|
+
renderBucketPolicyPage();
|
|
260
|
+
await waitFor(()=>{
|
|
261
|
+
expect(screen.getByTestId('policy-editor')).toBeInTheDocument();
|
|
262
|
+
});
|
|
263
|
+
expect(screen.queryByText((_content, element)=>element?.textContent?.includes('This bucket is managed by') || false)).not.toBeInTheDocument();
|
|
212
264
|
});
|
|
213
265
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Comprehensive tests for BucketReplicationFormPage component
|
|
3
|
+
*
|
|
4
|
+
* This test suite covers:
|
|
5
|
+
* - Page rendering (create/edit modes, loading states, error states)
|
|
6
|
+
* - Form fields (initial state, field visibility, conditional rendering)
|
|
7
|
+
* - Form validation (required fields, uniqueness, format validation)
|
|
8
|
+
* - Automatic field behaviors (encryption, RTC, delete marker, conditional fields)
|
|
9
|
+
* - Form submission (create/edit modes, success/error handling, navigation)
|
|
10
|
+
* - Rule data loading (various filter types, configurations)
|
|
11
|
+
* - Edge cases (URL encoding, missing fields, special characters)
|
|
12
|
+
* - Boundary conditions (max lengths, extreme values, format validation)
|
|
13
|
+
*
|
|
14
|
+
* @see BucketReplicationFormPage for the component implementation
|
|
15
|
+
*/
|
|
16
|
+
export {};
|