emberjs / emberjs/ember-test-helpers

typeIn not properly handling decimal places

Open
#1,546 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
188
Forks
254
PR merge metrics
No merged PRs in 30d

Description

I have the following test:

```ts
test('number type input accepts decimal values', async function (assert) {

await render(

);

const input = this.element.querySelector('input') as HTMLInputElement;

await typeIn('input', '1.03');
assert.strictEqual(input.value, '1.03', 'allows decimal values');
});
```

and it returns:

```
test-app:test: not ok 38 Chrome 135.0 - [249 ms] - Integration Component HeadlessForm > Input: number type input accepts decimal values
test-app:test: ---
test-app:test: actual: >
test-app:test: 03
test-app:test: expected: >
test-app:test: 1.03
test-app:test: stack: >
test-app:test: at Object. (http://localhost:4203/assets/tests.js:1378:14)
test-app:test: message: >
test-app:test: allows decimal values
test-app:test: negative: >
test-app:test: false
test-app:test: browser log: |
test-app:test: ...
```

Indicating an issue with the way that typeIn handles number inputs with decimal places. I cannot repeat this failure between Chrome and Firefox. Only within the test suite. Using `fillIn` instead allows for the test to pass. But `typeIn` should also work. If I had to guess the order in which events are fired may be off when using `typeIn`. I'll need to look into it further.

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied number-input test in the test suite and compare its behavior with fillIn. Trace the typeIn entry point and its event handling for an input with step="0.01" and value "1.03". Done means typeIn preserves the complete decimal value consistently in the test suite, including the reported Chrome case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.