From ce5e2a3ee62154516d52e3128fd4952714bb7ebf Mon Sep 17 00:00:00 2001 From: YanJin Date: Mon, 4 Sep 2023 17:16:46 +0200 Subject: [PATCH 1/3] ZKUI-376: reset the form value --- src/react/workflow/ConfigurationTab.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/react/workflow/ConfigurationTab.tsx b/src/react/workflow/ConfigurationTab.tsx index 504a2cb30..56f9699ae 100644 --- a/src/react/workflow/ConfigurationTab.tsx +++ b/src/react/workflow/ConfigurationTab.tsx @@ -1,4 +1,4 @@ -import { useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { FormProvider, useForm } from 'react-hook-form'; import { useHistory } from 'react-router-dom'; @@ -524,6 +524,15 @@ function EditForm({ }); const { formState, handleSubmit, reset } = useFormMethods; + useEffect(() => { + if (workflow && isExpirationWorkflow(workflow)) { + reset(initDefaultValues(workflow)); + } else if (workflow && isTransitionWorkflow(workflow)) { + reset(initTransitionDefaultValue(workflow)); + } else { + reset(convertToReplicationForm(workflow)); + } + }, [workflow, reset]); const { deleteReplicationMutation, editReplicationWorkflowMutation } = useReplicationMutations({ From eaf57c54ec5750de3c6cd0dd2f576365d204462f Mon Sep 17 00:00:00 2001 From: YanJin Date: Fri, 8 Sep 2023 16:26:27 +0200 Subject: [PATCH 2/3] ZKUI-376: Fix the issue of display wrong bucket after a new account creation --- src/react/actions/account.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/react/actions/account.ts b/src/react/actions/account.ts index 4abeb3ea8..d54f7f4d6 100644 --- a/src/react/actions/account.ts +++ b/src/react/actions/account.ts @@ -103,6 +103,7 @@ export function createAccount( .then(() => { queryClient.refetchQueries(['accounts']); queryClient.invalidateQueries(['WebIdentityRoles', token]); + queryClient.invalidateQueries(['s3AssumeRoleClient']); }) .catch((error) => dispatch(handleClientError(error))) .catch((error) => dispatch(handleApiError(error, 'byComponent'))) From 38ea5514c4d0b929bdec6c6fcfa8f419a8f3007a Mon Sep 17 00:00:00 2001 From: YanJin Date: Fri, 8 Sep 2023 18:06:07 +0200 Subject: [PATCH 3/3] ZKUI-376: Add test for the expiration of previous version --- src/js/mock/managementClientMSWHandlers.ts | 13 ++++++ src/react/workflow/ExpirationForm.tsx | 2 +- .../workflow/__tests__/Workflows.test.tsx | 41 +++++++++++++++++-- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/js/mock/managementClientMSWHandlers.ts b/src/js/mock/managementClientMSWHandlers.ts index ae7227626..8c9aad414 100644 --- a/src/js/mock/managementClientMSWHandlers.ts +++ b/src/js/mock/managementClientMSWHandlers.ts @@ -15,6 +15,7 @@ export const TRANSITION_WORKFLOW_CURRENT_ID = '0d55a1d7-349c-4e79-932b-b502bcc45a8f'; export const TRANSITION_WORKFLOW_PREVIOUS_ID = '1e55a1d7-349c-4e79-932b-b502bcc45a8f'; +export const EXPIRATION_WORKFLOW_ID = '330f2359-dc93-4abd-97c1-37c8483b1872'; export const TRIGGER_DELAY_DAYS = 15; export const COLD_LOCATION_NAME = 'europe25-myroom-cold'; @@ -266,6 +267,18 @@ export const getColdStorageHandlers = (baseUrl: string, instanceId: string) => [ enabled: true, }, }, + { + expiration: { + bucketName: BUCKET_NAME, + enabled: true, + filter: { + objectTags: null, + }, + type: 'bucket-workflow-expiration-v1', + workflowId: EXPIRATION_WORKFLOW_ID, + previousVersionTriggerDelayDays: 7, + }, + }, ]), ), ), diff --git a/src/react/workflow/ExpirationForm.tsx b/src/react/workflow/ExpirationForm.tsx index acaea2d1a..a797a9c7f 100644 --- a/src/react/workflow/ExpirationForm.tsx +++ b/src/react/workflow/ExpirationForm.tsx @@ -390,7 +390,7 @@ export function ExpirationForm({ prefix = '' }: Props) { }) => ( { beforeAll(() => { server.listen({ onUnhandledRequest: 'error' }); - mockOffsetSize(200, 800); + mockOffsetSize(200, 1000); }); afterEach(() => { server.resetHandlers(); @@ -136,4 +139,36 @@ describe('Workflows', () => { ), ).toBeInTheDocument(); }); + + it('should display the correct expiration form', async () => { + //S + server.use( + mockBucketListing([ + { + Name: BUCKET_NAME, + CreationDate: new Date('2021-03-18T12:51:44Z'), + }, + ]), + mockBucketOperations({ + isVersioningEnabled: (bucketName) => bucketName === BUCKET_NAME, + }), + ); + renderWithRouterMatch( + , + { + path: '/accounts/:accountName/workflows/:workflowId?', + route: `/accounts/${TEST_ACCOUNT}/workflows/expiration-${EXPIRATION_WORKFLOW_ID}`, + }, + { instances: { selectedId: INSTANCE_ID } }, + ); + //E + await waitFor(() => screen.getByText(TEST_ACCOUNT)); + await waitFor(() => screen.queryAllByText(/expiration/i)); + //V + expect( + screen.getByRole('checkbox', { + name: /Expire Previous version of objects/i, + }), + ).toBeChecked(); + }); });