bubble.test.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 > Bubble', () => {
  20. beforeEach(() => {
  21. cy.intercept('POST', '**/superset/explore_json/**').as('getJson');
  22. });
  23. const BUBBLE_FORM_DATA = {
  24. datasource: '2__table',
  25. viz_type: 'bubble',
  26. slice_id: 46,
  27. granularity_sqla: 'year',
  28. time_grain_sqla: 'P1D',
  29. time_range: '2011-01-01 : 2011-01-02',
  30. series: 'region',
  31. entity: 'country_name',
  32. x: 'sum__SP_RUR_TOTL_ZS',
  33. y: 'sum__SP_DYN_LE00_IN',
  34. size: 'sum__SP_POP_TOTL',
  35. max_bubble_size: '50',
  36. limit: 0,
  37. color_scheme: 'bnbColors',
  38. show_legend: true,
  39. x_axis_label: '',
  40. left_margin: 'auto',
  41. x_axis_format: '.3s',
  42. x_ticks_layout: 'auto',
  43. x_log_scale: false,
  44. x_axis_showminmax: false,
  45. y_axis_label: '',
  46. bottom_margin: 'auto',
  47. y_axis_format: '.3s',
  48. y_log_scale: false,
  49. y_axis_showminmax: false,
  50. };
  51. function verify(formData) {
  52. cy.visitChartByParams(formData);
  53. cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
  54. }
  55. it('should work with filter', () => {
  56. verify({
  57. ...BUBBLE_FORM_DATA,
  58. adhoc_filters: [
  59. {
  60. expressionType: 'SIMPLE',
  61. subject: 'region',
  62. operator: '==',
  63. comparator: 'South Asia',
  64. clause: 'WHERE',
  65. sqlExpression: null,
  66. filterOptionName: 'filter_b2tfg1rs8y_8kmrcyxvsqd',
  67. },
  68. ],
  69. });
  70. cy.get('[data-test="chart-container"]').should('be.visible');
  71. cy.get('[data-test="chart-container"]').within(() => {
  72. cy.get('svg').find('.nv-point-clips circle').should('have.length', 8);
  73. });
  74. cy.get('[data-test="chart-container"]').then(nodeList => {
  75. // Check that all circles have same color.
  76. const color = nodeList[0].getAttribute('fill');
  77. const circles = Array.prototype.slice.call(nodeList);
  78. expect(circles.every(c => c.getAttribute('fill') === color)).to.equal(
  79. true,
  80. );
  81. });
  82. });
  83. it('should allow type to search color schemes and apply the scheme', () => {
  84. cy.visitChartByParams(BUBBLE_FORM_DATA);
  85. cy.get('.Control[data-test="color_scheme"]').scrollIntoView();
  86. cy.get('.Control[data-test="color_scheme"] input[type="search"]').focus();
  87. cy.focused().type('supersetColors{enter}');
  88. cy.get(
  89. '.Control[data-test="color_scheme"] .ant-select-selection-item [data-test="supersetColors"]',
  90. ).should('exist');
  91. cy.get('[data-test=run-query-button]').click();
  92. cy.get('.bubble .nv-legend .nv-legend-symbol').should(
  93. 'have.css',
  94. 'fill',
  95. 'rgb(31, 168, 201)',
  96. );
  97. });
  98. });