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

Better fuzz testing for PDF generation #2965

Merged
merged 3 commits into from
Feb 5, 2025
Merged

Conversation

bjosttveit
Copy link
Member

@bjosttveit bjosttveit commented Feb 4, 2025

Description

This is a follow-up of #2958, the changes here makes the test I added in the previous PR redundant as this makes random failure much more likely if the #readyForPrint logic is insufficient. Even though I could safely remove that test here, it's important to keep in mind that everything is not covered automatically now. For example, the changeName test with the map component will probably not fail for any other reason than the map since the tiles almost always load last and gives a lot of time for other things to load while waiting on those.

Changes:

  • Added (optional) response fuzzing while loading the PDF layout. This delays all requests by a different random amount. If tests suddenly become flaky, that could be a sign that PDFs don't always load completely.
    • You cannot really remove a cy.intercept() after its been added, so the workaround is to check a variable if it has been disabled or not. This is only really relevant if you continue the test after running testPdf()
  • Disable browsers memory cache while loading the PDF layout
    • The real PDF generator always runs a fresh browser instance and therefore has nothing cached, additionally, cached requests cannot be intercepted and delayed. This mostly affects fonts, stylesheets etc, as most of our API requests are not cached anyways.
  • Calling cy.clock() immediately after #readyForPrint is visible. This will effectively pause all timers, which in many cases pauses things from updating in the UI which can make the snapshots a little more likely to fail if something is not quite ready. It is by no means a guarantee.
  • Extracted some things into custom cypress commands for readability and using more aliases for storing variables since that is the "proper" way of doing that.
  • Removed the specific options loading test as the first testPdf call in the changeName test now fails if options don't load in time.

Related Issue(s)

@bjosttveit bjosttveit added the kind/other Pull requests containing chores/repo structure/other changes label Feb 4, 2025
test/e2e/integration/frontend-test/pdf.ts Show resolved Hide resolved
test/e2e/support/custom.ts Outdated Show resolved Hide resolved
@bjosttveit bjosttveit merged commit 784baaa into main Feb 5, 2025
12 checks passed
@bjosttveit bjosttveit deleted the improve-pdf-testing branch February 5, 2025 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/other Pull requests containing chores/repo structure/other changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants