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