mirror of
https://github.com/ansible/awx.git
synced 2026-01-22 15:08:03 -03:30
Fix existing test failures
This commit is contained in:
parent
38bb4f3f3c
commit
f57876b6d9
@ -11,6 +11,7 @@ describe('<Notifications />', () => {
|
||||
onReadSuccess={() => {}}
|
||||
onCreateError={() => {}}
|
||||
onCreateSuccess={() => {}}
|
||||
canToggleNotifications
|
||||
/>
|
||||
);
|
||||
});
|
||||
@ -24,6 +25,7 @@ describe('<Notifications />', () => {
|
||||
onReadSuccess={() => {}}
|
||||
onCreateError={() => {}}
|
||||
onCreateSuccess={() => {}}
|
||||
canToggleNotifications
|
||||
/>
|
||||
);
|
||||
expect(spy).toHaveBeenCalled();
|
||||
@ -38,6 +40,7 @@ describe('<Notifications />', () => {
|
||||
onReadSuccess={() => {}}
|
||||
onCreateError={() => {}}
|
||||
onCreateSuccess={() => {}}
|
||||
canToggleNotifications
|
||||
/>
|
||||
).find('Notifications');
|
||||
wrapper.instance().toggleNotification(1, true, 'success');
|
||||
@ -56,6 +59,7 @@ describe('<Notifications />', () => {
|
||||
onReadSuccess={() => {}}
|
||||
onCreateError={() => {}}
|
||||
onCreateSuccess={onCreateSuccess}
|
||||
canToggleNotifications
|
||||
/>
|
||||
).find('Notifications');
|
||||
wrapper.setState({ successTemplateIds: [44] });
|
||||
@ -76,6 +80,7 @@ describe('<Notifications />', () => {
|
||||
onReadSuccess={() => {}}
|
||||
onCreateError={() => {}}
|
||||
onCreateSuccess={() => {}}
|
||||
canToggleNotifications
|
||||
/>
|
||||
).find('Notifications');
|
||||
wrapper.instance().toggleNotification(1, true, 'error');
|
||||
@ -94,6 +99,7 @@ describe('<Notifications />', () => {
|
||||
onReadSuccess={() => {}}
|
||||
onCreateError={onCreateError}
|
||||
onCreateSuccess={() => {}}
|
||||
canToggleNotifications
|
||||
/>
|
||||
).find('Notifications');
|
||||
wrapper.setState({ errorTemplateIds: [44] });
|
||||
@ -144,6 +150,7 @@ describe('<Notifications />', () => {
|
||||
onReadSuccess={onReadSuccess}
|
||||
onCreateError={() => {}}
|
||||
onCreateSuccess={() => {}}
|
||||
canToggleNotifications
|
||||
/>
|
||||
).find('Notifications');
|
||||
wrapper.instance().updateUrl = jest.fn();
|
||||
|
||||
@ -20,6 +20,7 @@ describe('<NotificationListItem />', () => {
|
||||
toggleNotification={toggleNotification}
|
||||
detailUrl="/foo"
|
||||
notificationType="slack"
|
||||
canToggleNotifications
|
||||
/>
|
||||
);
|
||||
expect(wrapper.length).toBe(1);
|
||||
@ -33,6 +34,7 @@ describe('<NotificationListItem />', () => {
|
||||
toggleNotification={toggleNotification}
|
||||
detailUrl="/foo"
|
||||
notificationType="slack"
|
||||
canToggleNotifications
|
||||
/>
|
||||
);
|
||||
wrapper.find('Switch').first().find('input').simulate('change');
|
||||
@ -47,6 +49,7 @@ describe('<NotificationListItem />', () => {
|
||||
toggleNotification={toggleNotification}
|
||||
detailUrl="/foo"
|
||||
notificationType="slack"
|
||||
canToggleNotifications
|
||||
/>
|
||||
);
|
||||
wrapper.find('Switch').first().find('input').simulate('change');
|
||||
@ -61,6 +64,7 @@ describe('<NotificationListItem />', () => {
|
||||
toggleNotification={toggleNotification}
|
||||
detailUrl="/foo"
|
||||
notificationType="slack"
|
||||
canToggleNotifications
|
||||
/>
|
||||
);
|
||||
wrapper.find('Switch').at(1).find('input').simulate('change');
|
||||
@ -75,6 +79,7 @@ describe('<NotificationListItem />', () => {
|
||||
toggleNotification={toggleNotification}
|
||||
detailUrl="/foo"
|
||||
notificationType="slack"
|
||||
canToggleNotifications
|
||||
/>
|
||||
);
|
||||
wrapper.find('Switch').at(1).find('input').simulate('change');
|
||||
|
||||
@ -16,13 +16,31 @@ const mockData = [
|
||||
role: {
|
||||
name: 'foo',
|
||||
id: 2,
|
||||
user_capabilities: {
|
||||
unattach: true
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
const organization = {
|
||||
id: 1,
|
||||
name: 'Default',
|
||||
summary_fields: {
|
||||
object_roles: {},
|
||||
user_capabilities: {
|
||||
edit: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const api = {
|
||||
foo: () => {}
|
||||
};
|
||||
|
||||
describe('<OrganizationAccessList />', () => {
|
||||
afterEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
@ -33,6 +51,8 @@ describe('<OrganizationAccessList />', () => {
|
||||
<OrganizationAccessList
|
||||
getAccessList={() => {}}
|
||||
removeRole={() => {}}
|
||||
api={api}
|
||||
organization={organization}
|
||||
/>
|
||||
);
|
||||
});
|
||||
@ -42,9 +62,13 @@ describe('<OrganizationAccessList />', () => {
|
||||
<OrganizationAccessList
|
||||
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
||||
removeRole={() => {}}
|
||||
api={api}
|
||||
organization={organization}
|
||||
/>
|
||||
).find('OrganizationAccessList');
|
||||
|
||||
// expect(wrapper.debug()).toBe(false);
|
||||
|
||||
setImmediate(() => {
|
||||
expect(wrapper.state().results).toEqual(mockData);
|
||||
done();
|
||||
@ -57,6 +81,8 @@ describe('<OrganizationAccessList />', () => {
|
||||
<OrganizationAccessList
|
||||
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
||||
removeRole={() => {}}
|
||||
api={api}
|
||||
organization={organization}
|
||||
/>
|
||||
).find('OrganizationAccessList');
|
||||
expect(onSort).not.toHaveBeenCalled();
|
||||
@ -74,6 +100,8 @@ describe('<OrganizationAccessList />', () => {
|
||||
<OrganizationAccessList
|
||||
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
||||
removeRole={() => {}}
|
||||
api={api}
|
||||
organization={organization}
|
||||
/>
|
||||
).find('OrganizationAccessList');
|
||||
|
||||
@ -94,6 +122,8 @@ describe('<OrganizationAccessList />', () => {
|
||||
<OrganizationAccessList
|
||||
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
||||
removeRole={() => {}}
|
||||
api={api}
|
||||
organization={organization}
|
||||
/>
|
||||
).find('OrganizationAccessList');
|
||||
expect(handleWarning).not.toHaveBeenCalled();
|
||||
@ -117,6 +147,8 @@ describe('<OrganizationAccessList />', () => {
|
||||
<OrganizationAccessList
|
||||
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
||||
removeRole={() => {}}
|
||||
api={api}
|
||||
organization={organization}
|
||||
/>
|
||||
).find('OrganizationAccessList');
|
||||
|
||||
|
||||
@ -3,7 +3,11 @@ import { mountWithContexts } from '../../../../enzymeHelpers';
|
||||
import Organization from '../../../../../src/pages/Organizations/screens/Organization/Organization';
|
||||
|
||||
describe('<OrganizationView />', () => {
|
||||
const me = {
|
||||
is_super_user: true,
|
||||
is_system_auditor: false
|
||||
};
|
||||
test('initially renders succesfully', () => {
|
||||
mountWithContexts(<Organization />);
|
||||
mountWithContexts(<Organization me={me} />);
|
||||
});
|
||||
});
|
||||
|
||||
@ -3,8 +3,12 @@ import { mountWithContexts } from '../../../../enzymeHelpers';
|
||||
import OrganizationAccess from '../../../../../src/pages/Organizations/screens/Organization/OrganizationAccess';
|
||||
|
||||
describe('<OrganizationAccess />', () => {
|
||||
const organization = {
|
||||
id: 1,
|
||||
name: 'Default'
|
||||
};
|
||||
test('initially renders succesfully', () => {
|
||||
mountWithContexts(<OrganizationAccess />);
|
||||
mountWithContexts(<OrganizationAccess organization={organization} />);
|
||||
});
|
||||
|
||||
test('passed methods as props are called appropriately', async () => {
|
||||
@ -14,13 +18,14 @@ describe('<OrganizationAccess />', () => {
|
||||
const mockResponse = {
|
||||
status: 'success',
|
||||
};
|
||||
const wrapper = mountWithContexts(<OrganizationAccess />, { context: { network: {
|
||||
api: {
|
||||
getOrganizationAccessList: () => Promise.resolve(mockAPIAccessList),
|
||||
disassociate: () => Promise.resolve(mockResponse)
|
||||
},
|
||||
handleHttpError: () => {}
|
||||
} } }).find('OrganizationAccess');
|
||||
const wrapper = mountWithContexts(<OrganizationAccess organization={organization} />,
|
||||
{ context: { network: {
|
||||
api: {
|
||||
getOrganizationAccessList: () => Promise.resolve(mockAPIAccessList),
|
||||
disassociate: () => Promise.resolve(mockResponse)
|
||||
},
|
||||
handleHttpError: () => {}
|
||||
} } }).find('OrganizationAccess');
|
||||
const accessList = await wrapper.instance().getOrgAccessList();
|
||||
expect(accessList).toEqual(mockAPIAccessList);
|
||||
const resp = await wrapper.instance().removeRole(2, 3, 'users');
|
||||
|
||||
@ -8,7 +8,12 @@ describe('<OrganizationDetail />', () => {
|
||||
description: 'Bar',
|
||||
custom_virtualenv: 'Fizz',
|
||||
created: 'Bat',
|
||||
modified: 'Boo'
|
||||
modified: 'Boo',
|
||||
summary_fields: {
|
||||
user_capabilities: {
|
||||
edit: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
test('initially renders succesfully', () => {
|
||||
|
||||
@ -18,7 +18,7 @@ describe('<OrganizationNotifications />', () => {
|
||||
|
||||
test('initially renders succesfully', () => {
|
||||
mountWithContexts(
|
||||
<OrganizationNotifications />, { context: { network: {
|
||||
<OrganizationNotifications canToggleNotifications />, { context: { network: {
|
||||
api,
|
||||
handleHttpError: () => {}
|
||||
} } }
|
||||
@ -26,7 +26,7 @@ describe('<OrganizationNotifications />', () => {
|
||||
});
|
||||
test('handles api requests', () => {
|
||||
const wrapper = mountWithContexts(
|
||||
<OrganizationNotifications />, { context: { network: {
|
||||
<OrganizationNotifications canToggleNotifications />, { context: { network: {
|
||||
api,
|
||||
handleHttpError: () => {}
|
||||
} } }
|
||||
|
||||
@ -476,7 +476,9 @@ class OrganizationAccessList extends React.Component {
|
||||
}
|
||||
|
||||
OrganizationAccessList.propTypes = {
|
||||
api: PropTypes.shape().isRequired,
|
||||
getAccessList: PropTypes.func.isRequired,
|
||||
organization: PropTypes.shape().isRequired,
|
||||
removeRole: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user