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

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIX JENKINS-39842] Open Blue Ocean button should not try to load /ac…
…tivity for a folder (#96)

* Test for JENKINS-39842

Clicking on the "Open Blue Ocean" button while in a classic folder that's not a MBP project folder should bring the user to the main top-level blue ocean page i.e. pipelines

* Another test for JENKINS-39842 for @kzantow

Using folder and job/branch names that are not confusing (special chars etc). BTW I'm leaving the original tests that were using weird chars because I think it's good to have tests that challenge the url encoding etc. Sure that can result in the presence of weird chars, but weird chars are a fact of life, so good to test against them.
  • Loading branch information
tfennelly committed Jan 6, 2017
1 parent 838879c commit 1ea16a7
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/main/js/page_objects/classic_jenkins/classicGeneral.js
@@ -0,0 +1,24 @@
/**
* @module classicGeneral
* @memberof page_objects
* @description Represents a page object containing "general" operations
* that can be performed on any Jenkins Classic page.
*/

exports.elements = {
pageBody: '#page-body'
};
exports.commands = [
{
/**
* Navigate to a page.
* @param {string} pageUrl Relative page URL (relative to nightwatch launchUrl).
* @returns {Object} self - nightwatch page object
*/
navigateToRun: function(pageUrl) {
this.navigate(this.api.launchUrl + '/' + pageUrl);
this.waitForElementPresent('@pageBody');
return this;
}
}
];
29 changes: 28 additions & 1 deletion src/test/js/edgeCases/folder.js
Expand Up @@ -12,7 +12,7 @@
* @see {@link https://issues.jenkins-ci.org/browse/JENKINS-36613|JENKINS-36613} Unable to load steps for multibranch pipelines with / in them
* @see {@link https://issues.jenkins-ci.org/browse/JENKINS-36674|JENKINS-36674} Tests are not being reported
* @see {@link https://issues.jenkins-ci.org/browse/JENKINS-36615|JENKINS-36615} the multibranch project has the branch 'feature/1'
*
* @see {@link https://issues.jenkins-ci.org/browse/JENKINS-39842|JENKINS-39842} - Open Blue Ocean button should not try to load /activity for a folder
*
*/
const git = require("../../../main/js/api/git");
Expand Down Expand Up @@ -204,4 +204,31 @@ module.exports = {
blueRunDetailPage.assertBasicLayoutOkay();
});
},
/**
* test open blueocean from classic - a normal folder page in classic jenkins.
* <p>
* It should send the user to the top level blue ocean page (pipelines).
* @param browser
*/
'step 12': function(browser) {
var classicGeneral = browser.page.classicGeneral();

// Go to a folder along the path to the MBP, but one
// of the parent folders i.e. not the MBP project folder.
classicGeneral.navigateToRun('job/anotherFolder/job/三百/job/ñba');

// make sure the open blue ocean button works. In this case,
// it should bring the browser to the main top-level pipelines page.
// See https://issues.jenkins-ci.org/browse/JENKINS-39842
browser.openBlueOcean();
browser.url(function (response) {
sanityCheck(browser, response);
response.value.endsWith('/blue/pipelines');

// Make sure the page has all the bits and bobs
// See JENKINS-40137
const bluePipelines = browser.page.bluePipelines();
bluePipelines.assertBasicLayoutOkay();
});
},
};
107 changes: 107 additions & 0 deletions src/test/js/multibranch/folder.js
@@ -0,0 +1,107 @@
/** @module folder
* @memberof multibranch
* @description
*
* Tests: Tests specific to MBP in folders
*
* REGRESSION covered:
*
* @see {@link https://issues.jenkins-ci.org/browse/JENKINS-39842|JENKINS-39842} - Open Blue Ocean button should not try to load /activity for a folder
*
*/
const git = require("../../../main/js/api/git");
const path = require("path");
const pageHelper = require("../../../main/js/util/pageHelper");
const sanityCheck = pageHelper.sanityCheck;

// base configuration for the path of the folders
const projectFolderPath = ['aFolder', 'bFolder', 'cFolder'];
// our job should be named the same way in both folders
const jobName = 'MBPInFolderTree';
// git repo details
const pathToRepo = path.resolve('./target/test-project-folder');
const soureRep = './src/test/resources/multibranch_1';

module.exports = {
/**
* creating a git repo
*/
before: function (browser, done) {
browser.waitForJobDeleted('aFolder', function () {
// we creating a git repo in target based on the src repo (see above)
git.createRepo(soureRep, pathToRepo)
.then(function () {
git.createBranch('feature/1', pathToRepo)
.then(done);
});
});
},
/**
* Create folder structure - "aFolder/bFolder/cFolder"
*/
'step 01': function (browser) {
// Initial folder create page
const folderCreate = browser.page.folderCreate().navigate();
// create nested folder for the project
folderCreate.createFolders(projectFolderPath);
},
/**
* Create multibranch job - "MBPInFolderTree"
*/
'step 02': function (browser) {
// go to the newItem page
browser.page.jobUtils().newItem();
// and then use the multibranchCreate page object to create
// a multibranch project
browser.page.multibranchCreate().createBranch(jobName, pathToRepo);
},
/**
* test open blueocean from classic - run details
* @param browser
*/
'step 03': function(browser) {
var classicRunPage = browser.page.classicRun();

classicRunPage.navigateToRun('aFolder/job/bFolder/job/cFolder/job/MBPInFolderTree/job/master');

// make sure the open blue ocean button works. In this case,
// it should bring the browser to the run details page for the first run.
browser.openBlueOcean();
browser.url(function (response) {
sanityCheck(browser, response);
response.value.endsWith('/blue/organizations/jenkins/aFolder%2FbFolder%2FcFolder%2FMBPInFolderTree/branches/');

// Make sure the page has all the bits and bobs
// See JENKINS-40137
const blueRunDetailPage = browser.page.bluePipelineRunDetail();
blueRunDetailPage.assertBasicLayoutOkay();
});
},
/**
* test open blueocean from classic - a normal folder page in classic jenkins.
* <p>
* It should send the user to the top level blue ocean page (pipelines).
* @param browser
*/
'step 04': function(browser) {
var classicGeneral = browser.page.classicGeneral();

// Go to a folder along the path to the MBP, but one
// of the parent folders i.e. not the MBP project folder.
classicGeneral.navigateToRun('job/aFolder/job/bFolder');

// make sure the open blue ocean button works. In this case,
// it should bring the browser to the main top-level pipelines page.
// See https://issues.jenkins-ci.org/browse/JENKINS-39842
browser.openBlueOcean();
browser.url(function (response) {
sanityCheck(browser, response);
response.value.endsWith('/blue/pipelines');

// Make sure the page has all the bits and bobs
// See JENKINS-40137
const bluePipelines = browser.page.bluePipelines();
bluePipelines.assertBasicLayoutOkay();
});
},
};

0 comments on commit 1ea16a7

Please sign in to comment.