From 6f67dbd85e73f1115d04b5315d4b1efba5930781 Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Wed, 26 Jun 2024 21:16:29 +0530 Subject: [PATCH] test: Use `deep.eq` for comparing objects (#34513) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The JSON string comparison is flaky because it depends on the order of keys in serialized objects. We actually don't care for the order the keys are serialized, just that the keys and values are as we want. This PR should fix that. [Slack conversation](https://theappsmith.slack.com/archives/C0134BAVDB4/p1719409620659339). /test table > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 3fa1746c580d700a3084d94166850acd18432d09 > Cypress dashboard. > Tags: `@tag.Table` --- .../TableV2/Date_column_editing_1_spec.ts | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_editing_1_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_editing_1_spec.ts index 93c7844773..7f72fe3526 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_editing_1_spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_editing_1_spec.ts @@ -60,20 +60,28 @@ describe( ); agHelper.AssertElementAbsence(table._dateInputPopover); agHelper.AssertElementAbsence(table._editCellEditor); - agHelper - .GetText(locators._textWidget, "text", 0) - .then(($textData) => - expect($textData).to.eq( - `{"revenue":42600000,"imdb_id":"tt3228774","release_date":"2021-05-17"}`, - ), - ); - agHelper - .GetText(locators._textWidget, "text", 1) - .then(($textData) => - expect($textData).to.eq( - `[{"index":0,"updatedFields":{"release_date":"2021-05-17"},"allFields":{"revenue":42600000,"imdb_id":"tt3228774","release_date":"2021-05-17"}}]`, - ), - ); + agHelper.GetText(locators._textWidget, "text", 0).then(($textData) => + expect(JSON.parse($textData as string)).to.deep.eq({ + revenue: 42600000, + imdb_id: "tt3228774", + release_date: "2021-05-17", + }), + ); + agHelper.GetText(locators._textWidget, "text", 1).then(($textData) => + expect(JSON.parse($textData as string)).to.deep.eq([ + { + index: 0, + updatedFields: { + release_date: "2021-05-17", + }, + allFields: { + revenue: 42600000, + imdb_id: "tt3228774", + release_date: "2021-05-17", + }, + }, + ]), + ); agHelper .GetText(locators._textWidget, "text", 2) .then(($textData) => expect($textData).to.eq("[0]"));