Expose attachment_url to TestCaseEntity
Part of #202114 (closed)
What does this MR do?
Following up !26922 (merged) where we added the ability to parse an attachment attribute on our JUnit XML reports and persists it on a TestCase object.
This MR does 2 things:
- Exposes an
attachment_url
attribute as part of ourTestCaseEntity
behind a feature flagjunit_pipeline_screenshots_view
- Composes the
attachment_url
for a given artifact
We will add filtering for a test case with attachment in a follow up MR.
Why are we adding this?
Today's problem
It's not possible to link a screenshot to a test failure. If a failure happens we need to inspect the job artifacts manually which takes time and it's a hard task for us internally.
Solution
We want to make it simple for the user to display a screenshot associated to a test failure. This way we can show a failing screenshot on a pipeline without browsing all the job artifacts manually.
Check the design for this feature.
Screenshots
Here an example payload of the test_report endpoint this feature will render:
{
"total_time": 0.01634,
"total_count": 1,
"success_count": 0,
"failed_count": 1,
"skipped_count": 0,
"error_count": 0,
"test_suites": [
{
"name": "test",
"total_time": 0.01634,
"total_count": 1,
"success_count": 0,
"failed_count": 1,
"skipped_count": 0,
"error_count": 0,
"test_cases": [
{
"status": "failed",
"name": "the home page return hello world",
"classname": "spec.hello_world_spec",
"execution_time": 0.01634,
"system_output": "Failure/Error: raise\nRuntimeError:\n./spec/hello_world_spec.rb:8:in `block (2 levels) in <top (required)>'",
"stack_trace": null,
"attachment_url": "http://127.0.0.1:3000/root/junit-test-report/-/jobs/845/artifacts/file/tmp/capybara/screenshot_return-hello-world.html"
}
]
}
]
}
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team