test: Add tests to check reseting public cloud states

This adds happy path tests that check whether the public cloud states get reset after the public cloud was removed from targets.
This commit is contained in:
regexowl 2024-04-29 13:37:27 +02:00 committed by Lucas Garfield
parent f2daa9c358
commit 0c1af145c1
3 changed files with 71 additions and 3 deletions

View file

@ -6,7 +6,7 @@ import {
CreateBlueprintRequest,
ImageRequest,
} from '../../../../../../store/imageBuilderApi';
import { clickNext } from '../../../../../testUtils';
import { clickBack, clickNext } from '../../../../../testUtils';
import {
blueprintRequest,
clickRegisterLater,
@ -58,6 +58,17 @@ const selectAwsTarget = async () => {
await clickNext();
};
const deselectAwsAndSelectGuestImage = async () => {
const awsCard = await screen.findByTestId('upload-aws');
await userEvent.click(awsCard);
await userEvent.click(
await screen.findByRole('checkbox', {
name: /virtualization guest image checkbox/i,
})
);
await clickNext();
};
const selectSource = async () => {
await userEvent.click(
await screen.findByRole('textbox', {
@ -135,4 +146,16 @@ describe('aws image type request generated correctly', () => {
expect(receivedRequest).toEqual(expectedRequest);
});
test('after selecting and deselecting aws', async () => {
await selectAwsTarget();
await goToAwsStep();
await selectSource();
await clickBack();
await deselectAwsAndSelectGuestImage();
await goToReview();
const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT);
expect(receivedRequest).toEqual(blueprintRequest);
});
});

View file

@ -6,7 +6,7 @@ import {
CreateBlueprintRequest,
ImageRequest,
} from '../../../../../../store/imageBuilderApi';
import { clickNext } from '../../../../../testUtils';
import { clickBack, clickNext } from '../../../../../testUtils';
import {
blueprintRequest,
clickRegisterLater,
@ -58,6 +58,17 @@ const selectAzureTarget = async () => {
await clickNext();
};
const deselectAzureAndSelectGuestImage = async () => {
const azureCard = await screen.findByTestId('upload-azure');
await userEvent.click(azureCard);
await userEvent.click(
await screen.findByRole('checkbox', {
name: /virtualization guest image checkbox/i,
})
);
await clickNext();
};
const selectSource = async () => {
await userEvent.click(
await screen.findByRole('textbox', {
@ -168,4 +179,16 @@ describe('azure image type request generated correctly', () => {
expect(receivedRequest).toEqual(expectedRequest);
});
test('after selecting and deselecting azure', async () => {
await selectAzureTarget();
await goToAzureStep();
await selectSource();
await clickBack();
await deselectAzureAndSelectGuestImage();
await goToReview();
const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT);
expect(receivedRequest).toEqual(blueprintRequest);
});
});

View file

@ -8,7 +8,7 @@ import {
ImageRequest,
ImageTypes,
} from '../../../../../store/imageBuilderApi';
import { clickNext } from '../../../../testUtils';
import { clickBack, clickNext } from '../../../../testUtils';
import {
blueprintRequest,
clickRegisterLater,
@ -73,6 +73,17 @@ const clickGCPTarget = async () => {
await clickNext();
};
const deselectGcpAndSelectGuestImage = async () => {
const googleCard = await screen.findByTestId('upload-google');
await userEvent.click(googleCard);
await userEvent.click(
await screen.findByRole('checkbox', {
name: /virtualization guest image checkbox/i,
})
);
await clickNext();
};
const selectGoogleAccount = async (optionId: string) => {
const googleAccountOption = await screen.findByTestId(optionId);
await userEvent.click(googleAccountOption);
@ -154,4 +165,15 @@ describe('gcp image type request generated correctly', () => {
};
expect(receivedRequest).toEqual(expectedRequest);
});
test('after selecting and deselecting gcp', async () => {
await clickGCPTarget();
await selectGoogleAccount('google-domain');
await clickBack();
await deselectGcpAndSelectGuestImage();
await goToReview();
const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT);
expect(receivedRequest).toEqual(blueprintRequest);
});
});