world_map.test.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. describe('Visualization > World Map', () => {
  20. beforeEach(() => {
  21. cy.intercept('POST', '**/superset/explore_json/**').as('getJson');
  22. });
  23. const WORLD_MAP_FORM_DATA = {
  24. datasource: '2__table',
  25. viz_type: 'world_map',
  26. slice_id: 45,
  27. granularity_sqla: 'year',
  28. time_grain_sqla: 'P1D',
  29. time_range: '2014-01-01 : 2014-01-02',
  30. entity: 'country_code',
  31. country_fieldtype: 'cca3',
  32. metric: 'sum__SP_RUR_TOTL_ZS',
  33. adhoc_filters: [],
  34. row_limit: 50000,
  35. show_bubbles: true,
  36. secondary_metric: 'sum__SP_POP_TOTL',
  37. max_bubble_size: '25',
  38. };
  39. function verify(formData) {
  40. cy.visitChartByParams(formData);
  41. cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
  42. }
  43. it('should work with ad-hoc metric', () => {
  44. verify(WORLD_MAP_FORM_DATA);
  45. cy.get('.bubbles circle.datamaps-bubble').should('have.length', 206);
  46. });
  47. it('should work with simple filter', () => {
  48. verify({
  49. ...WORLD_MAP_FORM_DATA,
  50. metric: 'count',
  51. adhoc_filters: [
  52. {
  53. expressionType: 'SIMPLE',
  54. subject: 'region',
  55. operator: '==',
  56. comparator: 'South Asia',
  57. clause: 'WHERE',
  58. sqlExpression: null,
  59. filterOptionName: 'filter_8aqxcf5co1a_x7lm2d1fq0l',
  60. },
  61. ],
  62. });
  63. cy.get('.bubbles circle.datamaps-bubble').should('have.length', 8);
  64. });
  65. it('should hide bubbles when told so', () => {
  66. verify({
  67. ...WORLD_MAP_FORM_DATA,
  68. show_bubbles: false,
  69. });
  70. cy.get('.slice_container').then(containers => {
  71. expect(
  72. containers[0].querySelectorAll('.bubbles circle.datamaps-bubble')
  73. .length,
  74. ).to.equal(0);
  75. });
  76. });
  77. it('should allow type to search color schemes', () => {
  78. verify(WORLD_MAP_FORM_DATA);
  79. cy.get('.Control[data-test="linear_color_scheme"]').scrollIntoView();
  80. cy.get(
  81. '.Control[data-test="linear_color_scheme"] input[type="search"]',
  82. ).focus();
  83. cy.focused().type('greens{enter}');
  84. cy.get(
  85. '.Control[data-test="linear_color_scheme"] .ant-select-selection-item [data-test="greens"]',
  86. ).should('exist');
  87. });
  88. });