debian-image-builder-frontend/src/test/Components/CreateImageWizard/EditImageWizard.test.tsx
regexowl 8ee2bad55e test: Add flag mocks
This adds mocked 'image-builder.firstboot.enabled' where needed.
2024-08-01 17:16:36 +02:00

65 lines
1.9 KiB
TypeScript

import { screen, within } from '@testing-library/react';
import { renderEditMode } from './wizardTestUtils';
import {
mockBlueprintIds,
mockBlueprintNames,
} from '../../fixtures/blueprints';
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
useChrome: () => ({
isBeta: () => true,
isProd: () => true,
getEnvironment: () => 'prod',
}),
}));
vi.mock('@unleash/proxy-client-react', () => ({
useUnleashContext: () => vi.fn(),
useFlag: vi.fn((flag) =>
flag === 'image-builder.firstboot.enabled' ? true : false
),
}));
describe('EditImageWizard', () => {
beforeEach(() => {
vi.clearAllMocks();
});
test('should enable all navigation items in edit mode', async () => {
const id = mockBlueprintIds['darkChocolate'];
const name = mockBlueprintNames['darkChocolate'];
await renderEditMode(id);
const heading = await screen.findByRole('heading', {
name: new RegExp(`review ${name}`, 'i'),
});
const navigation = await screen.findByRole('navigation', {
name: /wizard steps/i,
});
const outputNavItem = within(navigation).getByRole('button', {
name: /image output/i,
});
const targetNavItem = within(navigation).getByRole('button', {
name: /target environment/i,
});
const registerNavItem = within(navigation).getByRole('button', {
name: /register/i,
});
const scapNavItem = within(navigation).getByRole('button', {
name: /openscap/i,
});
const detailsNavItem = within(navigation).getByRole('button', {
name: /details/i,
});
// Assert that all validation items are enabled
expect(heading).toBeInTheDocument();
expect(outputNavItem).toBeEnabled();
expect(targetNavItem).toBeEnabled();
expect(registerNavItem).toBeEnabled();
expect(scapNavItem).toBeEnabled();
expect(detailsNavItem).toBeEnabled();
});
});