From cdc6dc31e501eed6678e33c502ae92be9c057cd1 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Tue, 20 Feb 2024 07:16:20 +0000 Subject: [PATCH] test: added some more tests --- .../smartsheet/calendar/DayView/DateField.vue | 2 +- .../calendar/DayView/DateTimeField.vue | 5 +- .../smartsheet/calendar/SideMenu.vue | 22 ++- .../calendar/WeekView/DateField.vue | 8 +- .../calendar/WeekView/DateTimeField.vue | 6 +- .../composables/useCalendarViewStore.ts | 7 +- .../Dashboard/Calendar/CalendarDayDateTime.ts | 18 +-- .../pages/Dashboard/Calendar/CalendarMonth.ts | 1 - .../Calendar/CalendarWeekDateTime.ts | 44 ++++++ .../pages/Dashboard/Calendar/index.ts | 8 +- .../tests/db/views/viewCalendar.spec.ts | 142 ++++-------------- 11 files changed, 127 insertions(+), 136 deletions(-) create mode 100644 tests/playwright/pages/Dashboard/Calendar/CalendarWeekDateTime.ts diff --git a/packages/nc-gui/components/smartsheet/calendar/DayView/DateField.vue b/packages/nc-gui/components/smartsheet/calendar/DayView/DateField.vue index eeaae6dd3d..8d61c7a47b 100644 --- a/packages/nc-gui/components/smartsheet/calendar/DayView/DateField.vue +++ b/packages/nc-gui/components/smartsheet/calendar/DayView/DateField.vue @@ -184,7 +184,7 @@ const dropEvent = (event: DragEvent) => { :style="record.rowMeta.style" class="absolute mt-2" @mouseleave="hoverRecord = null" - @mouseover="hoverRecord = record.rowMeta.id" + @mouseover="hoverRecord = record.rowMeta.id as string" > {
{ '!border-brand-500': hour.isSame(selectedTime), }" class="flex w-full min-h-20 relative border-1 group hover:bg-gray-50 border-white border-b-gray-100" + data-testid="nc-calendar-day-hour" @click="selectedTime = hour" >
@@ -681,6 +683,7 @@ const viewMore = (hour: dayjs.Dayjs) => {
{ } }) +const newRecord = () => { + const row = { + ...rowDefaultData(meta.value?.columns), + } + + if (activeCalendarView.value === 'day') { + row[calendarRange.value[0]!.fk_from_col!.title!] = selectedDate.value.format('YYYY-MM-DD HH:mm:ssZ') + } else if (activeCalendarView.value === 'week') { + row[calendarRange.value[0]!.fk_from_col!.title!] = selectedDateRange.value.start.format('YYYY-MM-DD HH:mm:ssZ') + } else if (activeCalendarView.value === 'month') { + row[calendarRange.value[0]!.fk_from_col!.title!] = (selectedDate.value ?? selectedMonth.value).format('YYYY-MM-DD HH:mm:ssZ') + } else if (activeCalendarView.value === 'year') { + row[calendarRange.value[0]!.fk_from_col!.title!] = selectedDate.value.format('YYYY-MM-DD HH:mm:ssZ') + } + + emit('new-record', { row, oldRow: {}, rowMeta: { new: true } }) +} + const height = ref(0) const heightListener = () => { @@ -353,7 +373,7 @@ onUnmounted(() => { class="!absolute right-5 !border-brand-500 bottom-5 !h-12 !w-12" data-testid="nc-calendar-side-menu-new-btn" type="secondary" - @click="emit('new-record', { row: {} })" + @click="newRecord" >
diff --git a/packages/nc-gui/components/smartsheet/calendar/WeekView/DateField.vue b/packages/nc-gui/components/smartsheet/calendar/WeekView/DateField.vue index 6cfe22e77d..66bbd70a1c 100644 --- a/packages/nc-gui/components/smartsheet/calendar/WeekView/DateField.vue +++ b/packages/nc-gui/components/smartsheet/calendar/WeekView/DateField.vue @@ -574,7 +574,7 @@ const dropEvent = (event: DragEvent) => {