tests: Fix race condition in one of the Scan Sbom tests#931
Open
matejnesuta wants to merge 3 commits intoguacsec:mainfrom
Open
tests: Fix race condition in one of the Scan Sbom tests#931matejnesuta wants to merge 3 commits intoguacsec:mainfrom
matejnesuta wants to merge 3 commits intoguacsec:mainfrom
Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefactors the SBOM scan cancellation E2E test to merge spinner verification and cancel action into a single step, and introduces Playwright request routing to delay API calls so the cancel button can be reliably located and clicked, eliminating a race condition-induced flake. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider wrapping the
page.route/page.unroutecalls in atry/finallyblock so the route is always removed even ifexpectProcessingSpinnerorclickCancelProcessingthrows, preventing the handler from leaking into later steps. - Routing
**/api/**with a hard-coded 10s delay is quite broad and slow; you might want to narrow the URL pattern to only the specific SBOM-related request(s) and/or reduce the delay to the minimum needed to reliably click cancel.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider wrapping the `page.route`/`page.unroute` calls in a `try/finally` block so the route is always removed even if `expectProcessingSpinner` or `clickCancelProcessing` throws, preventing the handler from leaking into later steps.
- Routing `**/api/**` with a hard-coded 10s delay is quite broad and slow; you might want to narrow the URL pattern to only the specific SBOM-related request(s) and/or reduce the delay to the minimum needed to reliably click cancel.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #931 +/- ##
==========================================
+ Coverage 64.47% 65.01% +0.53%
==========================================
Files 195 195
Lines 3341 3341
Branches 753 753
==========================================
+ Hits 2154 2172 +18
+ Misses 890 872 -18
Partials 297 297 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes Scan SBOM test, which tests cancelling of the SBOM analysis.
Even though this test passes on the Github CI, it was occasionally failing on my local setup. There is slight chance that the Scan Sbom result page loads faster than Playwright is able to query the locators for aborting the analysis, which causes the test to flake. Given that Trustify on OCP/RHEL should be faster than in the Github CI, I think it is reasonable to expect this flake on downstream builds as well.
This fix merges 2 Gherkin steps together and adds a
page.route()mechanism, which delays any network request on the loading page by 10 seconds, allowing Playwright to properly query theCancel Reportbutton.Summary by Sourcery
Tests: