settings-smoketest.cy.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* eslint-disable no-undef */
  18. context('settings page smoke test', () => {
  19. const selector = {
  20. avatar: '.ant-space-align-center',
  21. pageContainer: '.ant-pro-page-container',
  22. grafanaURL: '#grafanaURL',
  23. notificationMessage: '.ant-notification-notice-message',
  24. explain: '.ant-form-item-explain',
  25. };
  26. const data = {
  27. invalidURL: 'httx://www.test.com',
  28. validURL: 'http://localhost:8000/routes/list',
  29. fetchURL: 'fetchURL',
  30. fetch: '@fetchURL',
  31. grafanaAddress: 'Grafana Address',
  32. grafanaExplanation1: 'Grafana address should begin with HTTP or HTTPS',
  33. grafanaExplanation2: 'Address is invalid',
  34. updateSuccessfully: 'Update Configuration Successfully',
  35. };
  36. beforeEach(() => {
  37. cy.login();
  38. });
  39. it('should visit settings page', function () {
  40. cy.visit('/');
  41. cy.get(selector.avatar).invoke('show').click('center');
  42. cy.contains('Settings').click();
  43. cy.url().should('contains', '/settings');
  44. cy.get(selector.pageContainer)
  45. .children()
  46. .should('contain', 'Setting')
  47. .and('contain', data.grafanaAddress)
  48. .and('contain', data.grafanaExplanation1);
  49. });
  50. it('should set a invalid url', function () {
  51. cy.visit('/');
  52. cy.get(selector.avatar).invoke('show').click('center');
  53. cy.contains('Settings').click();
  54. cy.url().should('contains', '/settings');
  55. cy.get(selector.grafanaURL).clear().type(data.invalidURL);
  56. cy.get(selector.explain).should('contain', data.grafanaExplanation2);
  57. });
  58. it('should set a accessible URL', function () {
  59. cy.visit('/');
  60. cy.get(selector.avatar).invoke('show').click('center');
  61. cy.contains('Settings').click();
  62. cy.url().should('contains', '/settings');
  63. cy.get(selector.grafanaURL).clear().type(data.validURL);
  64. cy.contains('Submit').click();
  65. cy.get(selector.notificationMessage).should('contain', data.updateSuccessfully);
  66. cy.intercept(data.validURL).as(data.fetchURL);
  67. cy.wait(data.fetch);
  68. cy.get(selector.pageContainer).children().should('contain', 'Dashboard');
  69. });
  70. });