pie.test.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 > Pie', () => {
  20. beforeEach(() => {
  21. cy.intercept('POST', '**/api/v1/chart/data*').as('getJson');
  22. });
  23. const PIE_FORM_DATA = {
  24. datasource: '3__table',
  25. viz_type: 'pie',
  26. slice_id: 55,
  27. granularity_sqla: 'ds',
  28. time_grain_sqla: 'P1D',
  29. time_range: '100 years ago : now',
  30. metric: 'sum__num',
  31. adhoc_filters: [],
  32. groupby: ['gender'],
  33. row_limit: 50000,
  34. pie_label_type: 'key',
  35. donut: false,
  36. show_legend: true,
  37. show_labels: true,
  38. labels_outside: true,
  39. color_scheme: 'bnbColors',
  40. };
  41. function verify(formData) {
  42. cy.visitChartByParams(formData);
  43. cy.verifySliceSuccess({ waitAlias: '@getJson' });
  44. }
  45. it('should work with ad-hoc metric', () => {
  46. verify(PIE_FORM_DATA);
  47. cy.get('.chart-container .pie canvas').should('have.length', 1);
  48. });
  49. it('should work with simple filter', () => {
  50. verify({
  51. ...PIE_FORM_DATA,
  52. adhoc_filters: [
  53. {
  54. expressionType: 'SIMPLE',
  55. subject: 'gender',
  56. operator: '==',
  57. comparator: 'boy',
  58. clause: 'WHERE',
  59. sqlExpression: null,
  60. filterOptionName: 'filter_tqx1en70hh_7nksse7nqic',
  61. },
  62. ],
  63. });
  64. cy.get('.chart-container .pie canvas').should('have.length', 1);
  65. });
  66. it('should allow type to search color schemes', () => {
  67. verify(PIE_FORM_DATA);
  68. cy.get('#controlSections-tab-CUSTOMIZE').click();
  69. cy.get('.Control[data-test="color_scheme"]').scrollIntoView();
  70. cy.get('.Control[data-test="color_scheme"] input[type="search"]').focus();
  71. cy.focused().type('supersetColors{enter}');
  72. cy.get(
  73. '.Control[data-test="color_scheme"] .ant-select-selection-item [data-test="supersetColors"]',
  74. ).should('exist');
  75. });
  76. });