Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring of the tests for lab #6875

Merged
merged 9 commits into from
Feb 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions test/ipynb/groovy/JavaWidgetsTest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@
"//w.orientation = \"vertical\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"w.slider_color = \"#087636\""
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
48 changes: 0 additions & 48 deletions test/ipynb/groovy/LoadMagicCommandTest.ipynb

This file was deleted.

92 changes: 0 additions & 92 deletions test/ipynb/groovy/ShowNullExecutionResultTest.ipynb

This file was deleted.

97 changes: 47 additions & 50 deletions test/js/beakerx.po.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function BeakerXPageObject() {
this.publishAndOpenNbviewerWindow = function () {
this.clickPublish();
browser.pause(1000);
browser.$('button.btn.btn-default.btn-sm.btn-primary').click();
this.clickDialogPublishButton();
browser.waitUntil(function () {
var windowHandles = browser.windowHandles();
return windowHandles.value.length === 2;
Expand All @@ -50,12 +50,6 @@ function BeakerXPageObject() {
console.log(browser.getUrl());
};

this.clickCellRunAll = function () {
browser.click('=Cell');
browser.waitForEnabled('=Run All');
browser.click('=Run All')
};

this.getDtContainerByIndex = function (index) {
return this.getCodeCellByIndex(index).$('div.dtcontainer');
};
Expand Down Expand Up @@ -88,20 +82,57 @@ function BeakerXPageObject() {
return codeCell.$('#svgg');
};

this.runCellAndCheckOutputText = function (index, expectedText) {
this.runAndCheckOutputTextOfExecuteResult = function (cellIndex, expectedText) {
this.runCellAndCheckTextHandleError(cellIndex, expectedText, this.getAllOutputsExecuteResult);
};

this.runAndCheckOutputTextOfStdout = function (cellIndex, expectedText) {
this.runCellAndCheckTextHandleError(cellIndex, expectedText, this.getAllOutputsStdout);
};

this.runAndCheckOutputTextOfStderr = function (cellIndex, expectedText) {
this.runCellAndCheckTextHandleError(cellIndex, expectedText, this.getAllOutputsStderr);
};

this.runCellAndCheckTextHandleError = function(cellIndex, expectedText, getTextElements){
var resultTest;
try {
resultTest = this.runCellToGetOutputTextElement(index).getText();
} catch (e) {
console.log(expectedText + ' --- ' + e.toString());
resultTest = this.runCellToGetOutputTextElement(index).getText();
var codeCell;
var attempt = 3;
while(attempt > 0){
try {
codeCell = this.runCodeCellByIndex(cellIndex);
this.kernelIdleIcon.waitForEnabled();
resultTest = getTextElements(codeCell)[0].getText();
attempt = 0;
} catch (e) {
attempt -= 1;
}
}
expect(resultTest).toMatch(expectedText);
};

this.runCellToGetOutputTextElement = function (index) {
var codeCell = this.runCodeCellByIndex(index);
return codeCell.$(this.getAllOutputTextCss());
this.waitAndCheckOutputTextOfExecuteResult = function (cellIndex, expectedText, outputIndex) {
this.waitAndCheckOutputText(cellIndex, expectedText, this.getAllOutputsExecuteResult, outputIndex);
};

this.waitAndCheckOutputTextOfStdout = function (cellIndex, expectedText, outputIndex) {
this.waitAndCheckOutputText(cellIndex, expectedText, this.getAllOutputsStdout, outputIndex);
};

this.waitAndCheckOutputTextOfStderr = function (cellIndex, expectedText, outputIndex) {
this.waitAndCheckOutputText(cellIndex, expectedText, this.getAllOutputsStderr, outputIndex);
};

this.waitAndCheckOutputText = function (index, expectedText, getTextElements, outputIndex) {
if(!outputIndex){
outputIndex = 0;
}
var codeCell = this.getCodeCellByIndex(index);
codeCell.scroll();
browser.waitUntil(function () {
var output = getTextElements(codeCell)[outputIndex];
return output.isEnabled() && expectedText.test(output.getText());
}, 50000, 'expected output toMatch ' + expectedText);
};

this.plotLegendContainerIsEnabled = function (dtcontainer) {
Expand All @@ -127,40 +158,6 @@ function BeakerXPageObject() {
return codeCell.$('div.dataTables_scrollBody');
};

this.checkCellOutputText = function (index, expectedText) {
var codeCell = this.getCodeCellByIndex(index);
codeCell.scroll();
var resultTest;
try {
resultTest = codeCell.$(this.getAllOutputTextCss()).getText();
} catch (e) {
console.log(expectedText + ' --- ' + e.toString());
resultTest = this.runCellToGetOutputTextElement(index).getText();
}
expect(resultTest).toMatch(expectedText);
};

this.waitAndCheckCellOutputStderrText = function (index, expectedText) {
this.waitAndCheckCellOutputText(index, expectedText, this.getOutputStderrCss());
};

this.waitAndCheckCellOutputStdoutText = function (index, expectedText) {
this.waitAndCheckCellOutputText(index, expectedText, this.getOutputStdoutCss());
};

this.waitAndCheckCellOutputResultText = function (index, expectedText) {
this.waitAndCheckCellOutputText(index, expectedText, this.getOutputResultCss());
};

this.waitAndCheckCellOutputText = function (index, expectedText, selector) {
var codeCell = this.getCodeCellByIndex(index);
codeCell.scroll();
browser.waitUntil(function () {
var output = codeCell.$(selector);
return output.isEnabled() && expectedText.test(output.getText());
}, 50000, 'expected output toMatch ' + expectedText);
};

this.getTableColumnLabel = function (tableIndex, columnIndex) {
var table = $$("div.dataTables_scrollHead") [tableIndex];
var tableColumnLabels = table.$$("span.header-text");
Expand Down
28 changes: 15 additions & 13 deletions test/js/clojure/clojureTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
var BeakerXPageObject = require('../beakerx.po.js');
var beakerxPO;

describe('ClojureTutorial notebook', function () {
describe('Clojure base tests ', function () {

beforeAll(function () {
beakerxPO = new BeakerXPageObject();
Expand All @@ -28,24 +28,26 @@ describe('ClojureTutorial notebook', function () {
beakerxPO.closeAndHaltNotebook();
});

describe('Run first cell. ', function () {
it('Output contains "0, 1, 1, 2, 3, 5"', function () {
beakerxPO.kernelIdleIcon.waitForEnabled();
beakerxPO.runCellAndCheckOutputText(0, '0, 1, 1, 2, 3, 5');
var cellIndex;

describe('Run first cell ', function () {
it('Execute result output contains "0, 1, 1, 2, 3, 5" ', function () {
cellIndex = 0;
beakerxPO.runAndCheckOutputTextOfExecuteResult(cellIndex, /0, 1, 1, 2, 3, 5/);
});
});

describe('Run 2nd cell. ', function () {
it('Output contains "Will print"', function () {
beakerxPO.kernelIdleIcon.waitForEnabled();
beakerxPO.runCellAndCheckOutputText(1, 'Will print');
describe('Run 2nd cell ', function () {
it('Stdout output contains "Will print" ', function () {
cellIndex += 1;
beakerxPO.runAndCheckOutputTextOfStdout(cellIndex, /Will print/);
});
});

describe('Run 3rd cell. ', function () {
it('Output contains "Distinct: 36"', function () {
beakerxPO.kernelIdleIcon.waitForEnabled();
beakerxPO.runCellAndCheckOutputText(2, 'Distinct: 36');
describe('Run 3rd cell ', function () {
it('Execute result output contains "Distinct: 36" ', function () {
cellIndex += 1;
beakerxPO.runAndCheckOutputTextOfStdout(cellIndex, /Distinct: 36/);
});
});

Expand Down
6 changes: 3 additions & 3 deletions test/js/groovy/autotranslationGroovyTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
var BeakerXPageObject = require('../beakerx.po.js');
var beakerxPO;

describe('Autotranslation Groovy to JavaScript and D3 js', function () {
describe('Autotranslation Groovy to JavaScript and D3 ', function () {

beforeAll(function () {
beakerxPO = new BeakerXPageObject();
Expand All @@ -28,8 +28,8 @@ describe('Autotranslation Groovy to JavaScript and D3 js', function () {
beakerxPO.closeAndHaltNotebook();
});

describe('Groovy code', function(){
it('Output contains data table', function(){
describe('Groovy code ', function(){
it('Output contains data table ', function(){
var codeCell = beakerxPO.runCodeCellByIndex(0);
var bkoTable = codeCell.$('div.bko-table');
expect(bkoTable.isEnabled()).toBeTruthy();
Expand Down
Loading