-
Notifications
You must be signed in to change notification settings - Fork 4.6k
chore: fix map chart spec #36370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: fix map chart spec #36370
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /// <reference types="Cypress" /> | ||
| import viewWidgetsPage from "../../../../../locators/ViewWidgets.json"; | ||
| import publishWidgetspage from "../../../../../locators/publishWidgetspage.json"; | ||
| import { | ||
| agHelper, | ||
| entityExplorer, | ||
|
|
@@ -13,106 +13,86 @@ import EditorNavigation, { | |
| } from "../../../../../support/Pages/EditorNavigation"; | ||
|
|
||
| const _mapChartCaption = "text:last-child"; | ||
| const _mapChartPlot = (text: string) => | ||
| "//text()[contains(., '" + text + "')]/.."; | ||
|
|
||
| describe( | ||
| "Map Chart Widget Functionality", | ||
| { tags: ["@tag.Widget", "@tag.Maps", "@tag.Visual"] }, | ||
| function () { | ||
| it("1. Drag and drop a Map Chart widget and verify", function () { | ||
| entityExplorer.DragDropWidgetNVerify(draggableWidgets.MAPCHART, 200, 200); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("text") | ||
| .should("contain.text", "AS"); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapchartsimple"); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("text") | ||
| .should("contain.text", "AS"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
| }); | ||
|
|
||
| it("2.1 Update the Map type to different types and verify - part1", function () { | ||
| // Change the map type to World with Antarctica and verify the number of entities | ||
| propPane.SelectPropertiesDropDown("Map type", "World with Antarctica"); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapwithantarctica"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
|
|
||
| // Change the map type to World and verify the number of entities | ||
| propPane.SelectPropertiesDropDown("Map type", "World"); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapwithworld"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("text") | ||
| .should("contain.text", "AT"); | ||
|
|
||
| // Change the map type to Europe and verify the number of entities | ||
| propPane.SelectPropertiesDropDown("Map type", "Europe"); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapwitheurope"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("text") | ||
| .should("contain.text", "FR"); | ||
|
|
||
| // Change the map type to North America and verify the number of entities | ||
| propPane.SelectPropertiesDropDown("Map type", "North America"); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapwithnorthamerica"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("text") | ||
| .should("contain.text", "CA"); | ||
|
|
||
| // Change the map type to South America and verify the number of entities | ||
| propPane.SelectPropertiesDropDown("Map type", "South America"); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapwithsouthamerica"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("text") | ||
| .should("contain.text", "BR"); | ||
| }); | ||
|
|
||
| it("2.2 Update the Map type to different types and verify - part2", function () { | ||
| // Change the map type to Oceania and verify the number of entities | ||
| propPane.SelectPropertiesDropDown("Map type", "Oceania"); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapwithoceania"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("text") | ||
| .should("contain.text", "AU"); | ||
|
|
||
| // Change the map type to Africa and verify the number of entities | ||
| propPane.SelectPropertiesDropDown("Map type", "Africa"); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapwithafrica"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("text") | ||
| .should("contain.text", "ZA"); | ||
|
|
||
| // Change the map type to USA and verify the number of entities | ||
| propPane.SelectPropertiesDropDown("Map type", "USA"); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapwithusa"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("text") | ||
| .should("contain.text", "TX"); | ||
|
|
||
| // Change the map type to Asia and verify the number of entities | ||
| propPane.SelectPropertiesDropDown("Map type", "Asia"); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapwithasia"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("text") | ||
| .should("contain.text", "IN"); | ||
| }); | ||
|
|
||
| it("3. Update the Chart data and verify", function () { | ||
|
|
@@ -124,64 +104,30 @@ describe( | |
| ]; | ||
|
|
||
| propPane.TypeTextIntoField("Chart data", JSON.stringify(data)); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapwithcustomdata"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("text") | ||
| .should("contain.text", "IN: 2"); | ||
| }); | ||
|
|
||
| it("4. Verify General settings", function () { | ||
| // update the title and verify | ||
| propPane.TypeTextIntoField("Title", "App Sign Up"); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.AssertText(_mapChartCaption, "text", "App Sign Up"); | ||
| agHelper.VerifySnapshot(locators._root, "mapwithcustomtitle"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
|
|
||
| // update the visibility using toggle and verify | ||
| propPane.TogglePropertyState("Visible", "Off"); | ||
| deployMode.DeployApp(); | ||
| agHelper.AssertElementAbsence( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapwithvisibilityoff"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
|
|
||
| // update the visibility using JS and verify | ||
| propPane.EnterJSContext("Visible", "true"); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.AssertElementVisibility( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapwithvisibilityon"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
|
|
||
| // update the show labels using toggle and verify | ||
| propPane.TogglePropertyState("Show Labels", "Off"); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapwithshowlabelsoff"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("text") | ||
| .should("not.contain.text", "IN: 2"); | ||
|
|
||
| // update the visibility using JS and verify | ||
| propPane.EnterJSContext("Show Labels", "true"); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapwithshowlableson"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("text") | ||
| .should("contain.text", "IN: 2"); | ||
| }); | ||
|
|
||
| it("5. Update onDataPointClick and Verify", function () { | ||
|
|
@@ -192,26 +138,32 @@ describe( | |
| propPane._actionSelectorFieldByLabel("Message"), | ||
| "Data Point {{MapChart1.selectedDataPoint.label}} Clicked", | ||
| ); | ||
| agHelper.GetNClick(propPane._actionSelectorPopupClose); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.GetNClick(_mapChartPlot("RU: 1.30"), 0, true); | ||
| agHelper.ValidateToastMessage("Data Point Russian Federation Clicked"); | ||
| deployMode.NavigateBacktoEditor(); | ||
|
|
||
| agHelper.GetNClick(locators._enterPreviewMode); | ||
| agHelper | ||
| .GetElement(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("text") | ||
| .should("contain.text", "IN: 2") | ||
| .click(); | ||
| agHelper.ValidateToastMessage("Data Point India Clicked"); | ||
| agHelper.GetNClick(locators._exitPreviewMode); | ||
|
Comment on lines
+141
to
+109
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great test for the "onDataPointClick" property, but let's avoid using The test effectively verifies the behavior of the "onDataPointClick" property by setting it to "Show alert" with a custom message, entering preview mode, clicking on a specific data point, and validating the presence of the expected toast message. This is a good way to ensure the map chart is triggering the correct action when a data point is clicked. However, the code is using Consider removing the usage of |
||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
|
|
||
| // Convert the onDataPointClick to JS, update and verify | ||
| propPane.EnterJSContext( | ||
| "onDataPointClick", | ||
| "{{showAlert('Converted to Js and clicked '+ MapChart1.selectedDataPoint.label)}}", | ||
| ); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.GetNClick(_mapChartPlot("CN: .40"), 0, true); | ||
| agHelper.ValidateToastMessage("Converted to Js and clicked China"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| agHelper.GetNClick(locators._enterPreviewMode); | ||
| agHelper | ||
| .GetElement(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("text") | ||
| .should("contain.text", "IN: 2") | ||
| .click(); | ||
| agHelper.ValidateToastMessage("Converted to Js and clicked India"); | ||
| agHelper.GetNClick(locators._exitPreviewMode); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
| }); | ||
|
|
||
|
|
@@ -226,33 +178,29 @@ describe( | |
| ]; | ||
| propPane.MoveToTab("Style"); | ||
| propPane.TypeTextIntoField("Color Range", JSON.stringify(colorRange)); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapChartWithColorRange"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("svg") | ||
| .find("path") | ||
| .should("have.attr", "fill", "rgb(0,0,0)"); | ||
|
|
||
| // Change border radius and verify | ||
| propPane.MoveToTab("Style"); | ||
| propPane.EnterJSContext("Border radius", "1.5rem"); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapChartWithBorderRadius"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| EditorNavigation.SelectEntityByName("MapChart1", EntityType.Widget); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("[data-testid='t--map-chart-container']") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we please make this as locator variable? Kindly check all the locators. |
||
| .should("have.css", "border-radius", "24px"); | ||
|
|
||
| // Change box shadow and verify | ||
| const boxShadow = | ||
| "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"; | ||
| propPane.MoveToTab("Style"); | ||
| propPane.EnterJSContext("Box shadow", boxShadow); | ||
| deployMode.DeployApp( | ||
| locators._widgetInDeployed(draggableWidgets.MAPCHART), | ||
| ); | ||
| agHelper.VerifySnapshot(locators._root, "mapChartWithBoxShadow"); | ||
| deployMode.NavigateBacktoEditor(); | ||
| cy.get(publishWidgetspage.mapChartWidget) | ||
| .find("[data-testid='t--map-chart-container']") | ||
| .should( | ||
| "have.css", | ||
| "box-shadow", | ||
| "rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.05) 0px 4px 6px -2px", | ||
| ); | ||
| }); | ||
| }, | ||
| ); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's avoid duplicating code to keep our tests maintainable. 🧹
This code segment appears to be a duplicate of the previous one, performing the same assertion. Having duplicate code is not a good practice as it makes the test suite harder to maintain.
Consider removing this duplicate code segment to keep the test suite clean and maintainable.