Skip to content

Commit

Permalink
Merge pull request #189 from jpwhite4/usagetree
Browse files Browse the repository at this point in the history
Fix regression bug in Usage Tree.
  • Loading branch information
jpwhite4 authored Jul 21, 2017
2 parents d673417 + bb040c5 commit d8b0888
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 7 deletions.
4 changes: 3 additions & 1 deletion html/gui/js/modules/Usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,10 @@ Ext.extend(XDMoD.Module.Usage, XDMoD.PortalModule, {

var disableNode = false;

var matchkey;
for (var i = 0; i < CCR.xdmod.ui.disabledMenus.length && !disableNode; i++) {
disableNode = n.attributes.group_by == CCR.xdmod.ui.disabledMenus[i].group_by && n.attributes.category == CCR.xdmod.ui.disabledMenus[i].category;
matchkey = CCR.xdmod.ui.disabledMenus[i].category ? 'category' : 'realm';
disableNode = n.attributes.group_by === CCR.xdmod.ui.disabledMenus[i].group_by && n.attributes[matchkey] === CCR.xdmod.ui.disabledMenus[i][matchkey];
}

if (disableNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,56 @@ describe('Usage', function () {
start: '2016-12-25',
end: '2017-01-02'
};
describe('Usage Tab', function xdmod() {
describe('(Center Director)', function xdmod() {
it('Selected', function () {
browser.waitForLoadedThenClick(usg.tab).call();
browser.waitForChart();
browser.waitForExist(usg.chartByTitle('CPU Hours: Total'));
});
it('Set a known start and end date', function meSetStartEnd() {
browser.setValue(usg.startField, baselineDate.start);
browser.setValue(usg.endField, baselineDate.end);
browser.click(usg.refreshButton);
browser.waitForExist(usg.chartXAxisLabelByName(baselineDate.start));
});
it('Select Job Size Min', function () {
browser.waitForLoadedThenClick(usg.jobSizeMin);
});
it('Legend Text is Correct', function () {
browser.waitForLoadedThenClick(usg.treeNodeByPath('Jobs Summary', 'Job Size: Min'));
browser.waitForExist(usg.chartByTitle('Job Size: Min (Core Count)'));
usg.checkLegendText('Screwdriver');
});
it('View CPU Hours by System Username', function () {
browser.waitForLoadedThenClick(usg.unfoldTreeNodeByName('Jobs Summary'));
browser.waitForLoadedThenClick(usg.unfoldTreeNodeByName('Jobs by System Username'));
browser.waitUntilAnimEndAndClick(usg.treeNodeByPath('Jobs by System Username', 'CPU Hours: Per Job'));
browser.waitForExist(usg.chartByTitle('CPU Hours: Per Job: by System Username'));
});
});
logIn.logout();
describe('(Public User)', function () {
it('Selected', function () {
browser.waitForLoadedThenClick(usg.tab).call();
browser.waitForChart();
browser.waitForExist(usg.chartByTitle('CPU Hours: Total'));
});
it('Set a known start and end date', function meSetStartEnd() {
browser.setValue(usg.startField, baselineDate.start);
browser.setValue(usg.endField, baselineDate.end);
browser.click(usg.refreshButton);
browser.waitForExist(usg.chartXAxisLabelByName(baselineDate.start));
});
it('View Job Size Min', function () {
browser.waitForLoadedThenClick(usg.treeNodeByPath('Jobs Summary', 'Job Size: Min'));
browser.waitForExist(usg.chartByTitle('Job Size: Min (Core Count)'));
usg.checkLegendText('Screwdriver');
});
it('Confirm System Username is not selectable', function () {
browser.waitForLoadedThenClick(usg.unfoldTreeNodeByName('Jobs Summary'));
browser.waitUntilAnimEndAndClick(usg.topTreeNodeByName('Jobs by System Username'));
// The click should do nothing and the chart should remain unchanged
// since nothing should happen, there is no action to wait for, so we
// have to pause for a bit
browser.pause(500);
browser.waitForExist(usg.chartByTitle('Job Size: Min (Core Count)'));
});
});
});
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
/* eslint-env node, es6 */
class Usage {
constructor() {
this.tab = '#main_tab_panel__tg_usage';
this.startField = '#tg_usage input[id^=start_field_ext]';
this.endField = '#tg_usage input[id^=end_field_ext]';
this.jobSizeMin = '.x-tree-root-node > li:nth-child(1) > ul:nth-child(2) > li:nth-child(5)';
this.legendText = 'g.highcharts-legend-item';
this.refreshButton = '//div[@id="tg_usage"]//button[text()="Refresh"]/ancestor::node()[5]';
this.topTreeNodeByName = function (name) {
return '//div[@id="tg_usage"]//div[@class="x-tree-root-node"]/li/div[contains(@class,"x-tree-node-el")]//span[text() = "' + name + '"]';
};
this.treeNodeByPath = function (topname, childname) {
return module.exports.topTreeNodeByName(topname) + '/ancestor::node()[3]//span[text() = "' + childname + '"]';
};
this.unfoldTreeNodeByName = function (name) {
return module.exports.topTreeNodeByName(name) + '/ancestor::node()[2]/img[contains(@class,"x-tree-ec-icon")]';
};
this.chart = '//div[@id="tg_usage"]//div[@class="highcharts-container"]//*[local-name() = "svg"]';
this.chartByTitle = function (title) {
return module.exports.chart + '/*[name()="text" and contains(@class, "title")]/*[name()="tspan" and contains(text(),"' + title + '")]';
};
this.chartXAxisLabelByName = function (name) {
return module.exports.chart + '/*[name() = "g" and contains(@class, "highcharts-xaxis-labels")]/*[name() = "text" and text() = "' + name + '"]';
};
}

checkLegendText(text) {
browser.waitForChart();
browser.pause(2500);
browser.waitForExist(this.legendText, 50000);
expect(browser.getText(this.legendText)).to.equal(text);
}
Expand Down

0 comments on commit d8b0888

Please sign in to comment.