Skip to content

Instantly share code, notes, and snippets.

@patocallaghan
Last active February 25, 2019 17:16
Show Gist options
  • Save patocallaghan/fb83fb31991fa7bf350e0f53ffdd9098 to your computer and use it in GitHub Desktop.
Save patocallaghan/fb83fb31991fa7bf350e0f53ffdd9098 to your computer and use it in GitHub Desktop.
function checkTestsOpen() {
if (attempts > 50) { return; }
openedJobs = document.querySelectorAll('.build-details-pipeline-job-state-failed.build-details-pipeline-job-expanded');
if (openedJobs.length === failedJobs) {
getFailedTests();
getTimedOutJobs();
} else {
setTimeout(checkTestsOpen, 200);
}
}
function getTimedOutJobs() {
let timedOutJobs = document.querySelectorAll('.build-details-pipeline-job-state-timed_out');
if (timedOutJobs.length > 0) {
let buckets = new Set();
timedOutJobs.forEach(job => {
buckets.add(job.querySelector('.build-details-pipeline-job-name').textContent);
});
let timedOutText = document.createElement('p');
timedOutText.textContent = `Timed-out Buckets: ${buckets.size}`;
document.querySelector('.job-list-pipeline').prepend(timedOutText);
timedOutText.scrollIntoView();
}
}
function getFailedTests() {
failedTests = new Set();
document.querySelectorAll('.JobLogOutputComponent__Line__Content').forEach(line => {
trimmedLine = line.textContent.trim();
if (/^not ok/.test(trimmedLine)) {
failedTests.add(trimmedLine);
}
});
container = document.querySelector('.job-list-pipeline')
el = document.createElement('ul');
total = document.createElement('li');
total.textContent = `${failedTests.size} failing tests`;
el.append(total);
failedTests.forEach(test => {
failure = document.createElement('li');
failure.textContent = test;
el.append(failure);
});
container.prepend(el);
el.scrollIntoView();
}
failedJobs = document.querySelectorAll('.build-details-pipeline-job-state-failed').length;
document.querySelectorAll('.build-details-pipeline-job-state-failed').forEach(item => {
if (!item.classList.contains('build-details-pipeline-job-expanded')) {
item.querySelector('.items-center').click();
}
});
attempts = 0
setTimeout(checkTestsOpen, 200);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment