Skip to content

Commit

Permalink
fix ExpirationForm.test.tsx, ReplicationForm.test.tsx and TransitionF…
Browse files Browse the repository at this point in the history
…orm.test.tsx tests
  • Loading branch information
MonPote committed Nov 8, 2024
1 parent 37092a8 commit 9f56fb1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
11 changes: 9 additions & 2 deletions src/react/workflow/__tests__/ExpirationForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import {
getConfigOverlay,
getStorageConsumptionMetricsHandlers,
} from '../../../js/mock/managementClientMSWHandlers';
import { INSTANCE_ID } from '../../actions/__tests__/utils/testUtil';
import {
INSTANCE_ID,
waitForSelectOptionToBeEnabled,
} from '../../actions/__tests__/utils/testUtil';

const instanceId = 'instanceId';
const accountName = 'pat';
Expand Down Expand Up @@ -54,6 +57,7 @@ const locations: PerLocationMap<any> = {
objectId: '95dbedf5-9888-11ec-8565-1ac2af7d1e53',
},
};
jest.setTimeout(60_000);

const server = setupServer(
rest.post(
Expand All @@ -75,7 +79,6 @@ const server = setupServer(
beforeAll(() => {
server.listen({ onUnhandledRequest: 'error' });
mockOffsetSize(200, 800);
jest.setTimeout(10_000);
});
afterEach(() => server.resetHandlers());
afterAll(() => server.close());
Expand Down Expand Up @@ -145,6 +148,10 @@ describe('ExpirationForm', () => {
// Select the Source Bucket.
await selectClick(selectors.bucketSelect());

await waitForSelectOptionToBeEnabled(() =>
selectors.versionedBucketOption(),
);

await userEvent.click(selectors.versionedBucketOption());
const expireCurrentToggleState = result.container.querySelector(
'[for="expireCurrentVersions"]',
Expand Down
21 changes: 19 additions & 2 deletions src/react/workflow/__tests__/ReplicationForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,25 @@ describe('ReplicationForm', () => {
await waitFor(() => screen.getByText(/General/i));
await selectClick(selectors.bucketSelect());
//V
expect(selectors.bucketOption1()).toHaveAttribute('aria-disabled', 'false');
expect(selectors.bucketOption2()).toHaveAttribute('aria-disabled', 'true');

await waitFor(
() =>
expect(
selectors.bucketOption1(),
).toHaveAttribute('aria-disabled', 'false'),
{
timeout: 10_000,
},
);
await waitFor(
() =>
expect(
selectors.bucketOption2(),
).toHaveAttribute('aria-disabled', 'true'),
{
timeout: 10_000,
},
);
await userEvent.hover(selectors.bucketOption2());
expect(
screen.getByText(/Replication is not available for a Bucket that was created especially for Veeam./i),
Expand Down
20 changes: 16 additions & 4 deletions src/react/workflow/__tests__/TransitionForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ import {
getConfigOverlay,
getStorageConsumptionMetricsHandlers,
} from '../../../js/mock/managementClientMSWHandlers';
import { INSTANCE_ID } from '../../actions/__tests__/utils/testUtil';
import {
INSTANCE_ID,
waitForSelectOptionToBeEnabled,
} from '../../actions/__tests__/utils/testUtil';
import { debug } from 'jest-preview';

const versionedBucket = 'bucket1';
const notVersionedBucket = 'bucket2';
Expand Down Expand Up @@ -108,6 +112,8 @@ const server = setupServer(
),
);

jest.setTimeout(60_000);

beforeAll(() => {
server.listen({ onUnhandledRequest: 'error' });
mockOffsetSize(200, 800);
Expand Down Expand Up @@ -230,7 +236,8 @@ describe('TransitionForm', () => {
await selectClick(
notFalsyTypeGuard(getByText(sourceBucketContainer, /select/i)),
);
await waitFor(() =>

await waitForSelectOptionToBeEnabled(() =>
screen.getByRole('option', {
name: new RegExp(
`${versionedBucket} \\(us-east-1 / Storage Service \\)`,
Expand Down Expand Up @@ -333,7 +340,7 @@ describe('TransitionForm', () => {
notFalsyTypeGuard(getByText(sourceBucketContainer, /select/i)),
);

await waitFor(() =>
await waitForSelectOptionToBeEnabled(() =>
screen.getByRole('option', {
name: new RegExp(
`${notVersionedBucket} \\(us-east-1 / Storage Service \\)`,
Expand Down Expand Up @@ -381,14 +388,16 @@ describe('TransitionForm', () => {
await selectClick(
notFalsyTypeGuard(getByText(sourceBucketContainer, /select/i)),
);
await waitFor(() =>

await waitForSelectOptionToBeEnabled(() =>
screen.getByRole('option', {
name: new RegExp(
`${notVersionedBucket} \\(us-east-1 / Storage Service \\)`,
'i',
),
}),
);
debug();
await userEvent.click(
screen.getByRole('option', {
name: new RegExp(
Expand All @@ -397,7 +406,9 @@ describe('TransitionForm', () => {
),
}),
);
debug();
await userEvent.click(screen.getByLabelText(/Storage location/i));

await userEvent.keyboard('{ArrowDown}');
// expect the hyperdrive location is not in the list
expect(
Expand All @@ -415,6 +426,7 @@ describe('TransitionForm', () => {
screen.getByRole('spinbutton', { name: /Days after object creation/i }),
'0',
);

//V
//Check that the form is now valid
await waitFor(() =>
Expand Down

0 comments on commit 9f56fb1

Please sign in to comment.