This repository has been archived by the owner on Jan 4, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug/jenkins 40662 run details close problem (#93)
* [JENKINS-40662] custom nightwatch command to watch for location changes, to avoid brittle use of pause * [JENKINS-40662] add a test case for when user is deep-linked to run details in the URL form of :org/:pipeline/:branch/:runId and the modal doesn't close properly * [JENKINS-40662] makes more sense to pause for location change any time the modal is closed as this will ensure downstream actions occur after the navigation is completed * [JENKINS-40662] docs link * [JENKINS-40662] avoid flakiness by waiting for job to finish
- Loading branch information
1 parent
039f54b
commit 6d1b816
Showing
4 changed files
with
108 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* @module waitForLocationChange | ||
* @memberof custom_commands | ||
*/ | ||
const util = require('util'); | ||
const events = require('events'); | ||
|
||
function Cmd() { | ||
events.EventEmitter.call(this); | ||
} | ||
util.inherits(Cmd, events.EventEmitter); | ||
|
||
var POLLING_FREQUENCY = 100; | ||
var TIMEOUT = 5000; | ||
|
||
/** | ||
* @description Nightwatch command to wait for the browser's href to change. | ||
* Polls the browser at a given frequency to wait for any change to location.href | ||
*/ | ||
const waitForLocationChange = function () { | ||
var self = this; | ||
// var startTime = new Date().getTime(); | ||
var locationPollingTimeout = null; | ||
|
||
self.api.url(function(response) { | ||
var initialHref = response.value; | ||
|
||
var checkForUrlChange = function() { | ||
self.api.url(function (response) { | ||
if (response.value !== initialHref) { | ||
// var ellapsed = new Date().getTime() - startTime; | ||
// console.log('url changed from: ' + initialHref + ' to: ' + response.value + 'after ' + ellapsed + ' milliseconds.'); | ||
cleanUp(); | ||
self.emit('complete'); | ||
} | ||
else { | ||
locationPollingTimeout = setTimeout(checkForUrlChange, POLLING_FREQUENCY); | ||
} | ||
}); | ||
}; | ||
|
||
var errorTimeout = setTimeout(function() { | ||
cleanUp(); | ||
var error = new Error('timed out waiting for location change'); | ||
self.emit('error', error); | ||
}, TIMEOUT); | ||
|
||
var cleanUp = function() { | ||
clearTimeout(locationPollingTimeout); | ||
clearTimeout(errorTimeout); | ||
}; | ||
|
||
checkForUrlChange(); | ||
}); | ||
|
||
return this; | ||
}; | ||
|
||
Cmd.prototype.command = waitForLocationChange; | ||
module.exports = Cmd; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @module runDetailsDeepLink | ||
* @memberof edgeCases | ||
* @description | ||
* | ||
* Tests: test whether navigating to Run Details without specifying a tab allows the close button to work correctly. | ||
* | ||
* REGRESSION covered: | ||
* | ||
* @see {@link https://issues.jenkins-ci.org/browse/JENKINS-40662|JENKINS-40662} Deep-linking to Run Details | ||
* screen with no tab specified causes problem when closing modal | ||
*/ | ||
const jobName = 'runDetailsDeepLink'; | ||
module.exports = { | ||
/** Create Pipeline Job "runDetailsDeepLink" */ | ||
'Step 01': function (browser) { | ||
const pipelinesCreate = browser.page.pipelineCreate().navigate(); | ||
pipelinesCreate.createPipeline(jobName, 'initialStage.groovy'); | ||
}, | ||
/** Build Pipeline Job*/ | ||
'Step 02': function (browser) { | ||
const pipelinePage = browser.page.jobUtils().forJob(jobName); | ||
pipelinePage.buildStarted(function () { | ||
// Reload the job page and check that there was a build done. | ||
pipelinePage | ||
.waitForElementVisible('div#pipeline-box') | ||
.forRun(1) | ||
.waitForElementVisible('@executer'); | ||
}); | ||
}, | ||
/** Check Job Blue Ocean Pipeline Activity Page has run */ | ||
'Step 03': function (browser) { | ||
const blueActivityPage = browser.page.bluePipelineActivity().forJob(jobName, 'jenkins'); | ||
blueActivityPage.waitForRunRunningVisible(jobName + '-1'); | ||
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun(jobName, 'jenkins', 1); | ||
blueRunDetailPage.waitForJobRunEnded(jobName); | ||
blueRunDetailPage.closeModal('/activity'); | ||
}, | ||
}; |