big_number_total.test.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. import { interceptChart } from 'cypress/utils';
  20. import { FORM_DATA_DEFAULTS, NUM_METRIC } from './shared.helper';
  21. describe('Visualization > Big Number Total', () => {
  22. beforeEach(() => {
  23. interceptChart({ legacy: false }).as('chartData');
  24. });
  25. const BIG_NUMBER_DEFAULTS = {
  26. ...FORM_DATA_DEFAULTS,
  27. viz_type: 'big_number_total',
  28. };
  29. it('Test big number chart with adhoc metric', () => {
  30. const formData = { ...BIG_NUMBER_DEFAULTS, metric: NUM_METRIC };
  31. cy.visitChartByParams(formData);
  32. cy.verifySliceSuccess({
  33. waitAlias: '@chartData',
  34. querySubstring: NUM_METRIC.label,
  35. });
  36. });
  37. it('Test big number chart with simple filter', () => {
  38. const filters = [
  39. {
  40. expressionType: 'SIMPLE',
  41. subject: 'name',
  42. operator: 'IN',
  43. comparator: ['Aaron', 'Amy', 'Andrea'],
  44. clause: 'WHERE',
  45. sqlExpression: null,
  46. filterOptionName: 'filter_4y6teao56zs_ebjsvwy48c',
  47. },
  48. ];
  49. const formData = {
  50. ...BIG_NUMBER_DEFAULTS,
  51. metric: 'count',
  52. adhoc_filters: filters,
  53. };
  54. cy.visitChartByParams(formData);
  55. cy.verifySliceSuccess({ waitAlias: '@chartData' });
  56. });
  57. it('Test big number chart ignores groupby', () => {
  58. const formData = {
  59. ...BIG_NUMBER_DEFAULTS,
  60. metric: NUM_METRIC,
  61. groupby: ['state'],
  62. };
  63. cy.visitChartByParams(formData);
  64. cy.wait(['@chartData']).then(async ({ response }) => {
  65. cy.verifySliceContainer();
  66. const responseBody = response?.body;
  67. expect(responseBody.result[0].query).not.contains(formData.groupby[0]);
  68. });
  69. });
  70. });