Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test upgrade #779

Merged
merged 90 commits into from
May 12, 2024
Merged

Test upgrade #779

merged 90 commits into from
May 12, 2024

Conversation

s-yadav
Copy link
Owner

@s-yadav s-yadav commented Jul 22, 2023

Describe the issue/change

Add CodeSandbox link to illustrate the issue (If applicable)

Describe specs for failing cases if this is an issue (If applicable)

Describe the changes proposed/implemented in this PR

Link Github issue if this PR solved an existing issue

Example usage (If applicable)

Screenshot (If applicable)

Please check which browsers were used for testing

  • Chrome
  • Chrome (Android)
  • Safari (OSX)
  • Safari (iOS)
  • Firefox
  • Firefox (Android)

test/library/format_as_text.spec.jsx Outdated Show resolved Hide resolved
test/library/input.spec.jsx Outdated Show resolved Hide resolved
test/library/input.spec.jsx Outdated Show resolved Hide resolved
test/library/input.spec.jsx Outdated Show resolved Hide resolved
test/library/input.spec.jsx Outdated Show resolved Hide resolved
test/library/input.spec.jsx Outdated Show resolved Hide resolved
test/library/input.spec.jsx Outdated Show resolved Hide resolved
test/library/input.spec.jsx Show resolved Hide resolved
test/library/input.spec.jsx Outdated Show resolved Hide resolved
test/library/input.spec.jsx Outdated Show resolved Hide resolved
@aashu16
Copy link
Collaborator

aashu16 commented Jul 25, 2023

The changes from #763 are not ready to be merged into main yet. I think it would be better to close this PR and create a new one when some of the other ongoing work in the dev branch has been completed.

@aashu16 aashu16 reopened this Mar 18, 2024
@aashu16
Copy link
Collaborator

aashu16 commented Mar 18, 2024

@aashu16, Aaah better to use the same PR, so I can just check on changes that has been done after the last review. Or else I have to go through all the changes again. Not sure if we reopen github will allow seeing the changes made afterwards.

Sure, no problem. I will leave this open for now and keep making changes. You should still be able to see your comments and my responses. I marked them as resolved, but feel free to undo that.

Anyways other option is that I can check from commit ranges. But Yes please don't squash all the commits until the review is finished.

Not planning on squashing anything 😄

test/test_util.js Show resolved Hide resolved
test/test_util.js Outdated Show resolved Hide resolved

input.simulate('focus', focusEvent);
export function simulateFocusEvent(input) {
input.focus();
Copy link
Owner Author

Choose a reason for hiding this comment

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

Suggestion/Test Bug
So there are three cases how focus can happen.

  • Due to mouse click on specific caret position. In which case the caret is placed at specific position. Which I think the usage is replaced now with simulateMousUpEvent.
  • Due to tab press, in which case whole input value gets selected.
  • Manual input.focus call, in which case also whole input value gets selected.

If we catering all the three cases with this util, we should have selectionStart and selectionEnd as param.

In case we are catering 2nd and 3rd, we need to manually set the selectionStart to 0 and selectionEnd at input.value.length

Reason: input.focus() in JSDom puts the caret position at the end, which is not same as browser.

test/test_util.js Outdated Show resolved Hide resolved
@s-yadav
Copy link
Owner Author

s-yadav commented Mar 24, 2024

@aashu16 Merged master and fixed some broken tests which was incorrect on master as well. Also, I see couple of eslint error for unused variables in testing files, maybe you can remove those as well.

s-yadav and others added 15 commits March 24, 2024 17:15
* The positive assertion makes more sense while still covering the
  negative assertion case.
* Key input now directly uses @test-library/user-event to type text into
  the input element being tested. Previously, in some cases, the
  function used `fireEvent.change` to update the value of the input
  element with a pre-computed value.
* This change does not extend to "special keys" such as `Backspace` or
  `Delete`.
* The test now uses the `simulateKeyInput` function to set
  `input.selectionRange`. Pressing any key then replaces the selected text
  inside the input element.
* Added functions to select text inside an input element by, 1) double clicking
  inside it at a given position, and 2) pressing and dragging the mouse cursor.
* If `selectionEnd` is undefined, it is set to `selectionStart`, which
  matches the behaviour of `simulateKeyInput` function.
* It also uses other functions to select text inside the input element
  instead of directly setting the `selectionRange`.
* The other `simulateFocus` should ideally be used only when necessary
  as clicking to focus handles the more general cases when the user
  takes an action to focus the input element.
* Add the todo annotation to four tests that are currently failing.
  These tests have been confirmed to fail in a browser upon manual
  testing.
* Fix incorrect assertion in a test.
* Add a workaround to handle cases where `input.selectionStart !=
  input.selectionEnd` by first removing the selected text in the input
  and then using `user.keyboard` to type the key pressed.
@aashu16
Copy link
Collaborator

aashu16 commented Apr 6, 2024

@s-yadav, I think this is just about ready to merge now. Let me know if you have any comments regarding the recent commits.

(Please don't merge yet.)

aashu16 and others added 6 commits April 28, 2024 18:58
* Update node version.
* Use the latest versions of setup-node and checkout actions.
* Use `--frozen-lockfile` flag when running `yarn install`.
* Update script to run the new test suite.
- Added better way to find change range which fixes  issue around duplicate subsequent characters giving incorrect change range.
- Remove findChangedIndex util, as it wasn't used anywhere.
- Fix simulateKeyInput util
- Fix incorrect test
- Fix issue when complete text is selected and replaced with new value in pattern format. It was it was incorrectly pasting value.
@s-yadav
Copy link
Owner Author

s-yadav commented May 12, 2024

Hey @aashu16, all changes look good. I think let's merge this as there are couple of bug fixes I was planning to do, and better to do with new tests. If there are any changes required we can do that on separate pr.

Also, was making some changes to the core logic so wanted to do it on this branch only, seems like there was test for it, but earlier it was just giving false positives. In this branch, it was marked for todo.
Have made that, plus fixed all the todo tests, and also some changes around test_util to support my changes.

This are my changes. https://github.com/s-yadav/react-number-format/pull/779/files/91e8fd263a815f00d15f542a02dbad23c526ed6e..ca97625a2296f6fe39d33e9e4736e1cb7243cac2

@s-yadav s-yadav merged commit 5edf305 into master May 12, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants