Skip to content

Commit

Permalink
Merge branch 'bugfix/ZKUI-376-fix-the-workflow-not-visible-on-workflo…
Browse files Browse the repository at this point in the history
…w-page' into q/2.0
  • Loading branch information
bert-e committed Sep 12, 2023
2 parents cf48fb3 + 38ea551 commit 680dd7b
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 5 deletions.
13 changes: 13 additions & 0 deletions src/js/mock/managementClientMSWHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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,
},
},
]),
),
),
Expand Down
1 change: 1 addition & 0 deletions src/react/actions/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')))
Expand Down
11 changes: 10 additions & 1 deletion src/react/workflow/ConfigurationTab.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion src/react/workflow/ExpirationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export function ExpirationForm({ prefix = '' }: Props) {
}) => (
<Toggle
disabled={!isSourceBucketVersionned}
id="previousVersionTriggerDelayDaysToggle"
id="expirePreviousVersions"
placeholder="previousVersionDelayDaysToggle"
toggle={
previousVersionTriggerDelayDays !== null &&
Expand Down
41 changes: 38 additions & 3 deletions src/react/workflow/__tests__/Workflows.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ import { setupServer } from 'msw/node';
import {
ACCOUNT_ID,
BUCKET_NAME,
EXPIRATION_WORKFLOW_ID,
getColdStorageHandlers,
TRANSITION_WORKFLOW_CURRENT_ID,
TRANSITION_WORKFLOW_PREVIOUS_ID,
} from '../../../js/mock/managementClientMSWHandlers';

import Workflows from '../Workflows';
import {
mockOffsetSize,
queryClient,
renderWithRouterMatch,
TEST_API_BASE_URL,
} from '../../utils/testUtil';
import { mockBucketListing } from '../../../js/mock/S3ClientMSWHandlers';
import {
mockBucketListing,
mockBucketOperations,
} from '../../../js/mock/S3ClientMSWHandlers';

const INSTANCE_ID = '25050307-cd09-4feb-9c2e-c93e2e844fea';
const TEST_ACCOUNT = 'test-account';
Expand Down Expand Up @@ -50,7 +53,7 @@ jest.setTimeout(30000);
describe('Workflows', () => {
beforeAll(() => {
server.listen({ onUnhandledRequest: 'error' });
mockOffsetSize(200, 800);
mockOffsetSize(200, 1000);
});
afterEach(() => {
server.resetHandlers();
Expand Down Expand Up @@ -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(
<Workflows />,
{
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();
});
});

0 comments on commit 680dd7b

Please sign in to comment.