This commit is contained in:
Anna Vítová 2025-08-21 11:13:05 +02:00
parent 1c04ce8186
commit 5c8cb7d23b
3 changed files with 55 additions and 44 deletions

View file

@ -1,4 +1,4 @@
import React from 'react'; import React, { useEffect } from 'react';
import { import {
Button, Button,
@ -63,8 +63,12 @@ const Azure = () => {
const tenantId = useAppSelector(selectAzureTenantId); const tenantId = useAppSelector(selectAzureTenantId);
const subscriptionId = useAppSelector(selectAzureSubscriptionId); const subscriptionId = useAppSelector(selectAzureSubscriptionId);
const resourceGroup = useAppSelector(selectAzureResourceGroup); const resourceGroup = useAppSelector(selectAzureResourceGroup);
const launchEofFlag = true;
const launchEofFlag = useFlag('image-builder.launcheof'); useEffect(() => {
if (launchEofFlag && shareMethod !== 'manual') {
dispatch(changeAzureShareMethod('manual'));
}
}, [launchEofFlag, dispatch, shareMethod]);
return ( return (
<Form> <Form>

View file

@ -17,21 +17,6 @@ import {
selectRhel9, selectRhel9,
} from '../../wizardTestUtils'; } from '../../wizardTestUtils';
// Overwrite
vi.mock('@unleash/proxy-client-react', () => ({
useUnleashContext: () => vi.fn(),
useFlag: vi.fn((flag) => {
switch (flag) {
case 'image-builder.compliance.enabled':
return true;
case 'image-builder.aap.enabled':
return true;
default:
return false;
}
}),
}));
const goToComplianceStep = async () => { const goToComplianceStep = async () => {
const user = userEvent.setup(); const user = userEvent.setup();
await selectRhel9(); // Compliance is not available for RHEL 10 yet await selectRhel9(); // Compliance is not available for RHEL 10 yet

View file

@ -1,6 +1,7 @@
import type { Router as RemixRouter } from '@remix-run/router'; import type { Router as RemixRouter } from '@remix-run/router';
import { screen, waitFor, within } from '@testing-library/react'; import { screen, waitFor, within } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event'; import { userEvent } from '@testing-library/user-event';
import { useFlag } from '@unleash/proxy-client-react';
import { http, HttpResponse } from 'msw'; import { http, HttpResponse } from 'msw';
import { import {
@ -33,6 +34,18 @@ import {
// The router is just initiliazed here, it's assigned a value in the tests // The router is just initiliazed here, it's assigned a value in the tests
let router: RemixRouter | undefined = undefined; let router: RemixRouter | undefined = undefined;
vi.mock('@unleash/proxy-client-react', () => ({
useUnleashContext: () => vi.fn(),
useFlag: vi.fn((flag) => {
switch (flag) {
case 'image-builder.launcheof':
return true;
default:
return false;
}
}),
}));
const goToAzureStep = async () => { const goToAzureStep = async () => {
await clickNext(); await clickNext();
}; };
@ -181,6 +194,7 @@ describe('Step Upload to Azure', () => {
vi.clearAllMocks(); vi.clearAllMocks();
router = undefined; router = undefined;
}); });
const launchEofFlag = useFlag('image-builder.launcheof');
const user = userEvent.setup(); const user = userEvent.setup();
@ -188,7 +202,9 @@ describe('Step Upload to Azure', () => {
await renderCreateMode(); await renderCreateMode();
await selectAzureTarget(); await selectAzureTarget();
await goToAzureStep(); await goToAzureStep();
await selectManuallyEnterInformation(); if (!launchEofFlag) {
await selectManuallyEnterInformation();
}
await enterTenantGuid(); await enterTenantGuid();
await enterSubscriptionId(); await enterSubscriptionId();
await enterResourceGroup(); await enterResourceGroup();
@ -217,7 +233,9 @@ describe('Step Upload to Azure', () => {
await renderCreateMode(); await renderCreateMode();
await selectAzureTarget(); await selectAzureTarget();
await goToAzureStep(); await goToAzureStep();
await selectManuallyEnterInformation(); if (!launchEofFlag) {
await selectManuallyEnterInformation();
}
const nextButton = await getNextButton(); const nextButton = await getNextButton();
expect(nextButton).toBeDisabled(); expect(nextButton).toBeDisabled();
@ -237,30 +255,13 @@ describe('Step Upload to Azure', () => {
await enterResourceGroup(); await enterResourceGroup();
expect(nextButton).toBeEnabled(); expect(nextButton).toBeEnabled();
// switch to Sources
await selectSourcesOption();
// manual values should be cleared out
expect(await getTenantGuidInput()).toHaveValue('');
expect(await getSubscriptionIdInput()).toHaveValue('');
expect(await getResourceGroupSelect()).toHaveValue('');
expect(nextButton).toBeDisabled();
await selectSource('azureSource1');
// source information should be fetched
expect(await getTenantGuidInput()).not.toHaveValue('');
expect(await getSubscriptionIdInput()).not.toHaveValue('');
await selectResourceGroup();
await waitFor(() => {
expect(nextButton).toBeEnabled();
});
}); });
test('handles change of selected Source', async () => { test('handles change of selected Source', async () => {
if (launchEofFlag) {
return;
}
await renderCreateMode(); await renderCreateMode();
await selectAzureTarget(); await selectAzureTarget();
await goToAzureStep(); await goToAzureStep();
@ -287,6 +288,10 @@ describe('Step Upload to Azure', () => {
}); });
test('component renders error state correctly', async () => { test('component renders error state correctly', async () => {
if (launchEofFlag) {
return;
}
server.use( server.use(
http.get(`${PROVISIONING_API}/sources`, () => { http.get(`${PROVISIONING_API}/sources`, () => {
return new HttpResponse(null, { status: 500 }); return new HttpResponse(null, { status: 500 });
@ -301,6 +306,10 @@ describe('Step Upload to Azure', () => {
}); });
test('revisit step button on Review works', async () => { test('revisit step button on Review works', async () => {
if (launchEofFlag) {
// Revisit after launch EOF
return;
}
await renderCreateMode(); await renderCreateMode();
await selectAzureTarget(); await selectAzureTarget();
await goToAzureStep(); await goToAzureStep();
@ -313,11 +322,15 @@ describe('Step Upload to Azure', () => {
}); });
describe('Azure image type request generated correctly', () => { describe('Azure image type request generated correctly', () => {
const launchEofFlag = useFlag('image-builder.launcheof');
beforeEach(() => { beforeEach(() => {
vi.clearAllMocks(); vi.clearAllMocks();
}); });
test('using a source', async () => { test('using a source', async () => {
if (launchEofFlag) {
return;
}
await renderCreateMode(); await renderCreateMode();
await selectAzureTarget(); await selectAzureTarget();
await goToAzureStep(); await goToAzureStep();
@ -355,7 +368,9 @@ describe('Azure image type request generated correctly', () => {
await renderCreateMode(); await renderCreateMode();
await selectAzureTarget(); await selectAzureTarget();
await goToAzureStep(); await goToAzureStep();
await selectManuallyEnterInformation(); if (!launchEofFlag) {
await selectManuallyEnterInformation();
}
await enterTenantGuid(); await enterTenantGuid();
await enterSubscriptionId(); await enterSubscriptionId();
await enterResourceGroup(); await enterResourceGroup();
@ -388,7 +403,9 @@ describe('Azure image type request generated correctly', () => {
await renderCreateMode(); await renderCreateMode();
await selectAzureTarget(); await selectAzureTarget();
await goToAzureStep(); await goToAzureStep();
await selectManuallyEnterInformation(); if (!launchEofFlag) {
await selectManuallyEnterInformation();
}
await enterTenantGuid(); await enterTenantGuid();
await enterSubscriptionId(); await enterSubscriptionId();
await enterResourceGroup(); await enterResourceGroup();
@ -422,7 +439,12 @@ describe('Azure image type request generated correctly', () => {
await renderCreateMode(); await renderCreateMode();
await selectAzureTarget(); await selectAzureTarget();
await goToAzureStep(); await goToAzureStep();
await selectSource('azureSource1'); if (!launchEofFlag) {
await selectManuallyEnterInformation();
}
await enterTenantGuid();
await enterSubscriptionId();
await enterResourceGroup();
await clickBack(); await clickBack();
await deselectAzureAndSelectGuestImage(); await deselectAzureAndSelectGuestImage();
await goToReviewStep(); await goToReviewStep();