Wizard: enable nav items properly in Edit mode

This commit is contained in:
Ondrej Ezr 2024-07-10 16:36:28 +02:00 committed by Klara Simickova
parent 549ef37ab7
commit 4044b9eba1
3 changed files with 69 additions and 1 deletions

View file

@ -0,0 +1,66 @@
import { screen, within } from '@testing-library/react';
import { renderEditMode } from './wizardTestUtils';
import {
mockBlueprintIds,
mockBlueprintNames,
} from '../../fixtures/blueprints';
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
useChrome: () => ({
auth: {
getUser: () => {
return {
identity: {
internal: {
org_id: 5,
},
},
};
},
},
isBeta: () => true,
isProd: () => true,
getEnvironment: () => 'prod',
}),
}));
describe('EditImageWizard', () => {
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();
});
});