Stop double insertion of the relative_url_root in test_case attachment URL
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you receive complimentary access to GitLab Duo.
What does this MR do and why?
Stop double insertion of the relative_url_root
When generating the link to an attachment in a test report, the link contains two instances of the relative_url_root.
Remove the call to expose_url on the Test Case entity. This function should only be used as part of API calls, not the Rails links and calls we use this URL for. Add a test and some documentation above the function stating the same.
Use the file_project_job_artifacts_url function to generate the full URL instead of ..._path to find the relative version
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
| Before | After |
|---|---|
|
|
How to set up and validate locally
-
Configure GitLab to host itself with
relative_url_root, i.e./gitlab -
Create repository with
.gitlab-ci.ymlwith a test that uploads a image attachment and a JUnit file in XML form:python22: variables: CI_DEBUG_TRACE: "true" stage: test tags: - docker script: - mkdir build - echo "${SWEET}" - echo "${TEST}" - cd build - sleep 30s artifacts: when: always paths: - screenshots/dashboard.png - junit-complete.xml reports: junit: junit-complete.xmlOne of the tests within the report should fail and it should contain output which indicates that there is an attachment to the test, the uploaded image. The text that I use when testing locally is:
<testcase name="testCase5" classname="Tests.Registration" assertions="2" time="2.902412" file="tests/registration.code" line="202"> <!-- <failure> The test failed because one of the assertions/checks failed. Can have a message and failure type, often the assertion type or class. The text content of the element often includes the failure description or stack trace. --> <failure message="Expected value did not match." type="AssertionError"> </failure> <system-out>[[ATTACHMENT|screenshots/dashboard.png]]</system-out> </testcase> -
Create pipeline in repository and after it completes, navigate to the pipeline page and then the test report screen.
-
Open test report via
Tests, click on theView detailslink for the failing test. -
See that the relative root URL is duplicated in the link to the attachment as in the screenshots in the
Beforecolumn.


