mirror of
https://github.com/ansible/awx.git
synced 2026-03-02 01:08:48 -03:30
Merge pull request #8803 from marshmalien/8699-wf-notifications-approval-toggle
Show WFJT notification list approval toggle Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -210,6 +210,7 @@ function WorkflowJobTemplate({ i18n, me, setBreadcrumb }) {
|
|||||||
id={Number(templateId)}
|
id={Number(templateId)}
|
||||||
canToggleNotifications={isNotifAdmin}
|
canToggleNotifications={isNotifAdmin}
|
||||||
apiModel={WorkflowJobTemplatesAPI}
|
apiModel={WorkflowJobTemplatesAPI}
|
||||||
|
showApprovalsToggle
|
||||||
/>
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { createMemoryHistory } from 'history';
|
import { createMemoryHistory } from 'history';
|
||||||
import { act } from 'react-dom/test-utils';
|
import { act } from 'react-dom/test-utils';
|
||||||
import { WorkflowJobTemplatesAPI, OrganizationsAPI } from '../../api';
|
import {
|
||||||
|
WorkflowJobTemplatesAPI,
|
||||||
|
OrganizationsAPI,
|
||||||
|
NotificationTemplatesAPI,
|
||||||
|
} from '../../api';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
mountWithContexts,
|
mountWithContexts,
|
||||||
@@ -12,6 +16,7 @@ import mockWorkflowJobTemplateData from './shared/data.workflow_job_template.jso
|
|||||||
|
|
||||||
jest.mock('../../api/models/WorkflowJobTemplates');
|
jest.mock('../../api/models/WorkflowJobTemplates');
|
||||||
jest.mock('../../api/models/Organizations');
|
jest.mock('../../api/models/Organizations');
|
||||||
|
jest.mock('../../api/models/NotificationTemplates');
|
||||||
|
|
||||||
const mockMe = {
|
const mockMe = {
|
||||||
is_super_user: true,
|
is_super_user: true,
|
||||||
@@ -193,4 +198,65 @@ describe('<WorkflowJobTemplate />', () => {
|
|||||||
});
|
});
|
||||||
expect(WorkflowJobTemplatesAPI.readWebhookKey).not.toHaveBeenCalled();
|
expect(WorkflowJobTemplatesAPI.readWebhookKey).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render workflow notifications list view', async () => {
|
||||||
|
WorkflowJobTemplatesAPI.readNotificationTemplatesSuccess.mockReturnValue({
|
||||||
|
data: { results: [{ id: 1 }] },
|
||||||
|
});
|
||||||
|
WorkflowJobTemplatesAPI.readNotificationTemplatesError.mockReturnValue({
|
||||||
|
data: { results: [{ id: 2 }] },
|
||||||
|
});
|
||||||
|
WorkflowJobTemplatesAPI.readNotificationTemplatesStarted.mockReturnValue({
|
||||||
|
data: { results: [{ id: 3 }] },
|
||||||
|
});
|
||||||
|
WorkflowJobTemplatesAPI.readNotificationTemplatesApprovals.mockReturnValue({
|
||||||
|
data: { results: [{ id: 4 }] },
|
||||||
|
});
|
||||||
|
NotificationTemplatesAPI.readOptions.mockReturnValue({
|
||||||
|
data: {
|
||||||
|
actions: {
|
||||||
|
GET: {
|
||||||
|
notification_type: {
|
||||||
|
choices: [['email', 'Email']],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
NotificationTemplatesAPI.read.mockReturnValue({
|
||||||
|
data: {
|
||||||
|
count: 2,
|
||||||
|
results: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'Notification one',
|
||||||
|
url: '/api/v2/notification_templates/1/',
|
||||||
|
notification_type: 'email',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const history = createMemoryHistory({
|
||||||
|
initialEntries: ['/templates/workflow_job_template/1/notifications'],
|
||||||
|
});
|
||||||
|
await act(async () => {
|
||||||
|
wrapper = mountWithContexts(
|
||||||
|
<WorkflowJobTemplate
|
||||||
|
setBreadcrumb={() => {}}
|
||||||
|
me={{
|
||||||
|
is_system_auditor: true,
|
||||||
|
}}
|
||||||
|
/>,
|
||||||
|
{
|
||||||
|
context: { router: { history } },
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await waitForElement(wrapper, 'ContentLoading', el => el.length === 0);
|
||||||
|
expect(wrapper.find('NotificationListItem').length).toBe(1);
|
||||||
|
expect(wrapper.find('Switch[label="Approval"]')).toHaveLength(1);
|
||||||
|
expect(wrapper.find('Switch[label="Start"]')).toHaveLength(1);
|
||||||
|
expect(wrapper.find('Switch[label="Success"]')).toHaveLength(1);
|
||||||
|
expect(wrapper.find('Switch[label="Failure"]')).toHaveLength(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user