-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some tests for Choropleth visualization (#4358)
- Loading branch information
1 parent
b44fa51
commit aa06b32
Showing
7 changed files
with
136 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
client/cypress/integration/visualizations/choropleth_spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* global cy, Cypress */ | ||
|
||
import { createQuery } from '../../support/redash-api'; | ||
|
||
const SQL = ` | ||
SELECT 'AR' AS "code", 'Argentina' AS "name", 37.62 AS "value" UNION ALL | ||
SELECT 'AU' AS "code", 'Australia' AS "name", 37.62 AS "value" UNION ALL | ||
SELECT 'AT' AS "code", 'Austria' AS "name", 42.62 AS "value" UNION ALL | ||
SELECT 'BE' AS "code", 'Belgium' AS "name", 37.62 AS "value" UNION ALL | ||
SELECT 'BR' AS "code", 'Brazil' AS "name", 190.10 AS "value" UNION ALL | ||
SELECT 'CA' AS "code", 'Canada' AS "name", 303.96 AS "value" UNION ALL | ||
SELECT 'CL' AS "code", 'Chile' AS "name", 46.62 AS "value" UNION ALL | ||
SELECT 'CZ' AS "code", 'Czech Republic' AS "name", 90.24 AS "value" UNION ALL | ||
SELECT 'DK' AS "code", 'Denmark' AS "name", 37.62 AS "value" UNION ALL | ||
SELECT 'FI' AS "code", 'Finland' AS "name", 41.62 AS "value" UNION ALL | ||
SELECT 'FR' AS "code", 'France' AS "name", 195.10 AS "value" UNION ALL | ||
SELECT 'DE' AS "code", 'Germany' AS "name", 156.48 AS "value" UNION ALL | ||
SELECT 'HU' AS "code", 'Hungary' AS "name", 45.62 AS "value" UNION ALL | ||
SELECT 'IN' AS "code", 'India' AS "name", 75.26 AS "value" UNION ALL | ||
SELECT 'IE' AS "code", 'Ireland' AS "name", 45.62 AS "value" UNION ALL | ||
SELECT 'IT' AS "code", 'Italy' AS "name", 37.62 AS "value" UNION ALL | ||
SELECT 'NL' AS "code", 'Netherlands' AS "name", 40.62 AS "value" UNION ALL | ||
SELECT 'NO' AS "code", 'Norway' AS "name", 39.62 AS "value" UNION ALL | ||
SELECT 'PL' AS "code", 'Poland' AS "name", 37.62 AS "value" UNION ALL | ||
SELECT 'PT' AS "code", 'Portugal' AS "name", 77.24 AS "value" UNION ALL | ||
SELECT 'ES' AS "code", 'Spain' AS "name", 37.62 AS "value" UNION ALL | ||
SELECT 'SE' AS "code", 'Sweden' AS "name", 38.62 AS "value" UNION ALL | ||
SELECT 'US' AS "code", 'USA' AS "name", 523.06 AS "value" UNION ALL | ||
SELECT 'GB' AS "code", 'United Kingdom' AS "name", 112.86 AS "value" | ||
`; | ||
|
||
describe('Choropleth', () => { | ||
const viewportWidth = Cypress.config('viewportWidth'); | ||
|
||
beforeEach(() => { | ||
cy.login(); | ||
createQuery({ query: SQL }).then(({ id }) => { | ||
cy.visit(`queries/${id}/source`); | ||
cy.getByTestId('ExecuteButton').click(); | ||
}); | ||
}); | ||
|
||
it('creates visualization', () => { | ||
cy.clickThrough(` | ||
NewVisualization | ||
VisualizationType | ||
VisualizationType.CHOROPLETH | ||
`); | ||
|
||
cy.clickThrough(` | ||
Choropleth.EditorTabs.General | ||
Choropleth.Editor.MapType | ||
Choropleth.Editor.MapType.Countries | ||
Choropleth.Editor.KeyColumn | ||
Choropleth.Editor.KeyColumn.name | ||
Choropleth.Editor.KeyType | ||
Choropleth.Editor.KeyType.name | ||
Choropleth.Editor.ValueColumn | ||
Choropleth.Editor.ValueColumn.value | ||
`); | ||
|
||
cy.clickThrough('Choropleth.EditorTabs.Colors'); | ||
cy.clickThrough('Choropleth.Editor.Colors.Min'); | ||
cy.fillInputs({ 'ColorPicker.CustomColor': 'yellow{enter}' }); | ||
cy.wait(100); // eslint-disable-line cypress/no-unnecessary-waiting | ||
cy.clickThrough('Choropleth.Editor.Colors.Max'); | ||
cy.fillInputs({ 'ColorPicker.CustomColor': 'red{enter}' }); | ||
cy.wait(100); // eslint-disable-line cypress/no-unnecessary-waiting | ||
cy.clickThrough('Choropleth.Editor.Colors.Borders'); | ||
cy.fillInputs({ 'ColorPicker.CustomColor': 'black{enter}' }); | ||
cy.wait(100); // eslint-disable-line cypress/no-unnecessary-waiting | ||
|
||
cy.clickThrough(` | ||
Choropleth.EditorTabs.Format | ||
Choropleth.Editor.LegendPosition | ||
Choropleth.Editor.LegendPosition.TopRight | ||
`); | ||
|
||
cy.getByTestId('Choropleth.Editor.LegendTextAlignment.Left').check({ force: true }); | ||
|
||
// Wait for proper initialization of visualization | ||
cy.wait(500); // eslint-disable-line cypress/no-unnecessary-waiting | ||
cy.getByTestId('VisualizationPreview').find('.map-visualization-container.leaflet-container').should('exist'); | ||
cy.percySnapshot('Visualizations - Choropleth', { widths: [viewportWidth] }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters