Skip to content

Commit

Permalink
test: add datepicker monthRange e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLynn committed Nov 18, 2024
1 parent cde4825 commit ea57b6c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cypress/e2e/datePicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -910,4 +910,21 @@ describe('DatePicker', () => {
cy.get('.semi-popover .semi-datepicker-day-selected-start').contains('15');
cy.get('.semi-popover .semi-datepicker-day-selected-end').contains('20');
});

it('auto Correction month under month range', () => {
cy.visit('http://localhost:6006/iframe.html?args=&id=datepicker--fix-2567&viewMode=story');
cy.get('.semi-input').eq(0).click();
cy.get('.semi-scrolllist').eq(1).contains('2024').click();
cy.get('.semi-input').eq(0).should("have.value", "2024-11 ~ 2024-11");
cy.root().click('right');

cy.get('.semi-input').eq(1).click();
cy.get('.semi-scrolllist').eq(1).contains('2024').click();
cy.get('.semi-input').eq(1).should("have.value", "2024-11 ~ 2024-11");
cy.root().click('right');

cy.get('.semi-input').eq(2).click();
cy.get('.semi-scrolllist').eq(0).contains('2025').click();
cy.get('.semi-input').eq(2).should("have.value", "2025-01 ~ 2025-01");
})
});
25 changes: 25 additions & 0 deletions packages/semi-ui/datePicker/_story/datePicker.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1198,3 +1198,28 @@ CashedSelectedValue.storyName = "cashedSelectedValue";
export const Fix1982 = () => {
return <DatePicker type="monthRange" style={{ width: 200 }} />
}


export const Fix2567 = () => {
const disabledDate = (date) => {
const deadDate = new Date('2025/3/1 00:00:00');
const startDate = new Date('2024/11/1 00:00:00');
return date.getTime() < startDate.getTime() || date.getTime() > deadDate.getTime();
}
return (
<div>
<div>datePicker monthRange 对于三种需要矫正日期的处理</div>
<br />
<div>点击右侧面板 2024</div>
<DatePicker defaultValue={['2024-11', '2025-01']}type="monthRange" disabledDate={disabledDate} />
<br />
<br />
<div>点击右侧面板 2024</div>
<DatePicker defaultValue={['2024-12', '2025-01']}type="monthRange" disabledDate={disabledDate} />
<br />
<br />
<div>点击左侧面板 2025</div>
<DatePicker defaultValue={['2024-11', '2025-01']}type="monthRange" disabledDate={disabledDate} />
</div>
)
}

0 comments on commit ea57b6c

Please sign in to comment.