diff --git a/src/__tests__/form-test.tsx b/src/__tests__/form-test.tsx index bf5a72ba4..8500fbf37 100644 --- a/src/__tests__/form-test.tsx +++ b/src/__tests__/form-test.tsx @@ -1,7 +1,19 @@ import * as React from 'react'; import {render, screen, waitFor} from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import {ButtonPrimary, Form, TextField, EmailField, PasswordField, Switch, PhoneNumberField} from '..'; +import { + ButtonPrimary, + Form, + TextField, + EmailField, + PasswordField, + Switch, + PhoneNumberField, + DateField, + DateTimeField, + Select, + MonthField, +} from '..'; import ThemeContextProvider from '../theme-context-provider'; import {makeTheme} from './test-utils'; @@ -296,3 +308,43 @@ test('Disabling a field removes the error state and disabled fields are not subm {phone: '654 83 44 55', switch: false} ); }); + +test.each` + platform | type | expectedFocus + ${'ios'} | ${'date'} | ${false} + ${'ios'} | ${'datetime-local'} | ${false} + ${'ios'} | ${'month'} | ${false} + ${'ios'} | ${'select'} | ${false} + ${'ios'} | ${'text'} | ${true} + ${'android'} | ${'date'} | ${true} + ${'android'} | ${'datetime-local'} | ${true} + ${'android'} | ${'month'} | ${true} + ${'android'} | ${'select'} | ${true} + ${'android'} | ${'text'} | ${true} +`('autofocus on error - $platform $type $expectedFocus', async ({platform, type, expectedFocus}) => { + const FormComponent = () => { + return ( + +
{}}> + {type === 'date' && } + {type === 'datetime-local' && } + {type === 'month' && } + {type === 'select' && ( +