mirror of
https://github.com/ansible/awx.git
synced 2026-04-05 10:09:20 -02:30
add function for testing output lines
This commit is contained in:
committed by
Marliana Lara
parent
74ef0e7abf
commit
b2922792bc
@@ -140,6 +140,7 @@ function JobEvent({ counter, created, event, stdout, start_line, ...rest }) {
|
|||||||
<JobEventLineToggle />
|
<JobEventLineToggle />
|
||||||
<JobEventLineNumber>{lineNumber}</JobEventLineNumber>
|
<JobEventLineNumber>{lineNumber}</JobEventLineNumber>
|
||||||
<JobEventLineText
|
<JobEventLineText
|
||||||
|
type="job_event_line_text"
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: html,
|
__html: html,
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,15 +1,48 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { mountWithContexts } from '@testUtils/enzymeHelpers';
|
import { mountWithContexts, waitForElement } from '@testUtils/enzymeHelpers';
|
||||||
|
|
||||||
import JobOutput from './JobOutput';
|
import JobOutput from './JobOutput';
|
||||||
|
|
||||||
|
async function checkOutput(wrapper, expectedLines) {
|
||||||
|
await waitForElement(wrapper, 'div[type="job_event"]', (e) => e.length > 1);
|
||||||
|
const jobEventLines = wrapper.find('div[type="job_event_line_text"]');
|
||||||
|
const actualLines = [];
|
||||||
|
jobEventLines.forEach(line => {
|
||||||
|
actualLines.push(line.text());
|
||||||
|
});
|
||||||
|
expectedLines.forEach((line, index) => {
|
||||||
|
expect(actualLines[index]).toEqual(line);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
describe('<JobOutput />', () => {
|
describe('<JobOutput />', () => {
|
||||||
const mockDetails = {
|
const mockDetails = {
|
||||||
name: 'Foo',
|
name: 'Foo',
|
||||||
};
|
};
|
||||||
|
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', async done => {
|
||||||
mountWithContexts(<JobOutput job={mockDetails} />);
|
const wrapper = mountWithContexts(<JobOutput job={mockDetails} />);
|
||||||
|
// wait until not loading
|
||||||
|
await waitForElement(wrapper, 'EmptyStateBody', (e) => e.length === 0);
|
||||||
|
|
||||||
|
// await checkOutput(wrapper, [
|
||||||
|
// '',
|
||||||
|
// 'PLAY [localhost] ***************************************************************08:00:52',
|
||||||
|
// '',
|
||||||
|
// 'TASK [Gathering Facts] *********************************************************08:00:52',
|
||||||
|
// 'ok: [localhost]',
|
||||||
|
// '',
|
||||||
|
// 'TASK [Check Slack accounts against ldap] ***************************************08:00:53',
|
||||||
|
// 'changed: [localhost]',
|
||||||
|
// '',
|
||||||
|
// 'TASK [E-mail output] ***********************************************************08:00:58',
|
||||||
|
// 'skipping: [localhost]',
|
||||||
|
// '',
|
||||||
|
// 'PLAY RECAP *********************************************************************08:00:58',
|
||||||
|
// 'localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0 ',
|
||||||
|
// '',
|
||||||
|
// ]);
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user