From 38dd3ff248deb2917199bd1bce7a1fdb2d1ffa9b Mon Sep 17 00:00:00 2001 From: Levko Kravets Date: Tue, 26 May 2020 10:57:08 +0300 Subject: [PATCH] Fix flaky Map (Markers) tests (#4915) * Fix flaky Map (Markers) tests * Fix flaky Choropleth tests --- .../app/assets/images/fixtures/map-tile.png | Bin 0 -> 5447 bytes .../visualizations/choropleth_spec.js | 6 +-- .../integration/visualizations/map_spec.js | 37 ++++++++---------- .../choropleth/Renderer/index.jsx | 2 +- 4 files changed, 20 insertions(+), 25 deletions(-) create mode 100644 client/app/assets/images/fixtures/map-tile.png diff --git a/client/app/assets/images/fixtures/map-tile.png b/client/app/assets/images/fixtures/map-tile.png new file mode 100644 index 0000000000000000000000000000000000000000..060626296e59499479c5bbf546d53d79f5b5b818 GIT binary patch literal 5447 zcmeHL`9G9z_rHhnF_t2cNtPiY*+Q~q$(G%Oimb^V8Dn23vV?3|vhQ0$)`=KOOl29n z?6NeL#y(-j@SV@|PkeuPp8J>UoY(8R?sH$~ocDR3bH6e%(mBV-#RvevIo*4j_W=Mz z6+r;xAL?S|UFk$!z{tD0W)SKV0(lw>0PLr_n(Af&xrDs+)R~XxqtwM)+I@w$&%6U8 zvYPxoR!;7zm-scIS_J!gkKf(Db=V>{$`%Nrfw_cHNUIQ_Fm-Y28~`Y@KmZ`_1ppL6 z|BHpUYg6X}=yQ=~8P_+0e7Q)R2&52eX9)xR zmvT##an}t^8z%0vg2xLnJl{^v7EW(32=__rji%)y*`xWzGxZs}ck0|hP%a2cc*0V# z0B4rrc$xLi54{WSvaaMriS^k8{i}|w`v|xb8gpoDAmcP9>^=I~6ps(a zK%zQKs|JwA&r7HEW&i-&7-QG0MrcxM`FdjxV1qj30r8Z&lH{Diue29IP!eMdz;;Wp z{}-u{zH8^9mwaiwR0?z!zTf7|MgF`ED8jD+6PD&q^*5sj@iN6Ug&gKIUaeO1VT5pf zR`3TJwHt05pq)QwdNdzw>Rel`Gp8x=XVsU{PD3NxfuUGN&|3%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>B-E({{RS@oP!`uV`T)?y$mD&mzP8{C7FW)xU_W%^4&4 zTU7lRg3fzw8ur|{xT@Q{d|52AaiWZOVb_A^fyWPKj;(tUR(U^G-U#*tGNWlHpr#gX~LdpDA)ig5*P`kOGsReYor~!ZpGZ+AR{wMrDIH5m0T%gq%a0x(B|BM2 { + const viewportWidth = Cypress.config("viewportWidth"); + beforeEach(() => { cy.login(); createQuery({ query: SQL }).then(({ id }) => { @@ -84,8 +86,6 @@ describe("Choropleth", () => { .find(".map-visualization-container.leaflet-container") .should("exist"); - // This is unstable and therefore disabled until a better solution is available. - // const viewportWidth = Cypress.config("viewportWidth"); - // cy.percySnapshot("Visualizations - Choropleth", { widths: [viewportWidth] }); + cy.percySnapshot("Visualizations - Choropleth", { widths: [viewportWidth] }); }); }); diff --git a/client/cypress/integration/visualizations/map_spec.js b/client/cypress/integration/visualizations/map_spec.js index 297e3665..693a6eb9 100644 --- a/client/cypress/integration/visualizations/map_spec.js +++ b/client/cypress/integration/visualizations/map_spec.js @@ -1,15 +1,15 @@ /* global cy */ -import { createQuery } from "../../support/redash-api"; +import { createQuery, createVisualization } from "../../support/redash-api"; const SQL = ` - SELECT 'Israel' AS country, 32.0808800 AS lat, 34.7805700 AS lng UNION ALL + SELECT 'Israel' AS country, 32.0808800 AS lat, 34.7805700 AS lng UNION ALL SELECT 'Israel' AS country, 31.7690400 AS lat, 35.2163300 AS lng UNION ALL SELECT 'Israel' AS country, 32.8184100 AS lat, 34.9885000 AS lng UNION ALL - + SELECT 'Ukraine' AS country, 50.4546600 AS lat, 30.5238000 AS lng UNION ALL - SELECT 'Ukraine' AS country, 49.8382600 AS lat, 24.0232400 AS lng UNION ALL - SELECT 'Ukraine' AS country, 49.9808100 AS lat, 36.2527200 AS lng UNION ALL + SELECT 'Ukraine' AS country, 49.8382600 AS lat, 24.0232400 AS lng UNION ALL + SELECT 'Ukraine' AS country, 49.9808100 AS lat, 36.2527200 AS lng UNION ALL SELECT 'Hungary' AS country, 47.4980100 AS lat, 19.0399100 AS lng `; @@ -19,20 +19,20 @@ describe("Map (Markers)", () => { beforeEach(() => { cy.login(); - createQuery({ query: SQL }).then(({ id }) => { - cy.visit(`queries/${id}/source`); - cy.getByTestId("ExecuteButton").click(); - }); + + const mapTileUrl = "/static/images/fixtures/map-tile.png"; + + createQuery({ query: SQL }) + .then(({ id }) => createVisualization(id, "MAP", "Map (Markers)", { mapTileUrl })) + .then(({ id: visualizationId, query_id: queryId }) => { + cy.visit(`queries/${queryId}/source#${visualizationId}`); + cy.getByTestId("ExecuteButton").click(); + }); }); it("creates Map with groups", () => { cy.clickThrough(` - NewVisualization - VisualizationType - VisualizationType.MAP - `); - - cy.clickThrough(` + EditVisualization VisualizationEditor.Tabs.General Map.Editor.LatitudeColumnName Map.Editor.LatitudeColumnName.lat @@ -64,12 +64,7 @@ describe("Map (Markers)", () => { it("creates Map with custom markers", () => { cy.clickThrough(` - NewVisualization - VisualizationType - VisualizationType.MAP - `); - - cy.clickThrough(` + EditVisualization VisualizationEditor.Tabs.General Map.Editor.LatitudeColumnName Map.Editor.LatitudeColumnName.lat diff --git a/viz-lib/src/visualizations/choropleth/Renderer/index.jsx b/viz-lib/src/visualizations/choropleth/Renderer/index.jsx index 96cada33..0abae34d 100644 --- a/viz-lib/src/visualizations/choropleth/Renderer/index.jsx +++ b/viz-lib/src/visualizations/choropleth/Renderer/index.jsx @@ -53,7 +53,7 @@ export default function Renderer({ data, options, onOptionsChange }) { options // detect changes for all options except bounds, but pass them all! ); } - }, [map, geoJson, data, optionsWithoutBounds]); // eslint-disable-line react-hooks/exhaustive-deps + }, [map, geoJson, data.rows, optionsWithoutBounds]); // eslint-disable-line react-hooks/exhaustive-deps useEffect(() => { if (map) {