big_number.test.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. describe('Visualization > Big Number with Trendline', () => {
  21. beforeEach(() => {
  22. interceptChart({ legacy: false }).as('chartData');
  23. });
  24. const BIG_NUMBER_FORM_DATA = {
  25. datasource: '2__table',
  26. viz_type: 'big_number',
  27. slice_id: 42,
  28. granularity_sqla: 'year',
  29. time_grain_sqla: 'P1D',
  30. time_range: '2000 : 2014-01-02',
  31. metric: 'sum__SP_POP_TOTL',
  32. adhoc_filters: [],
  33. compare_lag: '10',
  34. compare_suffix: 'over 10Y',
  35. y_axis_format: '.3s',
  36. show_trend_line: true,
  37. start_y_axis_at_zero: true,
  38. color_picker: {
  39. r: 0,
  40. g: 122,
  41. b: 135,
  42. a: 1,
  43. },
  44. };
  45. function verify(formData) {
  46. cy.visitChartByParams(formData);
  47. cy.verifySliceSuccess({
  48. waitAlias: '@chartData',
  49. chartSelector: '.superset-legacy-chart-big-number',
  50. });
  51. }
  52. it('should work', () => {
  53. verify(BIG_NUMBER_FORM_DATA);
  54. cy.get('.chart-container .header-line');
  55. cy.get('.chart-container canvas');
  56. });
  57. it('should work without subheader', () => {
  58. verify({
  59. ...BIG_NUMBER_FORM_DATA,
  60. compare_lag: null,
  61. });
  62. cy.get('.chart-container .header-line');
  63. cy.get('.chart-container .subtitle-line').should('not.exist');
  64. cy.get('.chart-container canvas');
  65. });
  66. it('should not render trendline when hidden', () => {
  67. verify({
  68. ...BIG_NUMBER_FORM_DATA,
  69. show_trend_line: false,
  70. });
  71. cy.get('[data-test="chart-container"] .header-line');
  72. cy.get('[data-test="chart-container"] canvas').should('not.exist');
  73. });
  74. });