InsetInputE2E.jsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import React from 'react';
  2. import { DatePicker, Space, Button } from '@douyinfe/semi-ui';
  3. /**
  4. * Test with Cypress
  5. * Don't modify DOM structure
  6. */
  7. export default function App() {
  8. const [needConfirm, setNeedConfirm] = React.useState(false);
  9. const spacing = [200, 400];
  10. const props = {
  11. insetInput: true,
  12. defaultPickerValue: '2021-12-01',
  13. motion: false,
  14. };
  15. const handleToggleNeedConfirm = () => {
  16. setNeedConfirm(!needConfirm);
  17. };
  18. return (
  19. <div style={{ height: '300vh' }}>
  20. <div style={{ marginBottom: 12 }}>
  21. <Space>
  22. <Button onClick={handleToggleNeedConfirm} data-cy="btn">
  23. {`needConfirm=${needConfirm}`}
  24. </Button>
  25. </Space>
  26. </div>
  27. <Space wrap spacing={spacing}>
  28. <div data-cy="date">
  29. <DatePicker placeholder="选择单个日期" {...props} />
  30. </div>
  31. <div data-cy="month">
  32. <DatePicker
  33. {...props}
  34. placeholder="选择月"
  35. type="month"
  36. defaultValue="2021-12"
  37. timePickerOpts={{
  38. scrollItemProps: { motion: false },
  39. }}
  40. />
  41. </div>
  42. <div data-cy="dateTime">
  43. <DatePicker placeholder="选择日期时间" {...props} type="dateTime" needConfirm={needConfirm} />
  44. </div>
  45. <div data-cy="dateRange">
  46. <DatePicker placeholder="选择日期范围" {...props} type="dateRange" />
  47. </div>
  48. <div data-cy="dateTimeRange">
  49. <DatePicker
  50. placeholder="选择日期时间范围"
  51. {...props}
  52. type="dateTimeRange"
  53. needConfirm={needConfirm}
  54. />
  55. </div>
  56. <div data-cy="customFormat">
  57. <DatePicker placeholder="选择日期范围" {...props} type="dateRange" format="Pp" />
  58. </div>
  59. </Space>
  60. </div>
  61. );
  62. }
  63. App.parameters = { chromatic: { disableSnapshot: true } };
  64. App.storyName = 'inset input e2e test';