Skip to content

fix(web): add unit tests for DeadkeyTracker and fix a few bugs#15113

Merged
ermshiperete merged 5 commits intomasterfrom
fix/web/deadkeys
Nov 10, 2025
Merged

fix(web): add unit tests for DeadkeyTracker and fix a few bugs#15113
ermshiperete merged 5 commits intomasterfrom
fix/web/deadkeys

Conversation

@ermshiperete
Copy link
Copy Markdown
Contributor

@ermshiperete ermshiperete commented Nov 7, 2025

While working on the connection between web's TextStore (OutputTarget) and core's context I tried to understand what the Deadkey and DeadkeyTracker classes are doing. This lead me to add some unit tests and that showed that there were a few bugs in those classes. This PR fixes these:

  • initialize Deadkey.matched in c'tor
  • fix Deadkey.equal method
  • verify deadkey exists before removing it in DeadkeyTracker.remove
  • add unit tests for DeadkeyTracker

Test-bot: skip

- initialize `Deadkey.matched` in c'tor
- fix `Deadkey.equal` method
- verify deadkey exists before removing it in `DeadkeyTracker.remove`
- add unit tests for DeadkeyTracker

Test-bot: skip
@keymanapp-test-bot
Copy link
Copy Markdown

keymanapp-test-bot bot commented Nov 7, 2025

User Test Results

Test specification and instructions

User tests are not required

Test Artifacts

  • Android
    • Keyman for Android apk - build : all tests passed (no artifacts on BuildLevel "build")
    • FirstVoices Keyboards for Android apk - build : all tests passed (no artifacts on BuildLevel "build")
    • FirstVoices Keyboards for Android apk (old PRs) - build : all tests passed (no artifacts on BuildLevel "build")
    • KeyboardHarness apk - build : all tests passed (no artifacts on BuildLevel "build")
    • Keyman for Android apk (old PRs) - build : all tests passed (no artifacts on BuildLevel "build")
    • KMSample1 apk - build : all tests passed (no artifacts on BuildLevel "build")
    • KMSample2 apk - build : all tests passed (no artifacts on BuildLevel "build")
  • Developer
    • Keyman Developer - build : all tests passed (no artifacts on BuildLevel "build")
    • Compiler Regression Tests - build : all tests passed (no artifacts on BuildLevel "build")
    • Keyman Developer (old PRs) - build : all tests passed (no artifacts on BuildLevel "build")
    • kmcomp.zip - build : all tests passed (no artifacts on BuildLevel "build")
    • kmcomp.zip (old PRs) - build : all tests passed (no artifacts on BuildLevel "build")
  • iOS
    • Keyman for iOS (simulator image) - build : all tests passed (no artifacts on BuildLevel "build")
    • FirstVoices Keyboards for iOS (simulator image) - build : all tests passed (no artifacts on BuildLevel "build")
    • FirstVoices Keyboards for iOS (simulator image) (old PRs) - build : all tests passed (no artifacts on BuildLevel "build")
    • Keyman for iOS (simulator image) (old PRs) - build : all tests passed (no artifacts on BuildLevel "build")
  • Keyboards
    • Test Keyboards - build : all tests passed (no artifacts on BuildLevel "build")
  • Web
    • KeymanWeb Test Home - build : all tests passed (no artifacts on BuildLevel "build")

@keymanapp-test-bot keymanapp-test-bot bot added this to the A19S15 milestone Nov 7, 2025
Comment on lines +232 to +233
// REVIEW: this behavior seems odd
assert.isFalse(tracker.isMatch(0, 3, 1));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

?

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.

The first parameter of isMatch is the current cursor position, the second parameter the expected offset of the deadkey from the cursor. So if I have a deadkey at position 3 and the current caret at position 0, I'd expect isMatch(0, 3,...) to return true.

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.

...unless the second parameter is the offset we have to add to the deadkey position to get to the cursor position!?

const otherDks = other.dks;
const matchedDks: Deadkey[] = [];

for(const dk of this.dks) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

With this, will it fail if we have something two trackers looking like this?

  this == [ (0,0,0), (0,0,0), (1,2,3) ]
  other == [ (0,0,0), (1,2,3), (4,5,6) ]

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.

yep. Added additional tests.

Comment on lines +246 to +247
// REVIEW: this behavior seems odd
assert.isTrue(tracker.isMatch(0, -3, 1));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

?

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.

See above.

@ermshiperete ermshiperete requested a review from mcdurdin November 7, 2025 12:23
@keyman-server keyman-server modified the milestones: A19S15, A19S16 Nov 8, 2025
Co-authored-by: Marc Durdin <marc@durdin.net>
@ermshiperete ermshiperete merged commit eff0d07 into master Nov 10, 2025
16 checks passed
@ermshiperete ermshiperete deleted the fix/web/deadkeys branch November 10, 2025 11:30
@github-project-automation github-project-automation bot moved this from Todo to Done in Keyman Nov 10, 2025
@keyman-server
Copy link
Copy Markdown
Collaborator

Changes in this pull request will be available for download in Keyman version 19.0.158-alpha

ermshiperete added a commit that referenced this pull request Nov 13, 2025
fix(web): add unit tests for DeadkeyTracker and fix a few bugs

- initialize `Deadkey.matched` in c'tor 
- fix `Deadkey.equal` method 
- verify deadkey exists before removing it in `DeadkeyTracker.remove` 
- add unit tests for DeadkeyTracker

Cherry-pick-of: #15113
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.

4 participants