Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
[JENKINS-37666] Implement test for regression of clicking steps somet…
Browse files Browse the repository at this point in the history
…imes resulted in weird state (#32)
  • Loading branch information
scherler committed Sep 6, 2016
1 parent d3d4e58 commit a79354d
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 6 deletions.
38 changes: 38 additions & 0 deletions src/main/js/page_objects/blueocean/bluePipelineRunDetail.js
Expand Up @@ -20,6 +20,14 @@ module.exports = {
changes: 'table.changeset-table tr',
tests: 'div.new-failure-block div.result-item',
authors: 'a.authors',
firstResult: {
selector: '//div[contains(@class, "result-item") and position()=1]',
locateStrategy: 'xpath',
},
firstErrorResult: {
selector: '//div[contains(@class, "failure") and position()=1]',
locateStrategy: 'xpath',
},
}
};

Expand Down Expand Up @@ -216,5 +224,35 @@ module.exports.commands = [{
self.waitForElementVisible('@tests');
return self;
},
clickFirstResultItem: function (expand = true) {
var self = this;
self
.waitForElementVisible('@firstResult')
.click('@firstResult');

if (expand) {
self
.waitForElementVisible('code')
.getText('code', function (result) {
this.assert.notEqual(null, result.value);
});
}

return self;
},
clickFirstResultItemFailure: function (expand = true) {
var self = this;
self
.waitForElementVisible('@firstErrorResult')
.click('@firstErrorResult')
if (expand) {
self.waitForElementVisible('code')
.getText('code', function (result) {
this.assert.notEqual(null, result.value);
});
}

return self;
}

}];
43 changes: 43 additions & 0 deletions src/test/js/failing.js
@@ -0,0 +1,43 @@
const JOB = 'noStagesFail';
module.exports = {
// create a simple pipeline, that will produce a failure
'Create Pipeline Job "noStagesFail"': function (browser) {
const pipelinesCreate = browser.page.pipelineCreate().navigate();
// we have used the noStages script as basis
pipelinesCreate.createPipeline(JOB, 'noStagesFailing.groovy');
},

'Build Pipeline Job': function (browser) {
const pipelinePage = browser.page.jobUtils().forJob('noStagesFail');
// start to build the pipeline
pipelinePage.buildStarted(function() {
// Reload the job page and check that there is a build started.
pipelinePage
.waitForElementVisible('div#pipeline-box')
.forRun(1)
.waitForElementVisible('@executer');
});
},
// now tesinting JENKINS-37666
'Check whether the resultItemas are collapsing as expected.': function (browser) {
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun(JOB, 'jenkins', 1);
// we want to analyse the result after the job has finished
browser.waitForJobRunEnded(JOB, function() {
// the failure should collapse
blueRunDetailPage.clickFirstResultItemFailure(false);
// test whether the expand works
blueRunDetailPage.clickFirstResultItem();
// now click again so the result collapse again
blueRunDetailPage.clickFirstResultItem(false);
// now click the node again and see whether only one code is visible
blueRunDetailPage.clickFirstResultItem();
// we now need to get all visible code blocks, but there should be no more then one
browser.elements('css selector', 'code', function (codeCollection) {
this.assert.equal(typeof codeCollection, "object");
this.assert.equal(codeCollection.status, 0);
this.assert.equal(codeCollection.value.length, 1);
});

});
}
};
7 changes: 1 addition & 6 deletions src/test/js/log-karaoke/stages.js
Expand Up @@ -41,12 +41,7 @@ module.exports = {
})
;
// test whether the expand works
nodeDetail.waitForElementVisible('div.result-item')
.click('div.result-item')
.waitForElementVisible('code')
.getText('code', function (result) {
this.assert.notEqual(null, result.value);
});
nodeDetail.clickFirstResultItem(true);
// test whether the stage we seeing is highlighted
nodeDetail.waitForElementVisible('g.pipeline-node-selected');
// test whether log lines are navigatable
Expand Down
13 changes: 13 additions & 0 deletions src/test/resources/test_scripts/noStagesFailing.groovy
@@ -0,0 +1,13 @@
node {
echo 'first step'
sh 'sleep 1; echo `date` first;'
echo 'first step end'
echo 'Second coming up'
sh 'sleep 1; echo `date` second;'
echo '9th'
sh 'sleep 1; echo `date`;'
echo '10th'
sh 'sleep 1; echo `date`;'
echo 'and we are finished'
sh 'echo end; error 1'
}

0 comments on commit a79354d

Please sign in to comment.