From 9041c48b77c0954ce9071e64717df3efa2b03c08 Mon Sep 17 00:00:00 2001 From: Jacques Ikot Date: Thu, 10 Oct 2024 11:35:15 +0100 Subject: [PATCH] test: hard code date values in Date_column_types_validation_spec (#36759) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description **Problem** In the test spec, date data is fed directly from a file `(app/client/cypress/fixtures/tableDateColumnTypes.ts)`, which includes specific, static dates. However, the test is designed to handle relative dates (e.g., "today" and "tomorrow"). As a result, when the date picker opens, it displays a fixed date (e.g., September 2024), while the test is attempting to select a date like October 8 (tomorrow’s date), which is out of view. EE PR - https://github.com/appsmithorg/appsmith-ee/pull/5312 Fixes #36756 ## Automation /ok-to-test tags="@tag.Table" ### :mag: Cypress test results > [!TIP] > 🟒 🟒 🟒 All cypress tests have passed! πŸŽ‰ πŸŽ‰ πŸŽ‰ > Workflow run: > Commit: 9ac8789c2c00838cef45fcc1ad712e1afc419942 > Cypress dashboard. > Tags: `@tag.Table` > Spec: >
Thu, 10 Oct 2024 09:53:10 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **Bug Fixes** - Enhanced clarity and specificity in end-to-end tests for date column validation in the table widget. - Updated assertions to directly compare against a specific hardcoded date. - **Refactor** - Removed the `getFormattedTomorrowDates` method from the Table class, streamlining date formatting functionality. --- .../Date_column_types_validation_spec.ts | 11 +++--- app/client/cypress/support/Pages/Table.ts | 34 ------------------- 2 files changed, 5 insertions(+), 40 deletions(-) diff --git a/app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_types_validation_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_types_validation_spec.ts index 0ce8bc321a3..312ebb7c946 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_types_validation_spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_types_validation_spec.ts @@ -43,17 +43,16 @@ describe( // Click unix cell edit table.ClickOnEditIcon(row, column); - // Click on specific date within + // Click on a specific date within the view port of the date picker + // Date picker opens in september 2024 due to the Table data set agHelper.GetNClick( - `${table._dateInputPopover} [aria-label='${table.getFormattedTomorrowDates().verboseFormat}']`, + `${table._dateInputPopover} [aria-label='Thu Sep 26 2024']`, ); - // Check that date is set in column + // Check that the date is set in column table .ReadTableRowColumnData(row, column, "v2") - .then((val) => - expect(val).to.equal(table.getFormattedTomorrowDates().isoFormat), - ); + .then((val) => expect(val).to.equal("2024-09-26")); }; it("1. should allow inline editing of Unix Timestamp in seconds (unix/s)", () => { diff --git a/app/client/cypress/support/Pages/Table.ts b/app/client/cypress/support/Pages/Table.ts index 45dd2132ded..d1439a58927 100644 --- a/app/client/cypress/support/Pages/Table.ts +++ b/app/client/cypress/support/Pages/Table.ts @@ -854,38 +854,4 @@ export class Table { this.agHelper.GetHoverNClick(selector, 1, true); verify && cy.get(selector).eq(1).should("be.disabled"); } - - /** - * Helper function to get formatted date strings for tomorrow's date. - * - * @returns {Object} An object containing: - * - verbose format (e.g., "Sat Sep 21 2024") - * - ISO date format (e.g., "2024-09-21") - */ - public getFormattedTomorrowDates() { - // Create a new Date object for today - const tomorrow = new Date(); - - // Set the date to tomorrow by adding 1 to today's date - tomorrow.setDate(tomorrow.getDate() + 1); - - // Format tomorrow's date in verbose form (e.g., "Sat Sep 21 2024") - const verboseFormat = tomorrow - .toLocaleDateString("en-US", { - weekday: "short", - year: "numeric", - month: "short", - day: "2-digit", - }) - .replace(/,/g, ""); // Remove commas from the formatted string - - // Format tomorrow's date in ISO form (e.g., "2024-09-21") - const isoFormat = tomorrow.toISOString().split("T")[0]; // Extract the date part only - - // Return both formatted date strings as an object - return { - verboseFormat, - isoFormat, - }; - } }