From 972f236a122f31c3a6e7e7fe0117a6bc7cdcda1e Mon Sep 17 00:00:00 2001 From: Xc <124118265@qq.com> Date: Mon, 25 Dec 2023 10:50:10 +0800 Subject: [PATCH] fix(components): [date-picker] add first click demo (#15252) --- .../__tests__/date-time-picker.test.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/components/date-picker/__tests__/date-time-picker.test.tsx b/packages/components/date-picker/__tests__/date-time-picker.test.tsx index 9fdb3f4daa..dc02bffbdb 100644 --- a/packages/components/date-picker/__tests__/date-time-picker.test.tsx +++ b/packages/components/date-picker/__tests__/date-time-picker.test.tsx @@ -384,6 +384,25 @@ describe('Datetime Picker', () => { await nextTick() expect(timeInput.value).toBe('13:00:00') }) + + // fix #15196 + it('first click accuracy', async () => { + const value = ref('') + const wrapper = _mount(() => ( + + )) + + const input = wrapper.find('input') + input.trigger('blur') + input.trigger('focus') + await nextTick() + const dayItems = document.querySelectorAll('.el-date-table-cell__text') + const targetDay = dayItems[15] as HTMLElement // Try to make sure the date is this month + const dayText = targetDay.textContent + targetDay.click() + await nextTick() + expect(dayjs(value.value).format('D')).toBe(dayText) + }) }) describe('Datetimerange', () => {