fix(ui): remove stale task nodes when a file is re-collected#10677
Open
eldardada wants to merge 1 commit into
Open
fix(ui): remove stale task nodes when a file is re-collected#10677eldardada wants to merge 1 commit into
eldardada wants to merge 1 commit into
Conversation
Author
|
The two red jobs look unrelated to this change.
This PR only touches the UI explorer tree under |
Removing or commenting out a test re-collects the file with fewer tasks, but the sidebar tree only ever added or updated nodes and never dropped the ones that disappeared. The orphaned entry stayed in the explorer, often still showing red, until a full page reload. Reconcile the collected tasks against the tracked children whenever a file or suite subtree is rebuilt, removing any node and its descendants that is no longer present. Fixes vitest-dev#10670
83fe826 to
b631c60
Compare
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.
Description
When a test is removed or commented out, the file is re-collected with fewer tasks. The sidebar tree only ever added or updated nodes while collecting; it never dropped the ones that were gone, so the orphaned entry stayed in the explorer (often still showing red) until a full page reload. Re-running all tests does not help, because the rerun goes through the same collect path. This matches the report in #10670.
createOrUpdateFileNode(whencollectis set) andcreateOrUpdateNode(whencreateAllis set) rebuild a file or suite subtree from the collected tasks, but they only walked the incoming list, so any tracked child missing from it was left behind. This change reconciles the tracked children against the collected tasks after each subtree rebuild and removes any node, along with its descendants, that no longer exists.The summary counts were already correct because they come from the live task tree rather than the UI nodes, which is why the console showed the right totals while the sidebar did not.
Resolves #10670
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Added
packages/ui/client/composables/explorer/tree.spec.ts. It collects a file containing a suite, re-collects it after a test is deleted, and checks that the orphaned node is dropped, that a removed suite takes its children with it, and that untouched and newly added tasks stay. The two removal cases fail onmainand pass with this change.I went with a unit test rather than a browser e2e because the report is intermittent ("sometimes remains"), so an e2e around the watch rerun would be timing-dependent, while the reconciliation itself is deterministic.
Documentation
Changesets