import TaskExecutionTime from './TaskExecutionTime';
import TaskCancelButton from './TaskCancelButton';
import TaskLogsLink from './TaskLogsLink';
-
import { STATUSES } from './../constants';
-
-function renderFilter (task) {
- // if (this.props.options && this.props.options.component) {
- // return null;
- // }
- return <td className="thin nowrap">
- <a onClick={this.handleFilter.bind(this, task)} className="icon-filter icon-half-transparent spacer-left" href="#"
- title={`Show only "${task.componentName}" tasks`} data-toggle="tooltip"/>
- </td>;
-}
-
-export default function Task ({ task, index, tasks, onCancelTask, onFilterTask }) {
+export default function Task ({ task, index, tasks, component, onCancelTask, onFilterTask }) {
function handleFilterTask (task, e) {
e.preventDefault();
onFilterTask(task);
</td>
<td className="thin nowrap">
- <a
- onClick={handleFilterTask.bind(this, task)}
- className="icon-filter icon-half-transparent spacer-left"
- href="#"
- title={`Show only "${task.componentName}" tasks`}
- data-toggle="tooltip"/>
+ {!component && (
+ <a
+ onClick={handleFilterTask.bind(this, task)}
+ className="icon-filter icon-half-transparent spacer-left"
+ href="#"
+ title={`Show only "${task.componentName}" tasks`}
+ data-toggle="tooltip"/>
+ )}
</td>
</tr>
);
import Stats from '../../src/main/js/apps/background-tasks/components/Stats';
import Search from '../../src/main/js/apps/background-tasks/components/Search';
import Tasks from '../../src/main/js/apps/background-tasks/components/Tasks';
-import {STATUSES, CURRENTS, DEBOUNCE_DELAY} from '../../src/main/js/apps/background-tasks/constants';
-import {formatDuration} from '../../src/main/js/apps/background-tasks/helpers';
+import { STATUSES, CURRENTS, DEBOUNCE_DELAY } from '../../src/main/js/apps/background-tasks/constants';
+import { formatDuration } from '../../src/main/js/apps/background-tasks/helpers';
let chai = require('chai');
let expect = chai.expect;
});
});
- describe('Header', () => {
- it('should render', () => {
- let component = TestUtils.renderIntoDocument(<Header/>),
- header = TestUtils.scryRenderedDOMComponentsWithTag(component, 'header');
- expect(header.length).to.equal(1);
- });
- });
-
describe('Search', () => {
it('should render search form', () => {
- let spy = sinon.spy();
- let component = TestUtils.renderIntoDocument(<Search options={{}}
- onStatusChange={spy}
- onCurrentsChange={spy}
- onDateChange={spy}/>),
- searchBox = TestUtils.scryRenderedDOMComponentsWithClass(component, 'search-box');
+ let component = TestUtils.renderIntoDocument(
+ <Search
+ types={[]}
+ date={{}}/>
+ ),
+ searchBox = TestUtils.scryRenderedDOMComponentsWithClass(component, 'js-search');
expect(searchBox).to.have.length(1);
});
it('should not render search form', () => {
- let spy = sinon.spy();
- let component = TestUtils.renderIntoDocument(<Search options={{ component: { id: 'ABCD' } }}
- onStatusChange={spy}
- onCurrentsChange={spy}
- onDateChange={spy}/>),
- searchBox = TestUtils.scryRenderedDOMComponentsWithClass(component, 'search-box');
+ let component = TestUtils.renderIntoDocument(
+ <Search
+ options={{ component: { id: 'ABCD' } }}
+ types={[]}
+ date={{}}/>
+ ),
+ searchBox = TestUtils.scryRenderedDOMComponentsWithClass(component, 'js-search');
expect(searchBox).to.be.empty;
});
it('should search', (done) => {
- let spy = sinon.spy(),
- searchSpy = sinon.spy();
- let component = TestUtils.renderIntoDocument(<Search options={{}}
- onStatusChange={spy}
- onCurrentsChange={spy}
- onDateChange={spy}
- onSearch={searchSpy}/>);
- let searchInput = ReactDOM.findDOMNode(TestUtils.findRenderedDOMComponentWithClass(component, 'search-box-input'));
+ let searchSpy = sinon.spy();
+ let component = TestUtils.renderIntoDocument(
+ <Search
+ types={[]}
+ date={{}}
+ onSearch={searchSpy}/>);
+ let searchInput = ReactDOM.findDOMNode(
+ TestUtils.findRenderedDOMComponentWithClass(component, 'js-search'));
searchInput.value = 'some search query';
TestUtils.Simulate.change(searchInput);
setTimeout(() => {
});
it('should reload', () => {
- let spy = sinon.spy(),
- reloadSpy = sinon.spy();
- let component = TestUtils.renderIntoDocument(<Search options={{}}
- onStatusChange={spy}
- onCurrentsChange={spy}
- onDateChange={spy}
- refresh={reloadSpy}/>);
+ let reloadSpy = sinon.spy();
+ let component = TestUtils.renderIntoDocument(
+ <Search
+ types={[]}
+ date={{}}
+ onRefresh={reloadSpy}/>
+ );
let reloadButton = component.refs.reloadButton;
expect(reloadSpy).to.not.have.been.called;
TestUtils.Simulate.click(reloadButton);
it('should trigger cancelling pending', () => {
let spy = sinon.spy();
- let result = TestUtils.renderIntoDocument(<Stats pendingCount="5" cancelPending={spy}/>),
+ let result = TestUtils.renderIntoDocument(<Stats pendingCount="5" onCancelAllPending={spy}/>),
cancelPending = result.refs.cancelPending;
expect(spy).to.not.have.been.called;
TestUtils.Simulate.click(cancelPending);
describe('Failures', () => {
it('should show zero failures', () => {
- let result = TestUtils.renderIntoDocument(<Stats failuresCount="0"/>),
+ let result = TestUtils.renderIntoDocument(<Stats failingCount="0"/>),
failureCounter = result.refs.failureCount;
expect(failureCounter.textContent).to.contain('0');
});
it('should show 5 failures', () => {
- let result = TestUtils.renderIntoDocument(<Stats failuresCount="5"/>),
+ let result = TestUtils.renderIntoDocument(<Stats failingCount="5"/>),
failureCounter = result.refs.failureCount;
expect(failureCounter.textContent).to.contain('5');
});
it('should not show link to failures', () => {
- let result = TestUtils.renderIntoDocument(<Stats failuresCount="0"/>),
+ let result = TestUtils.renderIntoDocument(<Stats failingCount="0"/>),
failureCounter = result.refs.failureCount;
expect(failureCounter.tagName.toLowerCase()).to.not.equal('a');
});
it('should show link to failures', () => {
- let result = TestUtils.renderIntoDocument(<Stats failuresCount="5"/>),
+ let result = TestUtils.renderIntoDocument(<Stats failingCount="5"/>),
failureCounter = result.refs.failureCount;
expect(failureCounter.tagName.toLowerCase()).to.equal('a');
});
it('should trigger filtering failures', () => {
let spy = sinon.spy();
- let result = TestUtils.renderIntoDocument(<Stats failuresCount="5" showFailures={spy}/>),
+ let result = TestUtils.renderIntoDocument(<Stats failingCount="5" onShowFailing={spy}/>),
failureCounter = result.refs.failureCount;
expect(spy).to.not.have.been.called;
TestUtils.Simulate.click(failureCounter);
});
});
- describe('Tasks', () => {
- it('should show list', () => {
- let tasks = [
- { id: 'a' },
- { id: 'b' },
- { id: 'c' }
- ];
- let result = TestUtils.renderIntoDocument(<Tasks tasks={tasks}/>);
- expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'tr')).to.have.length(3 + /* table header */ 1);
- });
- });
-
describe('Helpers', () => {
describe('#formatDuration()', () => {
it('should format 173ms', () => {