@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
|
@@ -1,15 +1,15 @@
|
|
|
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
|
|
3
|
+
import { MemoryRouter, Route, Routes } from "react-router";
|
|
4
4
|
import { createMockMutationResult, createMockQueryResult, createTestWrapper } from "../../test/testUtils.js";
|
|
5
5
|
import { BucketPolicyPage } from "../buckets/BucketPolicyPage.js";
|
|
6
6
|
import { useGetBucketPolicy, useISVBucketStatus, useSetBucketPolicy } from "../../hooks/index.js";
|
|
7
|
-
jest.mock(
|
|
7
|
+
jest.mock('../../hooks', ()=>({
|
|
8
8
|
useGetBucketPolicy: jest.fn(),
|
|
9
9
|
useSetBucketPolicy: jest.fn(),
|
|
10
10
|
useISVBucketStatus: jest.fn()
|
|
11
11
|
}));
|
|
12
|
-
jest.mock(
|
|
12
|
+
jest.mock('../Editor', ()=>({
|
|
13
13
|
Editor: ({ value, onChange })=>/*#__PURE__*/ jsx("textarea", {
|
|
14
14
|
"data-testid": "policy-editor",
|
|
15
15
|
value: value,
|
|
@@ -21,33 +21,33 @@ const mockUseSetBucketPolicy = jest.mocked(useSetBucketPolicy);
|
|
|
21
21
|
const mockUseISVBucketStatus = jest.mocked(useISVBucketStatus);
|
|
22
22
|
const mockNavigate = jest.fn();
|
|
23
23
|
const createNoSuchPolicyError = ()=>{
|
|
24
|
-
const error = new Error(
|
|
25
|
-
error.name =
|
|
24
|
+
const error = new Error('Policy does not exist');
|
|
25
|
+
error.name = 'NoSuchBucketPolicy';
|
|
26
26
|
return error;
|
|
27
27
|
};
|
|
28
28
|
const mockNoPolicyExists = ()=>{
|
|
29
29
|
mockUseGetBucketPolicy.mockReturnValue(createMockQueryResult({
|
|
30
|
-
status:
|
|
30
|
+
status: 'error',
|
|
31
31
|
error: createNoSuchPolicyError()
|
|
32
32
|
}));
|
|
33
33
|
};
|
|
34
|
-
jest.mock(
|
|
35
|
-
...jest.requireActual(
|
|
34
|
+
jest.mock('react-router', ()=>({
|
|
35
|
+
...jest.requireActual('react-router'),
|
|
36
36
|
useNavigate: ()=>mockNavigate
|
|
37
37
|
}));
|
|
38
38
|
const existingPolicy = {
|
|
39
|
-
Version:
|
|
39
|
+
Version: '2012-10-17',
|
|
40
40
|
Statement: [
|
|
41
41
|
{
|
|
42
|
-
Sid:
|
|
43
|
-
Effect:
|
|
44
|
-
Principal:
|
|
45
|
-
Action:
|
|
46
|
-
Resource:
|
|
42
|
+
Sid: 'ExistingStatement',
|
|
43
|
+
Effect: 'Allow',
|
|
44
|
+
Principal: '*',
|
|
45
|
+
Action: 's3:GetObject',
|
|
46
|
+
Resource: 'arn:aws:s3:::test-bucket/*'
|
|
47
47
|
}
|
|
48
48
|
]
|
|
49
49
|
};
|
|
50
|
-
const renderBucketPolicyPage = (bucketName =
|
|
50
|
+
const renderBucketPolicyPage = (bucketName = 'test-bucket')=>{
|
|
51
51
|
const Wrapper = createTestWrapper();
|
|
52
52
|
return render(/*#__PURE__*/ jsx(MemoryRouter, {
|
|
53
53
|
initialEntries: [
|
|
@@ -63,7 +63,7 @@ const renderBucketPolicyPage = (bucketName = "test-bucket")=>{
|
|
|
63
63
|
})
|
|
64
64
|
}));
|
|
65
65
|
};
|
|
66
|
-
describe(
|
|
66
|
+
describe('BucketPolicyPage', ()=>{
|
|
67
67
|
const mockMutate = jest.fn();
|
|
68
68
|
beforeEach(()=>{
|
|
69
69
|
jest.clearAllMocks();
|
|
@@ -75,63 +75,63 @@ describe("BucketPolicyPage", ()=>{
|
|
|
75
75
|
isISVManaged: false,
|
|
76
76
|
isvApplication: void 0,
|
|
77
77
|
isLoading: false,
|
|
78
|
-
bucketTagsStatus:
|
|
78
|
+
bucketTagsStatus: 'success'
|
|
79
79
|
});
|
|
80
80
|
});
|
|
81
|
-
it(
|
|
81
|
+
it('shows loading state while fetching policy', ()=>{
|
|
82
82
|
mockUseGetBucketPolicy.mockReturnValue(createMockQueryResult({
|
|
83
|
-
status:
|
|
83
|
+
status: 'pending'
|
|
84
84
|
}));
|
|
85
85
|
renderBucketPolicyPage();
|
|
86
|
-
expect(screen.getByText(
|
|
86
|
+
expect(screen.getByText('Loading policy...')).toBeInTheDocument();
|
|
87
87
|
});
|
|
88
|
-
it(
|
|
88
|
+
it('renders create mode with default policy template when no policy exists', async ()=>{
|
|
89
89
|
mockNoPolicyExists();
|
|
90
90
|
renderBucketPolicyPage();
|
|
91
91
|
await waitFor(()=>{
|
|
92
|
-
expect(screen.getByText(
|
|
92
|
+
expect(screen.getByText('Bucket Policy Creation')).toBeInTheDocument();
|
|
93
93
|
});
|
|
94
|
-
const editor = screen.getByTestId(
|
|
95
|
-
expect(editor.value).toContain(
|
|
94
|
+
const editor = screen.getByTestId('policy-editor');
|
|
95
|
+
expect(editor.value).toContain('ExampleStatement');
|
|
96
96
|
});
|
|
97
|
-
it(
|
|
97
|
+
it('renders edit mode with existing policy', async ()=>{
|
|
98
98
|
mockUseGetBucketPolicy.mockReturnValue(createMockQueryResult({
|
|
99
99
|
data: {
|
|
100
100
|
Policy: JSON.stringify(existingPolicy),
|
|
101
101
|
$metadata: {}
|
|
102
102
|
},
|
|
103
|
-
status:
|
|
103
|
+
status: 'success'
|
|
104
104
|
}));
|
|
105
105
|
renderBucketPolicyPage();
|
|
106
106
|
await waitFor(()=>{
|
|
107
|
-
expect(screen.getByText(
|
|
107
|
+
expect(screen.getByText('Bucket Policy Edition')).toBeInTheDocument();
|
|
108
108
|
});
|
|
109
|
-
const editor = screen.getByTestId(
|
|
109
|
+
const editor = screen.getByTestId('policy-editor');
|
|
110
110
|
expect(JSON.parse(editor.value)).toEqual(existingPolicy);
|
|
111
111
|
});
|
|
112
|
-
it(
|
|
112
|
+
it('validates JSON format and shows error for invalid input', async ()=>{
|
|
113
113
|
mockNoPolicyExists();
|
|
114
114
|
renderBucketPolicyPage();
|
|
115
115
|
await waitFor(()=>{
|
|
116
|
-
expect(screen.getByTestId(
|
|
116
|
+
expect(screen.getByTestId('policy-editor')).toBeInTheDocument();
|
|
117
117
|
});
|
|
118
|
-
const editor = screen.getByTestId(
|
|
118
|
+
const editor = screen.getByTestId('policy-editor');
|
|
119
119
|
fireEvent.change(editor, {
|
|
120
120
|
target: {
|
|
121
|
-
value:
|
|
121
|
+
value: '{ invalid json'
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
124
|
await waitFor(()=>{
|
|
125
125
|
expect(screen.getByText(/Invalid JSON format/i)).toBeInTheDocument();
|
|
126
126
|
});
|
|
127
127
|
});
|
|
128
|
-
it(
|
|
128
|
+
it('saves valid policy and navigates back on success', async ()=>{
|
|
129
129
|
mockNoPolicyExists();
|
|
130
130
|
renderBucketPolicyPage();
|
|
131
131
|
await waitFor(()=>{
|
|
132
|
-
expect(screen.getByTestId(
|
|
132
|
+
expect(screen.getByTestId('policy-editor')).toBeInTheDocument();
|
|
133
133
|
});
|
|
134
|
-
const editor = screen.getByTestId(
|
|
134
|
+
const editor = screen.getByTestId('policy-editor');
|
|
135
135
|
const validPolicy = JSON.stringify(existingPolicy, null, 2);
|
|
136
136
|
fireEvent.change(editor, {
|
|
137
137
|
target: {
|
|
@@ -141,7 +141,7 @@ describe("BucketPolicyPage", ()=>{
|
|
|
141
141
|
mockMutate.mockImplementation((_, options)=>{
|
|
142
142
|
options?.onSuccess?.();
|
|
143
143
|
});
|
|
144
|
-
const saveButton = screen.getByRole(
|
|
144
|
+
const saveButton = screen.getByRole('button', {
|
|
145
145
|
name: /save/i
|
|
146
146
|
});
|
|
147
147
|
await waitFor(()=>{
|
|
@@ -150,30 +150,30 @@ describe("BucketPolicyPage", ()=>{
|
|
|
150
150
|
fireEvent.click(saveButton);
|
|
151
151
|
await waitFor(()=>{
|
|
152
152
|
expect(mockMutate).toHaveBeenCalledWith({
|
|
153
|
-
Bucket:
|
|
153
|
+
Bucket: 'test-bucket',
|
|
154
154
|
Policy: JSON.stringify(existingPolicy)
|
|
155
155
|
}, expect.any(Object));
|
|
156
|
-
expect(mockNavigate).toHaveBeenCalledWith(
|
|
156
|
+
expect(mockNavigate).toHaveBeenCalledWith('/buckets/test-bucket');
|
|
157
157
|
});
|
|
158
158
|
});
|
|
159
|
-
it(
|
|
159
|
+
it('displays error message when save fails', async ()=>{
|
|
160
160
|
mockNoPolicyExists();
|
|
161
161
|
renderBucketPolicyPage();
|
|
162
162
|
await waitFor(()=>{
|
|
163
|
-
expect(screen.getByTestId(
|
|
163
|
+
expect(screen.getByTestId('policy-editor')).toBeInTheDocument();
|
|
164
164
|
});
|
|
165
|
-
const editor = screen.getByTestId(
|
|
165
|
+
const editor = screen.getByTestId('policy-editor');
|
|
166
166
|
const validPolicy = JSON.stringify(existingPolicy, null, 2);
|
|
167
167
|
fireEvent.change(editor, {
|
|
168
168
|
target: {
|
|
169
169
|
value: validPolicy
|
|
170
170
|
}
|
|
171
171
|
});
|
|
172
|
-
const saveError = new Error(
|
|
172
|
+
const saveError = new Error('Access Denied');
|
|
173
173
|
mockMutate.mockImplementation((_, options)=>{
|
|
174
174
|
options?.onError?.(saveError);
|
|
175
175
|
});
|
|
176
|
-
const saveButton = screen.getByRole(
|
|
176
|
+
const saveButton = screen.getByRole('button', {
|
|
177
177
|
name: /save/i
|
|
178
178
|
});
|
|
179
179
|
await waitFor(()=>{
|
|
@@ -185,20 +185,20 @@ describe("BucketPolicyPage", ()=>{
|
|
|
185
185
|
expect(mockNavigate).not.toHaveBeenCalled();
|
|
186
186
|
});
|
|
187
187
|
});
|
|
188
|
-
it(
|
|
188
|
+
it('handles cancel button click and navigates back', async ()=>{
|
|
189
189
|
mockNoPolicyExists();
|
|
190
190
|
renderBucketPolicyPage();
|
|
191
191
|
await waitFor(()=>{
|
|
192
|
-
const cancelButton = screen.getByRole(
|
|
192
|
+
const cancelButton = screen.getByRole('button', {
|
|
193
193
|
name: /cancel/i
|
|
194
194
|
});
|
|
195
195
|
fireEvent.click(cancelButton);
|
|
196
196
|
});
|
|
197
|
-
expect(mockNavigate).toHaveBeenCalledWith(
|
|
197
|
+
expect(mockNavigate).toHaveBeenCalledWith('/buckets/test-bucket');
|
|
198
198
|
});
|
|
199
|
-
it(
|
|
199
|
+
it('shows loading state when ISV bucket status is loading', ()=>{
|
|
200
200
|
mockUseGetBucketPolicy.mockReturnValue(createMockQueryResult({
|
|
201
|
-
status:
|
|
201
|
+
status: 'success',
|
|
202
202
|
data: {
|
|
203
203
|
Policy: JSON.stringify(existingPolicy),
|
|
204
204
|
$metadata: {}
|
|
@@ -210,46 +210,46 @@ describe("BucketPolicyPage", ()=>{
|
|
|
210
210
|
isISVManaged: false,
|
|
211
211
|
isvApplication: void 0,
|
|
212
212
|
isLoading: true,
|
|
213
|
-
bucketTagsStatus:
|
|
213
|
+
bucketTagsStatus: 'pending'
|
|
214
214
|
});
|
|
215
215
|
renderBucketPolicyPage();
|
|
216
|
-
expect(screen.getByText(
|
|
216
|
+
expect(screen.getByText('Loading policy...')).toBeInTheDocument();
|
|
217
217
|
});
|
|
218
|
-
it(
|
|
218
|
+
it('displays warning banner when bucket is managed by Veeam', async ()=>{
|
|
219
219
|
mockNoPolicyExists();
|
|
220
220
|
mockUseISVBucketStatus.mockReturnValue({
|
|
221
221
|
isVeeamBucket: true,
|
|
222
222
|
isCommvaultBucket: false,
|
|
223
223
|
isISVManaged: true,
|
|
224
|
-
isvApplication:
|
|
224
|
+
isvApplication: 'Veeam',
|
|
225
225
|
isLoading: false,
|
|
226
|
-
bucketTagsStatus:
|
|
226
|
+
bucketTagsStatus: 'success'
|
|
227
227
|
});
|
|
228
228
|
renderBucketPolicyPage();
|
|
229
229
|
await waitFor(()=>{
|
|
230
|
-
expect(screen.getByTestId(
|
|
230
|
+
expect(screen.getByTestId('policy-editor')).toBeInTheDocument();
|
|
231
231
|
});
|
|
232
232
|
expect(screen.getByText(/Warning:/i)).toBeInTheDocument();
|
|
233
233
|
expect(screen.getByText(/Veeam/i)).toBeInTheDocument();
|
|
234
234
|
});
|
|
235
|
-
it(
|
|
235
|
+
it('displays warning banner when bucket is managed by Commvault', async ()=>{
|
|
236
236
|
mockNoPolicyExists();
|
|
237
237
|
mockUseISVBucketStatus.mockReturnValue({
|
|
238
238
|
isVeeamBucket: false,
|
|
239
239
|
isCommvaultBucket: true,
|
|
240
240
|
isISVManaged: true,
|
|
241
|
-
isvApplication:
|
|
241
|
+
isvApplication: 'Commvault',
|
|
242
242
|
isLoading: false,
|
|
243
|
-
bucketTagsStatus:
|
|
243
|
+
bucketTagsStatus: 'success'
|
|
244
244
|
});
|
|
245
245
|
renderBucketPolicyPage();
|
|
246
246
|
await waitFor(()=>{
|
|
247
|
-
expect(screen.getByTestId(
|
|
247
|
+
expect(screen.getByTestId('policy-editor')).toBeInTheDocument();
|
|
248
248
|
});
|
|
249
249
|
expect(screen.getByText(/Warning:/i)).toBeInTheDocument();
|
|
250
250
|
expect(screen.getByText(/Commvault/i)).toBeInTheDocument();
|
|
251
251
|
});
|
|
252
|
-
it(
|
|
252
|
+
it('does not display warning banner when bucket is not ISV managed', async ()=>{
|
|
253
253
|
mockNoPolicyExists();
|
|
254
254
|
mockUseISVBucketStatus.mockReturnValue({
|
|
255
255
|
isVeeamBucket: false,
|
|
@@ -257,12 +257,12 @@ describe("BucketPolicyPage", ()=>{
|
|
|
257
257
|
isISVManaged: false,
|
|
258
258
|
isvApplication: void 0,
|
|
259
259
|
isLoading: false,
|
|
260
|
-
bucketTagsStatus:
|
|
260
|
+
bucketTagsStatus: 'success'
|
|
261
261
|
});
|
|
262
262
|
renderBucketPolicyPage();
|
|
263
263
|
await waitFor(()=>{
|
|
264
|
-
expect(screen.getByTestId(
|
|
264
|
+
expect(screen.getByTestId('policy-editor')).toBeInTheDocument();
|
|
265
265
|
});
|
|
266
|
-
expect(screen.queryByText((_content, element)=>element?.textContent?.includes(
|
|
266
|
+
expect(screen.queryByText((_content, element)=>element?.textContent?.includes('This bucket is managed by') || false)).not.toBeInTheDocument();
|
|
267
267
|
});
|
|
268
268
|
});
|