Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Test results summary: fix JavaScript console error when 'showLink' HTML element is missing #514

Merged
merged 1 commit into from
May 10, 2023
Merged

Test results summary: fix JavaScript console error when 'showLink' HTML element is missing #514

merged 1 commit into from
May 10, 2023

Conversation

jayaddison
Copy link
Contributor

@jayaddison jayaddison commented Apr 12, 2023

The showLink HTML anchor element is only rendered server-side when fewer tests are displayed on the page than exist in the job result.

So if the job passes (zero failures displayed, zero failures exist), or if there are up to ten failures (up-to-ten failures displayed, up-to-ten failures exist), then the showLink HTML element won't be present on the page.

The associated show-failures.js adjunct code attempts to add an onclick event handler to a showLink-ID'd element on the page after the HTML DOM loads:

const showFailuresLink = document.getElementById("showLink");
showFailuresLink.onclick = (_) => showFailures();

This results in an error appearing in the browser's JavaScript console when the showLink element is not present in the HTML.

The fix suggested here is to only include the relevant JavaScript adjunct when the link itself is also placed on the page.

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue
    • Not done, however I have reproduced and confirmed the issue locally
      • Checked that the error occurred before the fix was applied
      • Checked that the error is resolved after the fix is applied

Related issues

Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

Seems reasonable, thanks!

I assume you manually tested this?

@jayaddison
Copy link
Contributor Author

You're welcome - and yep, tested manually locally with a sample JUnit XML report.

@timja timja enabled auto-merge (squash) April 12, 2023 12:06
@timja timja closed this Apr 23, 2023
auto-merge was automatically disabled April 23, 2023 06:59

Pull request was closed

@timja timja reopened this Apr 23, 2023
@timja
Copy link
Member

timja commented Apr 23, 2023

(Triggering build)

@timja timja merged commit 79a9867 into jenkinsci:master May 10, 2023
@jayaddison jayaddison deleted the issue-480/test-pass-js-console-error branch May 10, 2023 21:05
@jglick
Copy link
Member

jglick commented May 10, 2023

@timja this apparently produced a release (jenkinsci/bom#2059) but it is not in Releases?

@timja
Copy link
Member

timja commented May 11, 2023

Hmm jenkinsci/bom#2058 jenkinsci/workflow-api-plugin/releases githubstatus.com/incidents/pr3498h3qkfy I guess.

Yeah

https://github.com/jenkinsci/junit-plugin/actions/runs/4941356327/jobs/8833887199

  • gh api -F tag=1202.v79a_986785076 -F message=1202.v79a_986785076 -F object=79a986785076d8abd07e686de315faa77fdb4047 -F type=commit /repos/jenkinsci/junit-plugin/git/tags
    unexpected end of JSON input

Manually created now: https://github.com/jenkinsci/junit-plugin/releases/tag/1202.v79a_986785076next

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants