From 71d935337d9e8a7ad0cab624c02ae032c9e08fa2 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Tue, 20 Feb 2024 07:16:20 +0000 Subject: [PATCH] test: fix --- .../calendar/WeekView/DateField.vue | 4 +-- .../pages/Dashboard/Grid/Column/index.ts | 14 ++++++-- .../tests/db/views/viewCalendar.spec.ts | 35 +++++++++++++++++-- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/calendar/WeekView/DateField.vue b/packages/nc-gui/components/smartsheet/calendar/WeekView/DateField.vue index 7905c2a331..d9c346fbad 100644 --- a/packages/nc-gui/components/smartsheet/calendar/WeekView/DateField.vue +++ b/packages/nc-gui/components/smartsheet/calendar/WeekView/DateField.vue @@ -606,6 +606,7 @@ const dropEvent = (event: DragEvent) => {
.ant-select-selection-item').first().click(); + async selectType({ type, first }: { type: string; first?: boolean }) { + if (first) { + await this.get().locator('.ant-select-selector > .ant-select-selection-item').first().click(); + } else { + await this.get().locator('.ant-select-selector > .ant-select-selection-item').click(); + } await this.get().locator('.ant-select-selection-search-input[aria-expanded="true"]').waitFor(); await this.get().locator('.ant-select-selection-search-input[aria-expanded="true"]').fill(type); @@ -279,6 +283,7 @@ export class ColumnPageObject extends BasePage { format, dateFormat = '', timeFormat = '', + selectType = false, }: { title: string; type?: string; @@ -286,6 +291,7 @@ export class ColumnPageObject extends BasePage { format?: string; dateFormat?: string; timeFormat?: string; + selectType?: boolean; }) { // when clicked on the dropdown cell header await this.getColumnHeader(title).locator('.nc-ui-dt-dropdown').scrollIntoViewIfNeeded(); @@ -294,7 +300,9 @@ export class ColumnPageObject extends BasePage { await this.get().waitFor({ state: 'visible' }); - await this.selectType({ type }); + if (selectType) { + await this.selectType({ type, first: true }); + } switch (type) { case 'Formula': diff --git a/tests/playwright/tests/db/views/viewCalendar.spec.ts b/tests/playwright/tests/db/views/viewCalendar.spec.ts index b1362a4dea..88687d20da 100644 --- a/tests/playwright/tests/db/views/viewCalendar.spec.ts +++ b/tests/playwright/tests/db/views/viewCalendar.spec.ts @@ -1,4 +1,4 @@ -import { test } from '@playwright/test'; +import { Page, test } from '@playwright/test'; import { DashboardPage } from '../../../pages/Dashboard'; import { ToolbarPage } from '../../../pages/Dashboard/common/Toolbar'; @@ -45,6 +45,23 @@ test.describe('View', () => { let dashboard: DashboardPage, toolbar: ToolbarPage, topbar: TopbarPage, calendarTopbar: CalendarTopbarPage; let context: any; + async function undo({ page, dashboard }: { page: Page; dashboard: DashboardPage }) { + const isMac = await dashboard.grid.isMacOs(); + + if (validateResponse) { + await dashboard.grid.waitForResponse({ + uiAction: () => page.keyboard.press(isMac ? 'Meta+z' : 'Control+z'), + httpMethodsToMatch: ['PATCH'], + requestUrlPathToMatch: `/api/v1/db/data/noco/`, + }); + } else { + await page.keyboard.press(isMac ? 'Meta+z' : 'Control+z'); + + // allow time for undo to complete rendering + await page.waitForTimeout(500); + } + } + test.beforeEach(async ({ page }) => { context = await setup({ page, isEmptyProject: false }); dashboard = new DashboardPage(page, context.base); @@ -255,7 +272,7 @@ test.describe('View', () => { await dashboard.viewSidebar.deleteView({ title: 'Calendar' }); }); - test('Calendar Drag and Drop & Undo Redo Operations', async () => { + test.only('Calendar Drag and Drop & Undo Redo Operations', async () => { await dashboard.viewSidebar.createCalendarView({ title: 'Calendar', }); @@ -388,6 +405,7 @@ test.describe('View', () => { title: 'StartDate', type: 'Date', dateFormat: 'YYYY-MM-DD', + selectType: true, }); await dashboard.grid.column.save({ isUpdated: true }); @@ -432,5 +450,18 @@ test.describe('View', () => { await calendar.calendarWeekDate.selectDay({ dayIndex: 1 }); await calendar.sideMenu.verifySideBarRecords({ records: [] }); + + await calendar.calendarWeekDate.dragAndDrop({ + record: 'Team Catchup', + dayIndex: 2, + }); + + await calendar.calendarWeekDate.selectDay({ dayIndex: 3 }); + + await calendar.calendarWeekDate.selectDay({ dayIndex: 2 }); + + await calendar.sideMenu.updateFilter({ filter: 'In selected date' }); + + await calendar.sideMenu.verifySideBarRecords({ records: ['Team Catchup'] }); }); });