Skip to content

Commit

Permalink
Add e2e for the mobile value behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy committed Jul 11, 2024
1 parent 87b5319 commit 617f315
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/e2e/fixtures/DatePicker/MobileDatePickerV6WithClearAction.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import dayjs from 'dayjs';
import { MobileDatePicker } from '@mui/x-date-pickers/MobileDatePicker';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';

export default function MobileDatePickerV6WithClearAction() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<MobileDatePicker
label="Mobile Date Picker"
defaultValue={dayjs('2022-04-17')}
slotProps={{
actionBar: {
actions: ['clear', 'cancel', 'accept'],
},
}}
/>
</LocalizationProvider>
);
}
13 changes: 13 additions & 0 deletions test/e2e/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,19 @@ async function initializeEnvironment(
'04/11/2022',
);
});

it('should have consistent `placeholder` and `value` behavior', async () => {
await renderFixture('DatePicker/MobileDatePickerV6WithClearAction');

const input = page.getByRole('textbox');

await input.click({ position: { x: 10, y: 2 } });
await page.getByRole('button', { name: 'Clear' }).click();

await input.blur();
expect(await input.getAttribute('placeholder')).to.equal('MM/DD/YYYY');
expect(await input.inputValue()).to.equal('');
});
});
});

Expand Down

0 comments on commit 617f315

Please sign in to comment.