actions.test.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 { SAMPLE_DASHBOARD_1 } from 'cypress/utils/urls';
  20. import { interceptFav, interceptUnfav } from './utils';
  21. describe('Dashboard actions', () => {
  22. beforeEach(() => {
  23. cy.createSampleDashboards([0]);
  24. cy.visit(SAMPLE_DASHBOARD_1);
  25. });
  26. it('should allow to favorite/unfavorite dashboard', () => {
  27. interceptFav();
  28. interceptUnfav();
  29. // Find and click StarOutlined (adds to favorites)
  30. cy.getBySel('dashboard-header-container')
  31. .find("[aria-label='unstarred']")
  32. .as('starIconOutlined')
  33. .should('exist')
  34. .click();
  35. cy.wait('@select');
  36. // After clicking, StarFilled should appear
  37. cy.getBySel('dashboard-header-container')
  38. .find("[aria-label='starred']")
  39. .as('starIconFilled')
  40. .should('exist');
  41. // Verify the color of the filled star (gold)
  42. cy.get('@starIconFilled')
  43. .should('have.css', 'color')
  44. .and('eq', 'rgb(252, 199, 0)');
  45. // Click on StarFilled (removes from favorites)
  46. cy.get('@starIconFilled').click();
  47. cy.wait('@unselect');
  48. // After clicking, StarOutlined should reappear
  49. cy.getBySel('dashboard-header-container')
  50. .find("[aria-label='unstarred']")
  51. .as('starIconOutlinedAfter')
  52. .should('exist');
  53. // Verify the color of the outlined star (gray)
  54. cy.get('@starIconOutlinedAfter')
  55. .should('have.css', 'color')
  56. .and('eq', 'rgba(0, 0, 0, 0.45)');
  57. });
  58. });