Skip to content

refactor(web): reorganize worker-thread test helpers and test fixtures 🚂#15716

Merged
jahorton merged 8 commits into
epic/autocorrectfrom
refactor/web/reorganize-helpers-and-fixtures
Mar 16, 2026
Merged

refactor(web): reorganize worker-thread test helpers and test fixtures 🚂#15716
jahorton merged 8 commits into
epic/autocorrectfrom
refactor/web/reorganize-helpers-and-fixtures

Conversation

@jahorton
Copy link
Copy Markdown
Contributor

Build-bot: skip build:web
Test-bot: skip

@keymanapp-test-bot
Copy link
Copy Markdown

keymanapp-test-bot Bot commented Mar 10, 2026

User Test Results

Test specification and instructions

User tests are not required

Test Artifacts

  • Web
    • KeymanWeb Test Home - build : all tests passed (no artifacts on BuildLevel "build")

@keymanapp-test-bot keymanapp-test-bot Bot changed the title refactor(web): reorganize worker-thread test helpers and test fixtures refactor(web): reorganize worker-thread test helpers and test fixtures 🚂 Mar 10, 2026
@keymanapp-test-bot keymanapp-test-bot Bot added this to the A19S24 milestone Mar 10, 2026
@jahorton jahorton requested a review from ermshiperete March 10, 2026 16:05
@jahorton jahorton marked this pull request as ready for review March 10, 2026 16:05
Comment on lines +6 to +8
* This file defines a unit-text fixture designed for testing
* behaviors related to the clustering of search quotient spurs
* based on just substitution/match edges.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The comment doesn't seem to match the content of the file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Any suggestions for improving this, then? That comment was intended for this file's header comment; it's not a copy-paste artifact.

Copy link
Copy Markdown
Contributor

@ermshiperete ermshiperete Mar 13, 2026

Choose a reason for hiding this comment

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

But this file contains helper methods, not the test fixture. As it is the comment would fit on buildAlphabeticClusterFixture.tests.ts IMO.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, that method is the test fixture - or rather, it constructs it anew on each call. It requires live construction, like the buildCantLinearFixture method.

return node.parents.flatMap((p) => constituentPaths(p));
} else if(node instanceof SearchQuotientSpur) {
const parentPaths = constituentPaths(node.parents[0]);
let pathsToExtend = parentPaths;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From devin.ai:

Unnecessary intermediate variable pathsToExtend in new constituentPaths

The new version introduces let pathsToExtend = parentPaths; then uses pathsToExtend.map(...). Since pathsToExtend is just an alias for parentPaths (same reference, never reassigned before use), this variable serves no purpose. The old code directly used parentPaths. This is not a bug — it's functionally identical — but it's a minor style inconsistency that could be cleaned up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's here in part because a later PR does leverage the variable; such code appears in #15721.

Comment on lines +32 to +36
if(parentPaths.length > 0) {
return pathsToExtend.map(p => {
p.push(node);
return p;
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From devin.ai:

constituentPaths() mutates its returned arrays via push()

The constituentPaths function at web/src/test/auto/headless/engine/predictive-text/helpers/constituentPaths.ts:33-35 uses p.push(node) to mutate the arrays returned from recursive calls. This is a pre-existing pattern (carried over from the old searchQuotientUtils.ts), but it means calling constituentPaths() twice on the same node will produce incorrect results on the second call if the first call's arrays were mutated in-place by a caller. This is visible in constituentPaths.tests.ts:40-42 where the test calls constituentPaths(fixture.clusters.cluster_k3c4).map((p) => { p.push(finalPath); ... }) — this mutates the inner arrays. Since constituentPaths(finalPath) is evaluated first (as the first argument to assert.sameDeepMembers), it works, but it's fragile. The same pattern existed before, so this is not a regression.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Recursive root = new array each time / each call. There is no reference aliasing across multiple calls of the method.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, I think we discussed this before. Didn't remember that, sorry.

@ermshiperete
Copy link
Copy Markdown
Contributor

(note my replies on some of the comments above)

@keyman-server keyman-server modified the milestones: A19S24, A19S25 Mar 14, 2026
@jahorton jahorton merged commit f6d844d into epic/autocorrect Mar 16, 2026
7 of 8 checks passed
@jahorton jahorton deleted the refactor/web/reorganize-helpers-and-fixtures branch March 16, 2026 13:12
@github-project-automation github-project-automation Bot moved this from Todo to Done in Keyman Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants