Repository navigation
fix(playwright): rebuild describe-scope state in beforeAll - #33216
chirag-madlani wants to merge 0 commit into
Conversation
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
| if ( | ||
| node.type === 'CallExpression' && | ||
| node.callee.type === 'MemberExpression' && | ||
| !node.callee.computed && | ||
| node.callee.object.type === 'Identifier' && | ||
| node.callee.property.type === 'Identifier' && | ||
| node.callee.property.name === 'splice' && | ||
| isZero(node.arguments[0]) | ||
| ) { | ||
| return node.callee.object.name; | ||
| } |
There was a problem hiding this comment.
💡 Edge Case: splice(0, n) treated as full reset regardless of n
resetTarget only checks that splice's first argument is 0, so xs.splice(0, 5) — which removes just five elements and leaves the rest — is accepted as a complete reset and a following push is not flagged. This is a false negative that contradicts the comment's stated intent ("anything that only partially clears ... is deliberately not a reset"). To match that intent, treat splice as a reset only when the second argument is absent or is entities.length, and flag splice(0, <literal>) like splice(1).
Was this helpful? React with 👍 / 👎
| const projected = (await ( | ||
| await page.request.get(exploreUrl) | ||
| ).json()) as GraphData; | ||
|
|
||
| return projected.edges.length; |
There was a problem hiding this comment.
Projection poll omits authentication
This spec loads the admin storage state, but page.request.get(exploreUrl) does not inherit the application's bearer header from local storage. The authenticated RDF endpoint therefore returns an error response rather than GraphData, and projected.edges.length fails before the rendering assertions run. Use the authenticated context returned by getApiContext(page) and dispose it afterward, or explicitly preserve the original request's authorization.
| const hookBodyOf = (node) => { | ||
| const [callback] = node.arguments; | ||
|
|
||
| return callback && | ||
| (callback.type === 'ArrowFunctionExpression' || | ||
| callback.type === 'FunctionExpression') | ||
| ? callback | ||
| : undefined; |
There was a problem hiding this comment.
Titled hooks bypass enforcement
hookBodyOf only examines the first argument, so test.beforeAll('setup', async () => { entities.push(entity); }) receives no diagnostic. Named hooks are already common in this suite, leaving that existing setup pattern outside the new enforcement. Select the callback for both supported overloads and add an invalid RuleTester case with a title.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| node.callee.property.name === 'splice' && | ||
| isZero(node.arguments[0]) | ||
| ) { | ||
| return node.callee.object.name; |
There was a problem hiding this comment.
Partial splices count as resets
The check ignores deleteCount, so entities.splice(0, 0) and entities.splice(0, 1) both suppress diagnostics for later pushes despite retaining old entries. This leaves partial clears undetected even though the rule explicitly intends to reject them. Restrict accepted splice resets to forms that remove the entire array, and add invalid cases for zero and partial delete counts.
| if (target !== undefined && !resetsBefore.has(target)) { | ||
| resetsBefore.set(target, node.range[0]); | ||
| } |
There was a problem hiding this comment.
Unexecuted resets suppress diagnostics
The traversal records resets by variable name and source position, even inside conditional branches or uncalled nested functions. For example, if (condition) { entities = []; } before entities.push(entity) suppresses the diagnostic when the condition is false. A reset of a shadowed local can also suppress a push into the outer array. Only count resets that execute before the push for the same binding, and add cases covering these paths.
Code Review 👍 Approved with suggestions 1 closed / 2 findings🟡 Medium risk · Rebuilds Playwright test fixtures and adds an error-level lint rule. Fixes the 💡 Edge Case: splice(0, n) treated as full reset regardless of n📄 openmetadata-ui/src/main/resources/ui/playwright/eslint-rules/no-accumulating-before-all.mjs:95-105 resetTarget only checks that splice's first argument is 0, so ✅ 1 closed✅ Edge Case: Rule flags arrays reset via
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
Stack 1 of 4. Targets
main.The problem
beforeAllis not a per-worker hook. UnderfullyParallelPlaywright runs it once per group of a file's tests dispatched to a worker, so one worker can runbeforeAll → tests → afterAll → beforeAll → tests. An array the hookpushes into still holds entities the interveningafterAllhard-deleted, and a later read resolves to an FQN the backend no longer has. The page renders"<Entity> instance for <fqn> not found"and the next interaction waits out the whole test timeout.This is not a timing race — it is deterministic whenever the group split lands in the wrong place, which is why it presents as a flake.
Traced on
TasksUIFlow.spec.tsacross three merge_group runs (before that spec was rewritten on main), where worker 1 ran:The
error-contextsnapshot ended with... not foundin every sampled failure.The change
Rebuild the state at the top of the hook instead of appending, in the eight specs that still have the shape, and add
om-playwright/no-accumulating-before-allaterrorso it cannot come back.The rule finds exactly these 24 instances on
main. All are fixed here rather than snapshotted —eslint-suppressions.jsonis byte-identical tomain.Verification
yarn lint:playwright: 0 errorsyarn test:eslint-rules: 126 pass (10 new RuleTester cases)tsc: 165 vsmain's 168🤖 Generated with Claude Code
The PR appears safe to merge, with three previously reported non-blocking lint-enforcement gaps remaining.
Findings
Summary
Resets describe-scoped arrays at the start of
beforeAllin eight Playwright specs, preventing subsequent setup runs from retaining entities deleted during teardown.om-playwright/no-accumulating-before-allat error severity.Reviews (15) · Last reviewed commit: "fix(playwright): treat length = 0 and sp..."