Skip to content

DR-3790: Fix timeouts on homepage localhost tests#465

Merged
jbdalton merged 6 commits into
qafrom
DR-3790/timing-homepage-localhost-tests
Sep 19, 2025
Merged

DR-3790: Fix timeouts on homepage localhost tests#465
jbdalton merged 6 commits into
qafrom
DR-3790/timing-homepage-localhost-tests

Conversation

@jbdalton

@jbdalton jbdalton commented Sep 18, 2025

Copy link
Copy Markdown
Member

Ticket:

This PR does the following:

I've added a few things, after trying several alternatives, to try to address some of the continuing timeout issues, especially for the DC homepage tests.

The two main changes I've made are:

  • added route-filters on 3rd-party calls (New Relic, adobe, google, etc.) that normally wouldn't be running on dev testing
  • changed wait-until to "load"

This builds on the improvements made recently that allow us to run our playwright tests on localhost against production builds for better performance and stability during testing.

Open questions

When this is run in CI, I assume that New Relic, google, adobe etc. are not being called against the prod site. Or maybe this is a minimal overhead in that case. I found removing it from localhost calls against the prod build keeps it from being part of our analytics and runs faster, at least when the waitUntil-load method is used on the page.

How has this been tested? How should a reviewer test this?

I found that currently, while homepage.spec.ts would sometimes run without failing, if it were run a few times -- or especially if run within the entire suite, we could replicate failures. These were usually on the "verify feedback form" scenario in the homepage test.

I compared several different configurations until I found a combination that seems to be 0% flakey, at least during my testing. Specifically I've found that the visual overlay that uses IIIF's "main-feature" splash image is loaded twice (a 900 px and 1600 px version) to produce the main visual element on the home page. And whenever it fails (especially on localhost/dev, but even when run against a prod build) the feedback-form tests also fail. Overall, this is about 10-20% of the time. My theory is it's bottlenecking other assertions that Playwright might be waiting for on the "verify feedback form" functionality, which does happen to appear at the bottom of a DC homepage-load. Even after changing to { waitUntil: "domcontentloaded" } I found that the feedback-form test, no matter how large the timeout, would still sometimes fail.

My goal was to find some combination that would run quickly, at least 7 times in a row, without a homepage.spec.ts fail, both as part of the entire test suite and when run individually.

The results of my testing look like this (if something failed over 30% of the time, I stopped before 7 tries). "Timeout" here refers to the timeout set in the specific feedback scenario via the "test" and "page" set methods. Default.jpg is the visual overlay from IIIF. There is a route-filter on it, as well as the 3rd-party calls.

Running suite:

pass/fail timeout default.jpg page-load-wait avg-total
7/0 30000 filter-out "load" 35-41s
1/3 30000 filter-out "domcontentloaded"
1/3 60000 (test.set) filter-out "domcontentloaded"
0/2 60000 (page.set) filter-out "domcontentloaded"

Single test only: homepage.spec.ts

pass/fail feedback-timeout default.jpg page-load-wait avg-test-time
1/2 60000 (test.set) filter "domcontentloaded" 9.1s
7/0 30000 filter "load" 10.6s

Accessibility concerns or updates

Checklist:

  • I have added relevant accessibility documentation for this pull request.
  • All new and existing tests passed.
  • I have updated the CHANGELOG.md.

@vercel

vercel Bot commented Sep 18, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
digital-collections Ready Ready Preview Comment Sep 19, 2025 8:12pm

@samanthaandrews samanthaandrews left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One small change; otherwise this looks good. Once the change is made, you can re-request review from me so I'm notified to look at the PR again.

Comment thread playwright/tests/homepage.spec.ts Outdated
await page.route("**/default.jpg", (route) => route.abort());

// Navigate to the page after setting up the routing rules.
await page.goto("/", { waitUntil: "load" });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The default behavior for Playwright's .goto() method is waitUntil: "load", so this option can be removed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

removed the explicit "load"

Comment on lines +6 to +13
await page.route(/.*googletagmanager\.com.*/, (route) => route.abort());
await page.route(/.*demdex\.net.*/, (route) => route.abort());
await page.route(/.*adobedtm\.com.*/, (route) => route.abort());
await page.route(/.*everesttech\.net.*/, (route) => route.abort());
await page.route(/.*ipify\.org.*/, (route) => route.abort());
await page.route(/.*google\.com.*/, (route) => route.abort());
await page.route(/.*omappapi\.com.*/, (route) => route.abort());
await page.route(/.*google-analytics\.com.*/, (route) => route.abort());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nice! if we find this helpful on the homepage, we could make a change to abort these calls for all tests on all pages using a global setup file. definitely doesn't need to happen on this PR.

@Toxiapo

Toxiapo commented Sep 19, 2025

Copy link
Copy Markdown
Collaborator

Not sure if this will be helpful, but when I try to debug local versus virtual environment tests, I try to match the configurations as closely as possible. For instance, I noticed that the worker settings run with 2 workers in GH but 0 locally (which, I believe, will turns off parallelism). To make the environments more consistent, I would set a constant number of workers locally to match the GH setup.

@samanthaandrews

Copy link
Copy Markdown
Collaborator

Not sure if this will be helpful, but when I try to debug local versus virtual environment tests, I try to match the configurations as closely as possible. For instance, I noticed that the worker settings run with 2 workers in GH but 0 locally (which, I believe, will turns off parallelism). To make the environments more consistent, I would set a constant number of workers locally to match the GH setup.

This is good insight. I think our config currently is set to use 2 workers on GH Actions and "undefined" in local testing. In this context "undefined" actually means "use the max number of workers" which is pretty confusing. For me has been defaulting to 4. I think due to GH Actions concurrency limitations, 2 is what Playwright recommends because if you default to undefined in CI, then GH might default to only 1 which is less ideal.

@samanthaandrews samanthaandrews changed the title Dr 3790/timing homepage localhost tests DR-3790: Fix timeouts on homepage localhost tests Sep 19, 2025
@jbdalton

Copy link
Copy Markdown
Member Author

Yes, on my machine the undefined seems to default to 6 workers.

@jbdalton

Copy link
Copy Markdown
Member Author

I see at the top of the changelog an unreleased entry for "Fix Playwright test timeouts." Should I be adding another entry for this specific merge, like "DR-3790-Fix timeouts ...." or does that previous entry cover it?

@jbdalton jbdalton merged commit 5942cd1 into qa Sep 19, 2025
5 checks passed
@jbdalton jbdalton deleted the DR-3790/timing-homepage-localhost-tests branch September 19, 2025 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants