fix(web): validation of number input fields (#9789)

This commit is contained in:
Michel Heusschen
2024-05-27 10:19:08 +02:00
committed by GitHub
parent e3d39837d0
commit 298370b7be
3 changed files with 27 additions and 4 deletions

View File

@@ -27,4 +27,25 @@ describe('SettingInputField component', () => {
await user.click(document.body);
expect(numberInput.value).toEqual('100');
});
it('allows emptying number inputs while editing', async () => {
const { getByRole } = render(SettingInputField, {
props: {
label: 'test-number-input',
inputType: SettingInputFieldType.NUMBER,
value: 5,
},
});
const user = userEvent.setup();
const numberInput = getByRole('spinbutton') as HTMLInputElement;
expect(numberInput.value).toEqual('5');
await user.click(numberInput);
await user.keyboard('{Backspace}');
expect(numberInput.value).toEqual('');
await user.click(document.body);
expect(numberInput.value).toEqual('0');
});
});