Fixes some failing or skipped tests

This commit is contained in:
Alex Corey 2020-06-22 12:47:53 -04:00 committed by John Mitchell
parent 28e0ee8b7d
commit 88a38e30c3
6 changed files with 38 additions and 19 deletions

View File

@ -24,6 +24,7 @@ import ChipGroup from '../../ChipGroup';
const PromptTitle = styled(Title)`
--pf-c-title--m-md--FontWeight: 700;
grid-column: 1 / -1;
`;
function ScheduleDetail({ schedule, i18n }) {
@ -140,7 +141,7 @@ function ScheduleDetail({ schedule, i18n }) {
/>
{showPromptedFields && (
<>
<PromptTitle size="md" css="grid-column: 1 / -1;">
<PromptTitle headingLevel="h2">
{i18n._(t`Prompted Fields`)}
</PromptTitle>
<Detail label={i18n._(t`Job Type`)} value={job_type} />

View File

@ -135,8 +135,8 @@ describe('<ScheduleDetail />', () => {
expect(wrapper.find('Detail[label="Job Tags"]').length).toBe(0);
expect(wrapper.find('Detail[label="Skip Tags"]').length).toBe(0);
});
test.skip('details should render with the proper values with prompts', async () => {
SchedulesAPI.readCredentials.mockResolvedValueOnce({
test('details should render with the proper values with prompts', async () => {
SchedulesAPI.readCredentials.mockResolvedValue({
data: {
count: 2,
results: [
@ -182,6 +182,7 @@ describe('<ScheduleDetail />', () => {
);
});
await waitForElement(wrapper, 'ContentLoading', el => el.length === 0);
// await waitForElement(wrapper, 'Title', el => el.length > 0);
expect(
wrapper
.find('Detail[label="Name"]')
@ -231,7 +232,7 @@ describe('<ScheduleDetail />', () => {
expect(wrapper.find('Detail[label="Job Tags"]').length).toBe(1);
expect(wrapper.find('Detail[label="Skip Tags"]').length).toBe(1);
});
test.skip('error shown when error encountered fetching credentials', async () => {
test('error shown when error encountered fetching credentials', async () => {
SchedulesAPI.readCredentials.mockRejectedValueOnce(
new Error({
response: {
@ -266,7 +267,7 @@ describe('<ScheduleDetail />', () => {
await waitForElement(wrapper, 'ContentError', el => el.length === 1);
});
test.skip('should show edit button for users with edit permission', async () => {
test('should show edit button for users with edit permission', async () => {
SchedulesAPI.readCredentials.mockResolvedValueOnce({
data: {
count: 0,

View File

@ -11,7 +11,7 @@ jest.mock('../../api/models/Teams');
jest.mock('../../api/models/Users');
jest.mock('../../api/models/JobTemplates');
describe.skip('<UserAndTeamAccessAdd/>', () => {
describe('<UserAndTeamAccessAdd/>', () => {
const resources = {
data: {
results: [
@ -56,6 +56,7 @@ describe.skip('<UserAndTeamAccessAdd/>', () => {
/>
);
});
await waitForElement(wrapper, 'PFWizard');
});
afterEach(() => {
wrapper.unmount();
@ -68,12 +69,12 @@ describe.skip('<UserAndTeamAccessAdd/>', () => {
expect(wrapper.find('Button[type="submit"]').prop('isDisabled')).toBe(true);
expect(
wrapper
.find('WizardNavItem[text="Select items from list"]')
.find('WizardNavItem[content="Select items from list"]')
.prop('isDisabled')
).toBe(true);
expect(
wrapper
.find('WizardNavItem[text="Select roles to apply"]')
.find('WizardNavItem[content="Select roles to apply"]')
.prop('isDisabled')
).toBe(true);
await act(async () =>
@ -89,17 +90,19 @@ describe.skip('<UserAndTeamAccessAdd/>', () => {
wrapper.find('Button[type="submit"]').prop('onClick')()
);
wrapper.update();
expect(
wrapper.find('WizardNavItem[text="Add resource type"]').prop('isDisabled')
).toBe(false);
expect(
wrapper
.find('WizardNavItem[text="Select items from list"]')
.find('WizardNavItem[content="Add resource type"]')
.prop('isDisabled')
).toBe(false);
expect(
wrapper
.find('WizardNavItem[text="Select roles to apply"]')
.find('WizardNavItem[content="Select items from list"]')
.prop('isDisabled')
).toBe(false);
expect(
wrapper
.find('WizardNavItem[content="Select roles to apply"]')
.prop('isDisabled')
).toBe(true);
});

View File

@ -91,8 +91,8 @@ describe('<ApplicationAdd/>', () => {
wrapper.update();
expect(wrapper.find('input#name').prop('value')).toBe('new foo');
expect(wrapper.find('input#description').prop('value')).toBe('new bar');
expect(wrapper.find('InnerChipGroup').length).toBe(1);
expect(wrapper.find('InnerChipGroup').text()).toBe('organization');
expect(wrapper.find('Chip').length).toBe(1);
expect(wrapper.find('Chip').text()).toBe('organization');
expect(
wrapper
.find('AnsibleSelect[name="authorization_grant_type"]')

View File

@ -107,8 +107,8 @@ describe('<ApplicationForm', () => {
wrapper.update();
expect(wrapper.find('input#name').prop('value')).toBe('new foo');
expect(wrapper.find('input#description').prop('value')).toBe('new bar');
expect(wrapper.find('InnerChipGroup').length).toBe(1);
expect(wrapper.find('InnerChipGroup').text()).toBe('organization');
expect(wrapper.find('Chip').length).toBe(1);
expect(wrapper.find('Chip').text()).toBe('organization');
expect(
wrapper
.find('AnsibleSelect[name="authorization_grant_type"]')

View File

@ -190,7 +190,13 @@ describe('<CredentialForm />', () => {
wrapper.find('textarea#credential-ssh_key_data').prop('value')
).toBe('');
});
test.skip('should show error when error thrown parsing JSON', async () => {
test('should show error when error thrown parsing JSON', async () => {
await act(async () => {
await wrapper
.find('AnsibleSelect[id="credential_type"]')
.invoke('onChange')(null, 10);
});
wrapper.update();
expect(wrapper.find('#credential-gce-file-helper').text()).toBe(
'Select a JSON formatted service account key to autopopulate the following fields.'
);
@ -201,7 +207,15 @@ describe('<CredentialForm />', () => {
});
});
wrapper.update();
expect(wrapper.find('#credential-gce-file-helper').text()).toBe(
expect(
wrapper.find('FormGroup[fieldId="credential-gce-file"]').prop('isValid')
).toBe(false);
expect(
wrapper
.find('FormGroup[fieldId="credential-gce-file"]')
.prop('helperTextInvalid')
).toBe(
'There was an error parsing the file. Please check the file formatting and try again.'
);
});