import { screen } from '@testing-library/react';
import { routerRenderer } from '../../../utils/test-utils';
import { MockSnapshots } from '../../Commits/CommitDetails/visualization/__data__/MockCommitWorkflowData';
import EnvironmentProvisionErrorAlert from '../EnvironmentProvisionErrorAlert';
import { getEnvironmentProvisionError } from '../utils/snapshot-utils';
describe('EnvironmentProvisionErrorAlert', () => {
it('should return null when no ErrorStatus', () => {
routerRenderer();
expect(screen.queryByTestId(/env-provision-err-alert/)).not.toBeInTheDocument();
});
it('should return for emoty array ErrorStatus', () => {
routerRenderer();
expect(screen.queryByTestId(/env-provision-err-alert/)).not.toBeInTheDocument();
});
it('should return error section as hidden initially', () => {
routerRenderer(
,
);
expect(screen.getByTestId('error-expandable-section')).toBeInTheDocument();
expect(
screen
.getByTestId('error-expandable-section')
.querySelector('.pf-v6-c-expandable-section__content'),
).not.toBeVisible();
});
it('should show relevant Error Details Alert', () => {
routerRenderer(
,
);
expect(screen.getByTestId(/env-provision-err-alert/)).toBeInTheDocument();
expect(screen.getByText('app-sample-go-basic-enterprise-contract')).toBeInTheDocument();
expect(screen.getByText(/Snapshot failed to deploy/)).toBeInTheDocument();
expect(screen.getByTestId('timestamp')).toBeInTheDocument();
});
it('should show multiple scenarios for multiple failures', () => {
routerRenderer(
,
);
screen.getByTestId('env-provision-err-alert');
screen.getByText(/app-sample-go-basic-enterprise-contract/);
screen.getByText(/scn 2/);
});
it('should show multiple details for multiple failures', () => {
routerRenderer(
,
);
screen.getByText(/Snapshot failed to deploy/);
screen.getByText(
/Failed to find deploymentTargetClass with right provisioner for copy of existingEnvironment/,
);
screen.getByText(/could not find deployment/);
});
});