Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[JENKINS-69658] - CSP compatibility for failed-test.jelly #451

Merged
merged 5 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/main/resources/lib/hudson/test/failed-test.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,10 @@ THE SOFTWARE.
}
</style>
</st:once>
<j:set var="id" value="${h.jsStringEscape(url)}"/>
<j:set var="open" value="showFailureSummary('test-${id}','${url}/summary')"/>
<j:set var="close" value="hideFailureSummary('test-${id}')"/>
<a id="test-${id}-showlink" onclick="${open}" title="${%Show details}">
<a id="test-${id}-showlink" title="${%Show details}">
<l:icon src="symbol-add-outline plugin-ionicons-api" class="icon-sm"/>
</a>
<a id="test-${id}-hidelink" onclick="${close}" title="${%Hide details}" style="display:none">
<a id="test-${id}-hidelink" title="${%Hide details}" style="display:none">
<l:icon src="symbol-remove-outline plugin-ionicons-api" class="icon-sm"/>
</a>
<st:nbsp/>
Expand Down
21 changes: 21 additions & 0 deletions src/main/resources/lib/hudson/test/js/failureSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,24 @@ function hideFailureSummary(id) {
document.getElementById(id + "-showlink").style.display = "";
document.getElementById(id + "-hidelink").style.display = "none";
}


document.addEventListener('DOMContentLoaded', (event) => {

const testShowlinks = document.querySelectorAll("a[id*=-showlink]");
testShowlinks.forEach((element) => {
element.onclick = (_) => {
const testId = element.id.replace('-showlink', '');
showFailureSummary(testId, document.URL + "/summary");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

document.URL is wrong, as it refers to that page we're in. Request has to go to JENKINS_URL/job/fs/5/testReport/<package_name>/<test_name>/summary and not just JENKINS_URL/job/fs/5/testReport/summary
Currently this returns 404:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, can you please complete the Reproduction steps section of the Jira ticket (JENKINS-69658) description ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Artmorse commented in the ticket

Copy link
Contributor Author

@Artmorse Artmorse Oct 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! I was able to do my tests! 😄

}
});

const testHidelinks = document.querySelectorAll("a[id*=-hidelink]");
testHidelinks.forEach((element) => {
element.onclick = (_) => {
const testId = element.id.replace('-hidelink', '');
hideFailureSummary(testId);
}
});

});