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

Commit

Permalink
FIX Jenkins 38248 (#58)
Browse files Browse the repository at this point in the history
* [master] fix jsdoc comment

* [master] raise sleep so that slower boxes can test as well. refactor log console validation

* [JENKINS-38248] fix typo

* [JENKINS-38248] less flaky tests
  • Loading branch information
scherler committed Oct 6, 2016
1 parent a21c0de commit 45eb6aa
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 42 deletions.
5 changes: 3 additions & 2 deletions src/main/js/custom_commands/moveClassicBottomStickyButtons.js
@@ -1,5 +1,6 @@
/**
* Nightwatch command to move the config page buttons out of the way.
/**@module moveClassicBottomStickyButtons
* @memberof custom_commands
* @description Nightwatch command to move the config page buttons out of the way.
* See http://nightwatchjs.org/guide#writing-custom-commands
* <p/>
* The config page save/apply buttons in classic Jenkins is sticky positioned at the bottom
Expand Down
8 changes: 4 additions & 4 deletions src/main/js/custom_commands/removePageHead.js
@@ -1,13 +1,13 @@
/**
* Nightwatch command to remove the breadcrumb bar on classic jenkins pages.
/** @module removePageHead
* @memberof custom_commands
* @description Nightwatch command to remove the breadcrumb bar on classic jenkins pages.
* See http://nightwatchjs.org/guide#writing-custom-commands
* <p/>
* The breadcrumb bar in classic Jenkins is sticky positioned at the top
* of the page and can block events getting to elements e.g. selecting
* the job type on the create item page. This command removes it completely
* by injecting some JS into the page.
*/

* */
const util = require('util');
const events = require('events');

Expand Down
33 changes: 30 additions & 3 deletions src/main/js/page_objects/blueocean/bluePipelineRunDetail.js
Expand Up @@ -35,11 +35,11 @@ module.exports = {
circleSuccess: 'svg circle.success',
runningResult: 'span.result-item-icon.running',
firstResult: {
selector: '//div[contains(@class, "result-item") and position()=1]',
selector: '//div[contains(@class, "result-item")]',
locateStrategy: 'xpath',
},
firstErrorResult: {
selector: '//div[contains(@class, "failure") and position()=1]',
selector: '//div[contains(@class, "failure")]',
locateStrategy: 'xpath',
},
}
Expand Down Expand Up @@ -389,6 +389,33 @@ module.exports.commands = [{
validateNotRunningResults: function () {
this.expect.element('@runningResult').to.not.be.present.before(1000);
return this;
}
},
/**
* @description Nightwatch command to test whether log lines are navigable
* @param {Number} [position] - which log line do we want to click
* */
validateLogConsole: function (position) {
const self = this;
const browser = this.api;
const aXpath = '(//table[@class="highlight"]//tr/td/a)[' + position + ']';

// first turn on xpath to get the nodes we want
browser
.useXpath()
.waitForElementVisible(aXpath)
.getAttribute(aXpath, 'href', function (result) {
this.assert.equal(typeof result, "object");
this.assert.equal(result.status, 0);
const value = result.value;
browser
.click(aXpath)
.url(function (response) {
// did we changed the url on change?
this.assert.equal(response.value, result.value);
})
});
browser.useCss();
return self;
}

}];
31 changes: 4 additions & 27 deletions src/test/js/log-karaoke/stages.js
Expand Up @@ -80,37 +80,14 @@ module.exports = {
this.assert.equal('Shell Script', result.value);
})
;
// wait for job to finish
nodeDetail.waitForJobRunEnded(cases[0].name);
// test whether the expand works
nodeDetail.clickFirstResultItem();
// test whether the stage we seeing is highlighted
nodeDetail.waitForElementVisible('g.pipeline-node-selected');
// test whether log lines are navigatable
// first turn on xpath to get the nodes we want
browser.useXpath();
var aXpath = '//code/p/a[1]';
nodeDetail
.waitForElementVisible(aXpath)
.getAttribute(aXpath, 'href', function (result) {
this.assert.equal(typeof result, "object");
this.assert.equal(result.status, 0);
const value = result.value;
this
.click(aXpath)
.url(function (response) {
// did we changed the url on change?
this.assert.equal(response.value, result.value);
// controll whether we can still see the log and the link is still the same
this.waitForElementVisible(aXpath)
.getAttribute(aXpath, 'href', function (inner) {
this.assert.equal(inner.value, result.value);
})
})

});
// turn on css again
browser.useCss();
// wait for job to finish
nodeDetail.waitForJobRunEnded(cases[0].name);
// test whether log lines are navigable
nodeDetail.validateLogConsole(2);
},
/** Check whether there is an EmptyStateView for stages with no steps*/
'Step 05': function (browser) {
Expand Down
@@ -1,7 +1,7 @@
node {
stage ('Stage 1'){
sh 'sleep 3; echo `date` Stage 1;'
sh 'sleep 3; echo `date` Stage 1;'
sh 'sleep 6; echo `date` Stage 1;'
sh 'sleep 6; echo `date` Stage 1;'
}
stage ('Stage 2'){
parallel firstBranch: {
Expand Down
Expand Up @@ -2,8 +2,8 @@ pipeline {
agent label:""
stages {
stage ('Stage 1'){
sh 'sleep 3; echo `date` Stage 1;'
sh 'sleep 3; echo `date` Stage 1;'
sh 'sleep 6; echo `date` Stage 1;'
sh 'sleep 6; echo `date` Stage 1;'
}

stage ('fin'){
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/test_scripts/stages-with-wait.groovy
@@ -1,7 +1,7 @@
node {
stage 'Stage 1'
sh 'sleep 3; echo `date` Stage 1;'
sh 'sleep 3; echo `date` Stage 1;'
sh 'sleep 6; echo `date` Stage 1a we need some time here for slower ath hosts;'
sh 'sleep 6; echo `date` Stage 1b;'
stage 'Stage 2'
parallel firstBranch: {
sh 'echo `date` Stage 2 - first;sleep 3; echo `date` Stage 2 - first;sleep 3; echo `date` Stage 2 - first;'
Expand Down

0 comments on commit 45eb6aa

Please sign in to comment.