mirror of
https://github.com/ansible/awx.git
synced 2026-07-28 16:39:56 -02:30
Cleans up console error thrown from this test. Also fixed the last test as it wasn't actually testing the desired behavior.
This commit is contained in:
@@ -74,14 +74,19 @@ describe('<WorkflowJobTemplate/>', () => {
|
|||||||
data: { results: [{ id: 1, name: 'Org Foo' }] },
|
data: { results: [{ id: 1, name: 'Org Foo' }] },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
beforeEach(() => {
|
afterEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
wrapper.unmount();
|
||||||
|
});
|
||||||
|
describe('User can PUT', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
WorkflowJobTemplatesAPI.readWorkflowJobTemplateOptions.mockResolvedValue({
|
WorkflowJobTemplatesAPI.readWorkflowJobTemplateOptions.mockResolvedValue({
|
||||||
data: { actions: { PUT: {} } },
|
data: { actions: { PUT: {} } },
|
||||||
});
|
});
|
||||||
history = createMemoryHistory({
|
history = createMemoryHistory({
|
||||||
initialEntries: ['/templates/workflow_job_template/1/details'],
|
initialEntries: ['/templates/workflow_job_template/1/details'],
|
||||||
});
|
});
|
||||||
act(() => {
|
await act(async () => {
|
||||||
wrapper = mountWithContexts(
|
wrapper = mountWithContexts(
|
||||||
<Route
|
<Route
|
||||||
path="/templates/workflow_job_template/:id/details"
|
path="/templates/workflow_job_template/:id/details"
|
||||||
@@ -99,17 +104,15 @@ describe('<WorkflowJobTemplate/>', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
|
||||||
jest.clearAllMocks();
|
|
||||||
wrapper.unmount();
|
|
||||||
});
|
|
||||||
test('calls api to get workflow job template data', async () => {
|
test('calls api to get workflow job template data', async () => {
|
||||||
expect(wrapper.find('WorkflowJobTemplate').length).toBe(1);
|
expect(wrapper.find('WorkflowJobTemplate').length).toBe(1);
|
||||||
expect(WorkflowJobTemplatesAPI.readDetail).toBeCalledWith('1');
|
expect(WorkflowJobTemplatesAPI.readDetail).toBeCalledWith('1');
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
await sleep(0);
|
await sleep(0);
|
||||||
expect(WorkflowJobTemplatesAPI.readWebhookKey).toBeCalledWith('1');
|
expect(WorkflowJobTemplatesAPI.readWebhookKey).toBeCalledWith('1');
|
||||||
expect(WorkflowJobTemplatesAPI.readWorkflowJobTemplateOptions).toBeCalled();
|
expect(
|
||||||
|
WorkflowJobTemplatesAPI.readWorkflowJobTemplateOptions
|
||||||
|
).toBeCalled();
|
||||||
|
|
||||||
expect(CredentialsAPI.readDetail).toBeCalledWith(1234567);
|
expect(CredentialsAPI.readDetail).toBeCalledWith(1234567);
|
||||||
expect(OrganizationsAPI.read).toBeCalledWith({
|
expect(OrganizationsAPI.read).toBeCalledWith({
|
||||||
@@ -153,12 +156,37 @@ describe('<WorkflowJobTemplate/>', () => {
|
|||||||
tabs.forEach(t => expect(tc.prop(`aria-label=[${t}]`)));
|
tabs.forEach(t => expect(tc.prop(`aria-label=[${t}]`)));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('should not call for webhook key', async () => {
|
});
|
||||||
|
describe('User cannot PUT', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
WorkflowJobTemplatesAPI.readWorkflowJobTemplateOptions.mockResolvedValueOnce(
|
WorkflowJobTemplatesAPI.readWorkflowJobTemplateOptions.mockResolvedValueOnce(
|
||||||
{
|
{
|
||||||
data: { actions: {} },
|
data: { actions: {} },
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
history = createMemoryHistory({
|
||||||
|
initialEntries: ['/templates/workflow_job_template/1/details'],
|
||||||
|
});
|
||||||
|
await act(async () => {
|
||||||
|
wrapper = mountWithContexts(
|
||||||
|
<Route
|
||||||
|
path="/templates/workflow_job_template/:id/details"
|
||||||
|
component={() => (
|
||||||
|
<WorkflowJobTemplate setBreadcrumb={() => {}} me={mockMe} />
|
||||||
|
)}
|
||||||
|
/>,
|
||||||
|
{
|
||||||
|
context: {
|
||||||
|
router: {
|
||||||
|
history,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('should not call for webhook key', async () => {
|
||||||
expect(WorkflowJobTemplatesAPI.readWebhookKey).not.toBeCalled();
|
expect(WorkflowJobTemplatesAPI.readWebhookKey).not.toBeCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user