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)` const PromptTitle = styled(Title)`
--pf-c-title--m-md--FontWeight: 700; --pf-c-title--m-md--FontWeight: 700;
grid-column: 1 / -1;
`; `;
function ScheduleDetail({ schedule, i18n }) { function ScheduleDetail({ schedule, i18n }) {
@@ -140,7 +141,7 @@ function ScheduleDetail({ schedule, i18n }) {
/> />
{showPromptedFields && ( {showPromptedFields && (
<> <>
<PromptTitle size="md" css="grid-column: 1 / -1;"> <PromptTitle headingLevel="h2">
{i18n._(t`Prompted Fields`)} {i18n._(t`Prompted Fields`)}
</PromptTitle> </PromptTitle>
<Detail label={i18n._(t`Job Type`)} value={job_type} /> <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="Job Tags"]').length).toBe(0);
expect(wrapper.find('Detail[label="Skip 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 () => { test('details should render with the proper values with prompts', async () => {
SchedulesAPI.readCredentials.mockResolvedValueOnce({ SchedulesAPI.readCredentials.mockResolvedValue({
data: { data: {
count: 2, count: 2,
results: [ results: [
@@ -182,6 +182,7 @@ describe('<ScheduleDetail />', () => {
); );
}); });
await waitForElement(wrapper, 'ContentLoading', el => el.length === 0); await waitForElement(wrapper, 'ContentLoading', el => el.length === 0);
// await waitForElement(wrapper, 'Title', el => el.length > 0);
expect( expect(
wrapper wrapper
.find('Detail[label="Name"]') .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="Job Tags"]').length).toBe(1);
expect(wrapper.find('Detail[label="Skip 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( SchedulesAPI.readCredentials.mockRejectedValueOnce(
new Error({ new Error({
response: { response: {
@@ -266,7 +267,7 @@ describe('<ScheduleDetail />', () => {
await waitForElement(wrapper, 'ContentError', el => el.length === 1); 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({ SchedulesAPI.readCredentials.mockResolvedValueOnce({
data: { data: {
count: 0, count: 0,

View File

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

View File

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

View File

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

View File

@@ -190,7 +190,13 @@ describe('<CredentialForm />', () => {
wrapper.find('textarea#credential-ssh_key_data').prop('value') wrapper.find('textarea#credential-ssh_key_data').prop('value')
).toBe(''); ).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( expect(wrapper.find('#credential-gce-file-helper').text()).toBe(
'Select a JSON formatted service account key to autopopulate the following fields.' 'Select a JSON formatted service account key to autopopulate the following fields.'
); );
@@ -201,7 +207,15 @@ describe('<CredentialForm />', () => {
}); });
}); });
wrapper.update(); 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.' 'There was an error parsing the file. Please check the file formatting and try again.'
); );
}); });