π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix(pw): calendar view test fail issue
Ramesh Mane774793a410e0
diff --git a/packages/nc-gui/components/smartsheet/calendar/SideMenu.vue b/packages/nc-gui/components/smartsheet/calendar/SideMenu.vueindex 743b366c5c..f13d853ff6 100644--- a/packages/nc-gui/components/smartsheet/calendar/SideMenu.vue+++ b/packages/nc-gui/components/smartsheet/calendar/SideMenu.vue@@ -509,7 +509,7 @@ const selectOption = (option) => {'!h-[calc(100svh-16.6rem)]':height <= 700 && (activeCalendarView === 'day' || activeCalendarView === 'week') && showSearch,}"- class="nc-scrollbar-md pl-4 pr-4 overflow-y-auto"+ class="nc-scrollbar-md px-4 pb-4 overflow-y-auto"data-testid="nc-calendar-side-menu-list"@scroll="sideBarListScrollHandle">diff --git a/packages/nc-gui/components/smartsheet/calendar/YearView/Month.vue b/packages/nc-gui/components/smartsheet/calendar/YearView/Month.vueindex 418602f608..248589999d 100644--- a/packages/nc-gui/components/smartsheet/calendar/YearView/Month.vue+++ b/packages/nc-gui/components/smartsheet/calendar/YearView/Month.vue@@ -274,6 +274,7 @@ watch(activeDates, (newActiveDates) => {}"class="px-1 py-1.5 relative rounded border-transparent transition border-1 font-medium flex text-gray-700 items-center cursor-pointer justify-center"data-testid="nc-calendar-date"+ :data-date="date.date.format('DD MMM YYYY')"@click="handleSelectDate(date.date)"@dblclick="emitDblClick(date.date)">diff --git a/tests/playwright/pages/Dashboard/Calendar/CalendarSideMenu.ts b/tests/playwright/pages/Dashboard/Calendar/CalendarSideMenu.tsindex 23f5ae36a9..3e549c7e36 100644--- a/tests/playwright/pages/Dashboard/Calendar/CalendarSideMenu.ts+++ b/tests/playwright/pages/Dashboard/Calendar/CalendarSideMenu.ts@@ -54,42 +54,69 @@ export class CalendarSideMenuPage extends BasePage {await this.next_btn.click();}- async moveToDate({ date, action }: { date: string; action: 'prev' | 'next' }) {- console.log(await this.parent.toolbar.getActiveDate());+ async moveToDate({+ date,+ action,+ jumpTo,+ postSelectViewMode,+ }: {+ date: string;+ action: 'prev' | 'next';+ /**+ * Takes a while to move to date if we click one day at a time+ * So we can jump to nearest date and then move to the date+ * @Note - Select proper jumpTo so that action will work properly+ */+ jumpTo?: {+ day: number;+ month: 'Jan' | 'Feb' | 'Mar' | 'Apr' | 'May' | 'Jun' | 'Jul' | 'Aug' | 'Sep' | 'Oct' | 'Nov' | 'Dec';+ year: number;+ };+ postSelectViewMode?: 'day' | 'week' | 'month' | 'year';+ }) {+ if (jumpTo) {+ await this.parent.toolbar.calendarViewMode.changeCalendarView({ title: 'year' });++ // Select year+ let activeYear = +(await this.parent.toolbar.getActiveDate());++ while (activeYear !== jumpTo.year) {+ if (activeYear < jumpTo.year) {+ await this.clickNext();+ } else {+ await this.clickPrev();+ }++ activeYear = +(await this.parent.toolbar.getActiveDate());+ }- // takes a while to move to date if we click one day at a time- // so we will move to the month first and then select the date- const dateStr = new Date(date);- const options = { month: 'long', year: 'numeric' };- console.log(dateStr.toLocaleDateString('en-US', options));+ const day = String(jumpTo.day).padStart(2, '0');- let dateHeaderStr = await this.get().locator('.nc-date-week-header').textContent();+ const dateLocator = this.parent.calendarYear+ .get()+ .locator(`[data-testid="nc-calendar-date"][data-date="${day} ${jumpTo.month} ${jumpTo.year}"]`)+ .first();- while (dateHeaderStr !== dateStr.toLocaleDateString('en-US', options)) {- if (action === 'prev') {- console.log(await this.monthPrev_btn.count());- await this.monthPrev_btn.click();- } else {- console.log(await this.monthNext_btn.count());- await this.monthNext_btn.click();+ await dateLocator.scrollIntoViewIfNeeded();+ await dateLocator.waitFor();++ await dateLocator.click();++ if (postSelectViewMode) {+ await this.parent.toolbar.calendarViewMode.changeCalendarView({ title: postSelectViewMode });}- dateHeaderStr = await this.get().locator('.nc-date-week-header').textContent();}- // once the month is narrowed down, click on either the first or last date depending on how we intended to navigate- // we can click on date directly. but continuing with the existing logic as it verifies prev & next date movement as well- if (action === 'prev') {- await this.get().getByTestId('nc-calendar-date').last().click();- } else {- await this.get().getByTestId('nc-calendar-date').first().click();- }+ let activeDate = await this.parent.toolbar.getActiveDate();- while ((await this.parent.toolbar.getActiveDate()) !== date) {+ while (activeDate !== date) {if (action === 'prev') {await this.clickPrev();} else {await this.clickNext();}++ activeDate = await this.parent.toolbar.getActiveDate();}}diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/CalendarViewMode.ts b/tests/playwright/pages/Dashboard/common/Toolbar/CalendarViewMode.tsindex 7927f8cf9b..c1e8281cf1 100644--- a/tests/playwright/pages/Dashboard/common/Toolbar/CalendarViewMode.ts+++ b/tests/playwright/pages/Dashboard/common/Toolbar/CalendarViewMode.ts@@ -16,7 +16,7 @@ export class ToolbarCalendarViewModePage extends BasePage {return this.get().getByTestId(`nc-calendar-view-mode-${title}`);}- async changeCalendarView({ title }: { title: string }) {+ async changeCalendarView({ title }: { title: 'day' | 'week' | 'month' | 'year' }) {if (await this.getViewTab({ title }).isVisible()) {await this.getViewTab({ title }).click({ force: true });} else {@@ -25,5 +25,8 @@ export class ToolbarCalendarViewModePage extends BasePage {await this.rootPage.locator('.rc-virtual-list-holder-inner > div').locator(`text="${title}"`).click();}++ // Wait for view mode to change+ await this.rootPage.waitForTimeout(1000);}}diff --git a/tests/playwright/tests/db/views/viewCalendar.spec.ts b/tests/playwright/tests/db/views/viewCalendar.spec.tsindex fd8288cca8..985772e6d3 100644--- a/tests/playwright/tests/db/views/viewCalendar.spec.ts+++ b/tests/playwright/tests/db/views/viewCalendar.spec.ts@@ -193,9 +193,12 @@ test.describe('Calendar View', () => {await calendar.toolbar.verifyActiveCalendarView({ view: 'year' });- await toolbar.calendarViewMode.changeCalendarView({ title: 'month' });-- await calendar.sideMenu.moveToDate({ date: 'Jan 2024', action: 'prev' });+ await calendar.sideMenu.moveToDate({+ date: 'Jan 2024',+ action: 'prev',+ jumpTo: { day: 1, month: 'Feb', year: 2024 },+ postSelectViewMode: 'month',+ });// Verify Sidebar Records & Filters@@ -249,11 +252,11 @@ test.describe('Calendar View', () => {await calendar.sideMenu.verifySideBarRecords({ records: [] });- await calendar.toolbar.calendarViewMode.changeCalendarView({ title: 'day' });-await calendar.sideMenu.moveToDate({date: '1 Jan 2024',action: 'prev',+ jumpTo: { day: 5, month: 'Feb', year: 2024 },+ postSelectViewMode: 'day',});await calendar.sideMenu.verifySideBarRecords({ records: dateRecords.filter(f => f.Title).map(f => f.Title) });@@ -271,6 +274,8 @@ test.describe('Calendar View', () => {await calendar.sideMenu.moveToDate({date: '3 Jan 2024',action: 'next',+ jumpTo: { day: 1, month: 'Jan', year: 2024 },+ postSelectViewMode: 'day',});await calendar.sideMenu.verifySideBarRecords({ records: [] });@@ -311,7 +316,12 @@ test.describe('Calendar View', () => {const calendar = dashboard.calendar;- await calendar.sideMenu.moveToDate({ date: 'Jan 2024', action: 'prev' });+ await calendar.sideMenu.moveToDate({+ date: 'Jan 2024',+ action: 'prev',+ jumpTo: { day: 1, month: 'Mar', year: 2024 },+ postSelectViewMode: 'month',+ });await calendar.calendarMonth.dragAndDrop({record: 'Team Catchup',@@ -330,11 +340,11 @@ test.describe('Calendar View', () => {await calendar.sideMenu.verifySideBarRecords({ records: ['Team Catchup'] });- await calendar.toolbar.calendarViewMode.changeCalendarView({ title: 'week' });-await calendar.sideMenu.moveToDate({date: '1 - 7 Jan 24',action: 'prev',+ jumpTo: { day: 11, month: 'Jan', year: 2024 },+ postSelectViewMode: 'week',});await calendar.dashboard.rootPage.waitForTimeout(1000);@@ -412,11 +422,12 @@ test.describe('Calendar View', () => {await calendar.toolbar.verifyActiveCalendarView({ view: 'year' });- await toolbar.calendarViewMode.changeCalendarView({ title: 'month' });-- // await calendar.toggleSideBar();-- await calendar.sideMenu.moveToDate({ date: 'Jan 2024', action: 'prev' });+ await calendar.sideMenu.moveToDate({+ date: 'Jan 2024',+ action: 'prev',+ jumpTo: { day: 1, month: 'Feb', year: 2024 },+ postSelectViewMode: 'month',+ });await calendar.sideMenu.verifySideBarRecords({ records: dateRecords.filter(f => f.Title).map(f => f.Title) });@@ -462,9 +473,12 @@ test.describe('Calendar View', () => {const calendar = dashboard.calendar;- // await calendar.toggleSideBar();-- await calendar.sideMenu.moveToDate({ date: '1 Jan 2024', action: 'prev' });+ await calendar.sideMenu.moveToDate({+ date: '1 Jan 2024',+ action: 'prev',+ jumpTo: { day: 5, month: 'Jan', year: 2024 },+ postSelectViewMode: 'day',+ });await calendar.sideMenu.verifySideBarRecords({ records: dateRecords.filter(f => f.Title).map(f => f.Title) });