gauge.test.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 > Gauge', () => {
  20. beforeEach(() => {
  21. cy.intercept('POST', '**/api/v1/chart/data*').as('getJson');
  22. });
  23. const GAUGE_FORM_DATA = {
  24. datasource: '3__table',
  25. viz_type: 'gauge_chart',
  26. metric: 'count',
  27. adhoc_filters: [],
  28. slice_id: 54,
  29. row_limit: 10,
  30. };
  31. function verify(formData) {
  32. cy.visitChartByParams(formData);
  33. cy.verifySliceSuccess({ waitAlias: '@getJson' });
  34. }
  35. it('should work', () => {
  36. verify(GAUGE_FORM_DATA);
  37. cy.get('.chart-container .gauge_chart canvas').should('have.length', 1);
  38. });
  39. it('should work with simple filter', () => {
  40. verify({
  41. ...GAUGE_FORM_DATA,
  42. adhoc_filters: [
  43. {
  44. expressionType: 'SIMPLE',
  45. subject: 'country_code',
  46. operator: '==',
  47. comparator: 'USA',
  48. clause: 'WHERE',
  49. sqlExpression: null,
  50. isExtra: false,
  51. isNew: false,
  52. filterOptionName: 'filter_jaemvkxd5h_ku22m3wyo',
  53. },
  54. ],
  55. });
  56. cy.get('.chart-container .gauge_chart canvas').should('have.length', 1);
  57. });
  58. it('should allow type to search color schemes', () => {
  59. verify(GAUGE_FORM_DATA);
  60. cy.get('#controlSections-tab-CUSTOMIZE').click();
  61. cy.get('.Control[data-test="color_scheme"]').scrollIntoView();
  62. cy.get('.Control[data-test="color_scheme"] input[type="search"]').focus();
  63. cy.focused().type('bnbColors{enter}');
  64. cy.get(
  65. '.Control[data-test="color_scheme"] .ant-select-selection-item [data-test="bnbColors"]',
  66. ).should('exist');
  67. });
  68. });