sunburst.test.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 > Sunburst', () => {
  20. beforeEach(() => {
  21. cy.intercept('POST', '**/api/v1/chart/data**').as('chartData');
  22. });
  23. const SUNBURST_FORM_DATA = {
  24. datasource: '2__table',
  25. viz_type: 'sunburst_v2',
  26. slice_id: 47,
  27. granularity_sqla: 'year',
  28. time_grain_sqla: 'P1D',
  29. time_range: 'No filter',
  30. columns: ['region'],
  31. metric: 'sum__SP_POP_TOTL',
  32. adhoc_filters: [],
  33. row_limit: 50000,
  34. color_scheme: 'bnbColors',
  35. };
  36. function verify(formData) {
  37. cy.visitChartByParams(formData);
  38. cy.verifySliceSuccess({ waitAlias: '@chartData' });
  39. }
  40. // requires the ability to render charts using SVG only for tests
  41. it.skip('should work without secondary metric', () => {
  42. verify(SUNBURST_FORM_DATA);
  43. cy.get('.chart-container svg g path').should('have.length', 7);
  44. });
  45. // requires the ability to render charts using SVG only for tests
  46. it.skip('should work with secondary metric', () => {
  47. verify({
  48. ...SUNBURST_FORM_DATA,
  49. secondary_metric: 'sum__SP_RUR_TOTL',
  50. });
  51. cy.get('.chart-container svg g path').should('have.length', 7);
  52. });
  53. // requires the ability to render charts using SVG only for tests
  54. it.skip('should work with multiple columns', () => {
  55. verify({
  56. ...SUNBURST_FORM_DATA,
  57. columns: ['region', 'country_name'],
  58. });
  59. cy.get('.chart-container svg g path').should('have.length', 221);
  60. });
  61. // requires the ability to render charts using SVG only for tests
  62. it.skip('should work with filter', () => {
  63. verify({
  64. ...SUNBURST_FORM_DATA,
  65. adhoc_filters: [
  66. {
  67. expressionType: 'SIMPLE',
  68. subject: 'region',
  69. operator: 'IN',
  70. comparator: ['South Asia', 'North America'],
  71. clause: 'WHERE',
  72. sqlExpression: null,
  73. filterOptionName: 'filter_txje2ikiv6_wxmn0qwd1xo',
  74. },
  75. ],
  76. });
  77. cy.get('.chart-container svg g path').should('have.length', 2);
  78. });
  79. it('should allow type to search color schemes', () => {
  80. verify(SUNBURST_FORM_DATA);
  81. cy.get('#controlSections-tab-CUSTOMIZE').click();
  82. cy.get('.Control[data-test="color_scheme"]').scrollIntoView();
  83. cy.get('.Control[data-test="color_scheme"] input[type="search"]').focus();
  84. cy.focused().type('supersetColors{enter}');
  85. cy.get(
  86. '.Control[data-test="color_scheme"] .ant-select-selection-item [data-test="supersetColors"]',
  87. ).should('exist');
  88. });
  89. });