Skip to content

Conversation

@MichaelWest22
Copy link
Collaborator

@MichaelWest22 MichaelWest22 commented Apr 21, 2025

Description

This is a follow up to the new web-test-runner testing PR with more fixes to increase code coverage reporting.

Three new tests written to cover 3 edge cases that had no coverage before

  1. calling htmx.process on a non element type triggers an is element check
  2. file formData ignores blank file name now tested
  3. disabling a sub child element triggers a disabled check in initNode()

When fixing this third one I found the is element disabled checking is used in multiple places without the eltIsDisabled() helper function so fixed this in three places

There was a bug with webkit testing microsoft/playwright#5894 that had a try catch inserted to handle but after much time testing old versions I reproduced the issue again but found it was fixed in 2022 with webkit 16.0 so we can now safely remove this workaround.

There was also a bug/edge-case i found that is not currently handled perfectly when it runs removeValueFromFormData to remove an input that will be included on a form it only removes the input value and not multiple values in array. To fix this issue I moved a chunk of value lookup logic into a sub function getValueFromInput() so it can be ruesed by the removeValueFromFormData as well which solved the bug and the code coverage issue. Updated my test for this to show the impact.

FormData proxy had a block of code that could not be executed to test because it seems like an invalid fallback we don't need. checked with @Telroshan to confirm it wasn't needed.

Finally there were several element checks that I found were just not needed and found several of the JSDocs had Node when they should be Element which solved this issue. Part of the confusion here is that resolveTarget() function can return node types instead of Element when dealing with some situations like from triggers as you can have document here as an option (maybe we need two resolveTarget functions??). But for the main target use case it will only ever return an Element and be valid. I managed to hack around it to make it target a non element text node but this just breaks things later as it tries to add a class to the target so its just not supported right now.

Corresponding issue:

Testing

mostly tested using new testing suite

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue
  • I ran the test suite locally (npm run test) and verified that it succeeded
@MichaelWest22 MichaelWest22 changed the title Code coverage3 Apr 21, 2025
@MichaelWest22
Copy link
Collaborator Author

This PR also includes a fix that was in #2215 which I found was also a code coverage issue

@Telroshan Telroshan added enhancement New feature or request devops Changes to the repository structure or project management labels Apr 22, 2025
Copy link
Collaborator

@Telroshan Telroshan left a comment

Choose a reason for hiding this comment

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

Amazing as always!
I love the fact that the lib is becoming more and more reliable with your recent PRs 😄

@Telroshan Telroshan added the ready for review Issues that are ready to be considered for merging label Apr 22, 2025
@1cg 1cg merged commit 408850a into bigskysoftware:dev Apr 24, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops Changes to the repository structure or project management enhancement New feature or request ready for review Issues that are ready to be considered for merging

3 participants