Skip to content

Commit

Permalink
ARTESCA-11656: fix immutable backup
Browse files Browse the repository at this point in the history
  • Loading branch information
hervedombya committed Mar 18, 2024
1 parent e219a2a commit 09236a9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 11 deletions.
50 changes: 46 additions & 4 deletions src/react/ui-elements/Veeam/VeeamConfiguration.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import { Stepper } from '@scality/core-ui';
import { useStepper } from '@scality/core-ui/dist/components/steppers/Stepper.component';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { QueryClient, QueryClientProvider } from 'react-query';
import { selectClick } from '../../utils/testUtil';
import Configuration from './VeeamConfiguration';
import { Stepper } from '@scality/core-ui';
import { VEEAM_BACKUP_REPLICATION } from './VeeamConstants';
import { selectClick } from '../../utils/testUtil';

jest.mock('@scality/core-ui/dist/components/steppers/Stepper.component', () => {
return {
useStepper: jest.fn(() => {
return { next: jest.fn() };
}),
};
});

const mockUseStepper = useStepper as jest.Mock;

describe('Veeam Configuration UI', () => {
const selectors = {
Expand All @@ -16,7 +27,7 @@ describe('Veeam Configuration UI', () => {
veeamApplicationSelect: () => screen.getByLabelText(/Veeam application/i),
veeamVBO: () =>
screen.getByRole('option', {
name: /Veeam Backup for Microsoft Office 365/i,
name: /Veeam Backup for Microsoft 365/i,
}),
};

Expand Down Expand Up @@ -72,7 +83,7 @@ describe('Veeam Configuration UI', () => {
expect(screen.getByText(/GiB/i)).toBeInTheDocument();
});

it('should hide immutable backup and Max Veeam Repository Capacity when Veeam Backup for Microsoft Office 365 is selected', async () => {
it('should hide immutable backup and Max Veeam Repository Capacity when Veeam Backup for Microsoft 365 is selected', async () => {
//Setup
render(
<QueryClientProvider client={new QueryClient()}>
Expand Down Expand Up @@ -120,4 +131,35 @@ describe('Veeam Configuration UI', () => {
expect(screen.getByText(/Exit Veeam assistant?/i)).toBeInTheDocument();
expect(screen.getByText(/Cancel/i)).toBeInTheDocument();
});

it('should disable immutable backup when Veeam Backup for Microsoft 365 is selected', async () => {
const SUT = jest.fn();
mockUseStepper.mockReturnValue({ next: SUT });

render(
<QueryClientProvider client={new QueryClient()}>
<Stepper
steps={[
{
label: 'Configuration',
Component: Configuration,
},
]}
/>
</QueryClientProvider>,
);

await selectClick(selectors.veeamApplicationSelect());
await userEvent.click(selectors.veeamVBO());
await userEvent.type(selectors.repositoryInput(), 'veeam-bucket');
await userEvent.click(selectors.continueButton());

expect(SUT).toHaveBeenCalledWith({
accountName: 'Veeam',
application: 'Veeam Backup for Microsoft 365',
bucketName: 'veeam-bucket',
capacityBytes: '4294967296',
enableImmutableBackup: undefined,
});
});
});
7 changes: 5 additions & 2 deletions src/react/ui-elements/Veeam/VeeamConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const VeeamApplicationTooltip = () => (
<br />
Features such as Immutable Backup and Max Repository Capacity (that provides
notification via Smart Object Storage API) are only supported in Veeam
Backup and Replication, and not in Veeam Backup for Microsoft Office 365.
Backup and Replication, and not in Veeam Backup for Microsoft 365.
</>
);

Expand Down Expand Up @@ -142,7 +142,10 @@ const Configuration = () => {
bucketName,
application,
capacityBytes: getCapacityBytes(capacity, capacityUnit),
enableImmutableBackup,
enableImmutableBackup:
application === VEEAM_BACKUP_REPLICATION_XML_VALUE
? enableImmutableBackup
: undefined,
// Add advanced configuration to set the account name, for the moment we use the default account name.
accountName: VEEAM_DEFAULT_ACCOUNT_NAME,
});
Expand Down
4 changes: 2 additions & 2 deletions src/react/ui-elements/Veeam/VeeamConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export const BUCKET_TAG_VEEAM_APPLICATION = 'X-Scality-Veeam-Application';
export const VEEAM_BACKUP_REPLICATION = 'Veeam Backup & Replication';
export const VEEAM_BACKUP_REPLICATION_XML_VALUE =
'Veeam Backup &#38; Replication';
export const VEEAM_OFFICE_365 = 'Veeam Backup for Microsoft Office 365';
export const VEEAM_OFFICE_365 = 'Veeam Backup for Microsoft 365';
export const VEEAM_IMMUTABLE_POLICY_NAME = 'Scality-Veeam-Immutable-Policy';
export const GET_VEEAM_IMMUTABLE_POLICY = (bucketName: string) =>
JSON.stringify({
Expand Down Expand Up @@ -46,7 +46,7 @@ export const GET_CAPACITY_XML_CONTENT = (capacity: string) =>
export const VEEAM_DEFAULT_ACCOUNT_NAME = 'Veeam';
export enum VeeamApplicationType {
VEEAM_BACKUP_REPLICATION = 'Veeam Backup & Replication',
VEEAM_OFFICE_365 = 'Veeam Backup for Microsoft Office 365',
VEEAM_OFFICE_365 = 'Veeam Backup for Microsoft 365',
}
export const unitChoices = {
GiB: 1024 ** 3,
Expand Down
6 changes: 3 additions & 3 deletions src/react/ui-elements/Veeam/VeeamTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('VeeamTable', () => {
veeamApplicationSelect: () => screen.getByLabelText(/Veeam application/i),
veeamVBO: () =>
screen.getByRole('option', {
name: /Veeam Backup for Microsoft Office 365/i,
name: /Veeam Backup for Microsoft 365/i,
}),
immutableBackupToggle: () => screen.getByLabelText('enableImmutableBackup'),
};
Expand Down Expand Up @@ -201,12 +201,12 @@ describe('VeeamTable', () => {
await verifySuccessActions(mutationActions);
});

it('should skip the SOSAPI setup step when choosing Veeam Backup for Microsoft Office 365, ', async () => {
it('should skip the SOSAPI setup step when choosing Veeam Backup for Microsoft 365, ', async () => {
//Setup
server.resetHandlers(...goodHandlers);
setupTest();
//Exercise
//Select Veeam Backup for Microsoft Office 365
//Select Veeam Backup for Microsoft 365
await selectClick(selectors.veeamApplicationSelect());
await userEvent.click(selectors.veeamVBO());
//type the bucket name in configuration form
Expand Down

0 comments on commit 09236a9

Please sign in to comment.