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.
[FIX JENKINS-36660] WIP Acceptance tests for nested project and funky…
… branch name regressions (#26) * Added git api for creating local git repos for testing * stash * [JENKINS-36660] WIP implementing creation of folder and a freestyle project within the nested path. * [JENKINS-36660] WIP remove obsolete variable * [JENKINS-36660] WIP waiting for ever when uncommenting, seems that sse is not getting informed * [JENKINS-36660] Add tests for JENKINS-36618 * [JENKINS-36660] Extending multibranch AT implementing creation of job * [JENKINS-36660] Add fixme note so tom knows where the problems lies * [JENKINS-36660] first working version of creating multibranch in folders * [JENKINS-36660] fix class name * [JENKINS-36660] add more test to cover various regressions. The close modal test is breaking my balls though since the opener url is equal to the current location but only in AT. * [JENKINS-36660] Implement regression testing for all tabs when they should show data. Add commit script for the git repo. * [JENKINS-36660] remove legacy folder * [JENKINS-36660] fix renamed methood * [JENKINS-36660] make sure we do not start without wait for finish * [JENKINS-36660] Start test for pressing run button. add test to validate activities. move clickTab and related code to url util class * [JENKINS-36660] Implement check for runButton and start working on queued state * [JENKINS-36660] WIP queued state testing, infrastructure code to set executors * [JENKINS-36660] Implement checks for queued jobs * [JENKINS-36660] using async series to make sure the changeset has passed before doing next step * [JENKINS-36660] make sure we reset the executors * [JENKINS-36660] prepare for merge with current master, Disable tests as long ticket is open,
- Loading branch information
Showing
23 changed files
with
1,126 additions
and
76 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,152 @@ | ||
var NodeGit = require("nodegit"); | ||
var fse = require('fs-extra'); | ||
var path = require("path"); | ||
|
||
exports.init = function (pathToRepo, onInit) { | ||
var pathToRepo = path.resolve(pathToRepo); | ||
|
||
fse.emptyDirSync(pathToRepo); | ||
NodeGit.Repository.init(pathToRepo, 0) | ||
.then(function (repo) { | ||
var signature = NodeGit.Signature.default(repo); | ||
var initIndex; | ||
|
||
repo.refreshIndex() | ||
.then(function (index) { | ||
initIndex = index; | ||
return index.write(); | ||
}) | ||
.then(function (index) { | ||
return initIndex.writeTree(); | ||
}) | ||
.then(function (oid) { | ||
return repo.createCommit("HEAD", signature, signature, 'initial commit', oid, []); | ||
}) | ||
.done(function () { | ||
if (onInit) { | ||
onInit({ | ||
repo: repo, | ||
copyDirToRepo: function (dir) { | ||
var pathToFiles = path.resolve(dir); | ||
|
||
if (!fse.existsSync(pathToFiles)) { | ||
throw new Error('No such directory: ' + pathToFiles); | ||
} | ||
if (!fse.statSync(pathToFiles).isDirectory()) { | ||
throw new Error('Not a directory: ' + pathToFiles); | ||
} | ||
|
||
fse.copySync(pathToFiles, pathToRepo); | ||
}, | ||
commit: function (message) { | ||
if (!message) { | ||
message = 'commit all'; | ||
} | ||
|
||
var index; | ||
var oid; | ||
var returnPromise = repo.refreshIndex() | ||
.then(function (indexResult) { | ||
index = indexResult; | ||
}) | ||
.then(function () { | ||
return index.addAll(); | ||
}) | ||
.then(function () { | ||
return index.write(); | ||
}) | ||
.then(function () { | ||
return index.writeTree(); | ||
}) | ||
.then(function (oidResult) { | ||
oid = oidResult; | ||
return NodeGit.Reference.nameToId(repo, "HEAD"); | ||
}) | ||
.then(function (head) { | ||
return repo.getCommit(head); | ||
}) | ||
.then(function (parent) { | ||
return repo.createCommit("HEAD", signature, signature, message, oid, [parent]); | ||
}); | ||
|
||
return returnPromise; | ||
}, | ||
createRepo: function (fromDir, inDir) { | ||
repo.copyDirToRepo(fromDir); | ||
return repo.commit('Added '); | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
}); | ||
}; | ||
|
||
exports.createRepo = function (fromDir, inDir) { | ||
return new Promise(function (resolve, reject) { | ||
exports.init(inDir, function (repo) { | ||
repo.copyDirToRepo(fromDir); | ||
repo.commit('Copied files from ' + fromDir) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
}); | ||
}; | ||
|
||
exports.createBranch = function (branchName, pathToRepo) { | ||
var pathToRepo = path.resolve(pathToRepo); | ||
|
||
return NodeGit.Repository.open(pathToRepo) | ||
.then(function (repo) { | ||
return repo.getHeadCommit() | ||
.then(function (commit) { | ||
return repo.createBranch( | ||
branchName, | ||
commit, 0, | ||
repo.defaultSignature(), | ||
'Created "' + branchName + '" branch on HEAD'); | ||
}); | ||
}); | ||
}; | ||
|
||
exports.createCommit = function (pathToRepo, files) { | ||
|
||
const signatureAuthor = NodeGit.Signature.now('Iron Thor', 'ironThor@avengers.com'); | ||
var repo, index, oid, remote; | ||
|
||
return NodeGit.Repository.open(pathToRepo) | ||
.then(function (repoResult) { | ||
repo = repoResult; | ||
return repo.refreshIndex(); | ||
}) | ||
.then(function (indexResult) { | ||
index = indexResult; | ||
// this file is in the root of the directory and doesn't need a full path | ||
return files.map(function (fileName) { | ||
console.log('++++Adding file +++', fileName); | ||
index.addByPath(fileName); | ||
}) | ||
}) | ||
.then(function() { | ||
// this will write files to the index | ||
return index.write(); | ||
}) | ||
.then(function() { | ||
return index.writeTree(); | ||
}) | ||
.then(function (oidResult) { | ||
oid = oidResult; | ||
return NodeGit.Reference.nameToId(repo, "HEAD"); | ||
}) | ||
.then(function (head) { | ||
return repo.getCommit(head); | ||
}) | ||
.then(function (parent) { | ||
return repo.createCommit("HEAD", signatureAuthor, signatureAuthor, 'testing commit tab', oid, [parent]); | ||
}) | ||
.done(function (commitId) { | ||
console.log("New Commit: ", commitId); | ||
return commitId; | ||
}); | ||
|
||
}; |
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,30 @@ | ||
var url = require('../../util/url'); | ||
|
||
module.exports = { | ||
elements: { | ||
runButton: 'div.actions div.run-pipeline', | ||
toasts: 'div.toaster div.toast span.text' | ||
} | ||
}; | ||
|
||
// Nightwatch commands. | ||
// http://nightwatchjs.org/guide#writing-commands | ||
module.exports.commands = [{ | ||
clickRunButton: function (browser) { | ||
var self = this; | ||
self.waitForElementVisible('@runButton'); | ||
self.click('@runButton'); | ||
browser.elements('css selector', 'div.toaster div.toast span.text', function (codeCollection) { | ||
this.assert.equal(codeCollection.value.length, 2); | ||
codeCollection.value.map(function (item) { | ||
browser.elementIdText(item.ELEMENT, function (value) { | ||
var passed = value.value.indexOf('Queued'); | ||
if (passed === -1) { | ||
passed = value.value.indexOf('Started'); | ||
} | ||
self.assert.equal(passed > -1, true); | ||
}) | ||
}) | ||
}); | ||
} | ||
}]; |
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
Oops, something went wrong.