Fix E2E test quality issues: always-passing assertions, unawaited checks, and dead code#32801
Conversation
…cks, and dead code Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
florianduros
left a comment
There was a problem hiding this comment.
Hi, thanks for the fixes!
| const initialProgress = parseFloat(await progressBar.getAttribute("value")); | ||
| const initialMax = parseFloat(await progressBar.getAttribute("max")); | ||
| expect(initialMax).toBeGreaterThan(4000); | ||
| expect(initialProgress).toBeGreaterThanOrEqual(0); |
There was a problem hiding this comment.
I'm failing to follow why you're removing this. Asserting that the progress is not negative seems useful to me?
There was a problem hiding this comment.
Good point. My original reasoning was that NaN <= 500 evaluates to false, so toBeLessThanOrEqual(500) already catches the parseFloat() returning NaN case. But you're right that it doesn't guard against negative values — >= 0 is not redundant for that. Restored.
| await expect(locator.locator(".mx_EventTile").first().getByText("Hello Mr. Bot")).toBeVisible(); | ||
| await expect(locator.locator(".mx_EventTile").last().getByText("Hello Mr. User")).toBeVisible(); |
There was a problem hiding this comment.
not that I object to this change, but it seems a bit odd to change this but leave the instance of toBeAttached at line 444 unchanged.
There was a problem hiding this comment.
Good catch, missed that one. Fixed to match the rest.
Fix five E2E test quality issues across four spec files.
These issues were found using e2e-reviewer, a static analysis skill for Playwright/Cypress E2E tests that detects common anti-patterns.
crypto/migration.spec.ts— Remove vacuoustoBeGreaterThanOrEqual(0)toBeGreaterThanOrEqual(0)can never fail for a progress bar value. The adjacenttoBeLessThanOrEqual(500)already bounds the valid range — and sinceNaN <= 500evaluates tofalse, it also catches theparseFloat()returningNaNcase. The>= 0check is entirely redundant.devtools/devtools.spec.ts/crypto/utils.ts— Fix unawaitedisVisible()callsisVisible()returns aPromise<boolean>without retrying or throwing. Withoutawait, the expression resolves to aPromiseobject (always truthy), making the check a silent no-op. Playwright docs state: "Returns whether the element is visible. The method returns immediately (does not wait)" — web-first assertions liketoBeVisible()retry automatically and throw on failure, which is the correct behaviour here.spotlight/spotlight.spec.ts— Remove 1-hourwaitForTimeoutfrom a skipped testThis line is inside a
test.skip()block (the test requires federation which is unavailable in local e2e runs), so it never executes in CI. It was introduced in the original Playwright migration (matrix-react-sdk#12033, commitd1562bef, 2023-12-18) and appears to be a debugging artifact: a 1-hour pause so the developer could inspect browser state, left in before committing.A possible alternative reading is that it was intentional — to make CI hang obviously if someone removes
test.skip()prematurely. Either way, the// TODOcomment directly above the test already communicates the intent clearly. A 1-hour hang is a poor signal; an explicitthrow new Error("Requires federation — do not remove test.skip")would be clearer if a guard is desired.threads/threads.spec.ts— ReplacetoBeAttached()withtoBeVisible()The test verifies that thread messages are rendered after opening a thread.
toBeAttached()only checks DOM presence — an element hidden withdisplay:noneorvisibility:hiddenwould still pass.toBeVisible()is the correct assertion here.Checklist
public/exportedsymbols have accurate TSDoc documentation.Notes: none