Skip to content

Commit

Permalink
Merge pull request #1624 from briehl/log-viewer
Browse files Browse the repository at this point in the history
Issue #1619 - disable button at start
  • Loading branch information
briehl committed Apr 8, 2020
2 parents eb7f02e + 84ebcb3 commit 30cdd18
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 11 deletions.
16 changes: 8 additions & 8 deletions kbase-extension/static/kbase/js/util/jobLogViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ define([
ui: {
buttons: {
enabled: [],
disabled: ['play', 'stop', 'top', 'bottom']
disabled: ['play', 'stop', 'top', 'bottom', 'expand']
}
},
next: [{
Expand Down Expand Up @@ -87,7 +87,7 @@ define([
ui: {
buttons: {
enabled: [],
disabled: ['play', 'stop', 'top', 'bottom']
disabled: ['play', 'stop', 'top', 'bottom', 'expand']
}
},
next: [{
Expand Down Expand Up @@ -136,7 +136,7 @@ define([
},
ui: {
buttons: {
enabled: ['stop'],
enabled: ['stop', 'expand'],
disabled: ['play', 'top', 'bottom']
}
},
Expand Down Expand Up @@ -186,7 +186,7 @@ define([
},
ui: {
buttons: {
enabled: ['play', 'top', 'bottom'],
enabled: ['play', 'top', 'bottom', 'expand'],
disabled: ['stop']
}
},
Expand Down Expand Up @@ -229,7 +229,7 @@ define([
},
ui: {
buttons: {
enabled: ['top', 'bottom'],
enabled: ['top', 'bottom', 'expand'],
disabled: ['play', 'stop']
}
},
Expand Down Expand Up @@ -257,7 +257,7 @@ define([
},
ui: {
buttons: {
enabled: ['top', 'bottom'],
enabled: ['top', 'bottom', 'expand'],
disabled: ['play', 'stop']
}
},
Expand Down Expand Up @@ -285,7 +285,7 @@ define([
},
ui: {
buttons: {
enabled: ['top', 'bottom'],
enabled: ['top', 'bottom', 'expand'],
disabled: ['play', 'stop']
}
},
Expand Down Expand Up @@ -317,7 +317,7 @@ define([
ui: {
buttons: {
enabled: [],
disabled: ['play', 'stop', 'top', 'bottom']
disabled: ['play', 'stop', 'top', 'bottom', 'expand']
}
},
on: {
Expand Down
71 changes: 68 additions & 3 deletions test/unit/spec/Util/jobLogViewerSpec.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
/*global define, describe, it, expect, jasmine, beforeEach, afterEach*/
/*jslint white: true*/
define([
'util/jobLogViewer'
'util/jobLogViewer',
'common/runtime'
], (
JobLogViewer
JobLogViewer,
Runtime
) => {
describe('Test the job log viewer module', () => {
let hostNode = null;
let hostNode = null,
runtimeBus = null;
beforeEach(() => {
hostNode = document.createElement('div');
document.body.appendChild(hostNode);
runtimeBus = Runtime.make().bus();
});

afterEach(() => {
hostNode.remove();
window.kbaseRuntime = null;
});

it('Should load the module code successfully', () => {
Expand Down Expand Up @@ -60,5 +65,65 @@ define([
viewer.detach();
expect(hostNode.innerHTML).toBe('');
});

it('Should send a bus messages requesting job status information at startup', (done) => {
let viewer = JobLogViewer.make();
const jobId = 'testJob1';
const arg = {
node: hostNode,
jobId: jobId
};
runtimeBus.on('request-job-status', (msg) => {
expect(msg).toEqual({jobId: jobId});
viewer.detach();
done();
});
viewer.start(arg);
});

it('Should react to job status messages', (done) => {
let viewer = JobLogViewer.make();
const jobId = 'testJobStatusMsg';
const arg = {
node: hostNode,
jobId: jobId
};
runtimeBus.on('request-job-status', (msg) => {
expect(msg).toEqual({jobId: jobId});
runtimeBus.send(
{
jobId: jobId,
jobState: {
job_state: 'in-progress'
}
},
{
channel: {
jobId: jobId
},
key: {
type: 'job-status'
}
}
);
viewer.detach();
done();
});
viewer.start(arg);
});

it('Should start with all buttons disabled', () => {
let viewer = JobLogViewer.make();
const jobId = 'testBtnState';
const arg = {
node: hostNode,
jobId: jobId
};
viewer.start(arg);
let btns = hostNode.querySelectorAll('div[data-element="header"] button');
btns.forEach(btn => {
expect(btn.classList.contains('disabled')).toBeTruthy();
});
});
});
})

0 comments on commit 30cdd18

Please sign in to comment.