_skip.controls.test.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 {
  20. waitForChartLoad,
  21. ChartSpec,
  22. getChartAliasesBySpec,
  23. } from 'cypress/utils';
  24. import { WORLD_HEALTH_DASHBOARD } from 'cypress/utils/urls';
  25. import { WORLD_HEALTH_CHARTS } from './utils';
  26. import { isLegacyResponse } from '../../utils/vizPlugins';
  27. describe.skip('Dashboard top-level controls', () => {
  28. beforeEach(() => {
  29. cy.visit(WORLD_HEALTH_DASHBOARD);
  30. });
  31. // flaky test
  32. it('should allow chart level refresh', () => {
  33. const mapSpec = WORLD_HEALTH_CHARTS.find(
  34. ({ viz }) => viz === 'world_map',
  35. ) as ChartSpec;
  36. waitForChartLoad(mapSpec).then(gridComponent => {
  37. const mapId = gridComponent.attr('data-test-chart-id');
  38. cy.get('[data-test="grid-container"]').find('.world_map').should('exist');
  39. cy.get(`#slice_${mapId}-controls`).click();
  40. cy.get(`[data-test="slice_${mapId}-menu"]`)
  41. .find('[data-test="refresh-chart-menu-item"]')
  42. .click({ force: true });
  43. // likely cause for flakiness:
  44. // The query completes before this assertion happens.
  45. // Solution: pause the network before clicking, assert, then unpause network.
  46. cy.get('[data-test="refresh-chart-menu-item"]').should(
  47. 'have.class',
  48. 'ant-dropdown-menu-item-disabled',
  49. );
  50. waitForChartLoad(mapSpec);
  51. cy.get('[data-test="refresh-chart-menu-item"]').should(
  52. 'not.have.class',
  53. 'ant-dropdown-menu-item-disabled',
  54. );
  55. });
  56. });
  57. it('should allow dashboard level force refresh', () => {
  58. // when charts are not start loading, for example, under a secondary tab,
  59. // should allow force refresh
  60. WORLD_HEALTH_CHARTS.forEach(waitForChartLoad);
  61. getChartAliasesBySpec(WORLD_HEALTH_CHARTS).then(aliases => {
  62. cy.get('[aria-label="ellipsis"]').click();
  63. cy.get('[data-test="refresh-dashboard-menu-item"]').should(
  64. 'not.have.class',
  65. 'ant-dropdown-menu-item-disabled',
  66. );
  67. cy.get('[data-test="refresh-dashboard-menu-item"]').click({
  68. force: true,
  69. });
  70. cy.get('[data-test="refresh-dashboard-menu-item"]').should(
  71. 'have.class',
  72. 'ant-dropdown-menu-item-disabled',
  73. );
  74. // wait all charts force refreshed.
  75. cy.wait(aliases).then(xhrs => {
  76. xhrs.forEach(async ({ response, request }) => {
  77. const responseBody = response?.body;
  78. const isCached = isLegacyResponse(responseBody)
  79. ? responseBody.is_cached
  80. : responseBody.result[0].is_cached;
  81. // request url should indicate force-refresh operation
  82. expect(request.url).to.have.string('force=true');
  83. // is_cached in response should be false
  84. expect(isCached).to.equal(false);
  85. });
  86. });
  87. });
  88. cy.get('[aria-label="ellipsis"]').click();
  89. cy.get('[data-test="refresh-dashboard-menu-item"]').and(
  90. 'not.have.class',
  91. 'ant-dropdown-menu-item-disabled',
  92. );
  93. });
  94. });