service-edit-service-with-upstream.cy.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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('Edit Service with Upstream', () => {
  19. const selector = {
  20. empty: '.ant-empty-normal',
  21. name: '#name',
  22. description: '#desc',
  23. nodes_0_host: '#submitNodes_0_host',
  24. nodes_0_port: '#submitNodes_0_port',
  25. nodes_0_weight: '#submitNodes_0_weight',
  26. notification: '.ant-notification-notice-message',
  27. upstreamSelector: '[data-cy=upstream_selector]',
  28. input: ':input',
  29. nameSearch: '[title=Name]',
  30. };
  31. const data = {
  32. upstreamName: 'test_upstream',
  33. description: 'desc_by_autotest',
  34. ip1: '127.0.0.1',
  35. createUpstreamSuccess: 'Create Upstream Successfully',
  36. serviceName: 'test_service',
  37. createServiceSuccess: 'Create Service Successfully',
  38. ip2: '127.0.0.2',
  39. port: '80',
  40. weight: 1,
  41. editServiceSuccess: 'Configure Service Successfully',
  42. deleteServiceSuccess: 'Delete Service Successfully',
  43. deleteUpstreamSuccess: 'Delete Upstream Successfully',
  44. };
  45. beforeEach(() => {
  46. cy.login();
  47. });
  48. it('should create a test upstream', function () {
  49. cy.visit('/upstream/list');
  50. cy.get(selector.empty).should('be.visible');
  51. cy.contains('Create').click();
  52. cy.get(selector.name).type(data.upstreamName);
  53. cy.get(selector.nodes_0_host).type(data.ip1);
  54. cy.get(selector.nodes_0_port).clear().type('7000');
  55. cy.get(selector.nodes_0_weight).clear().type(1);
  56. cy.contains('Next').click();
  57. cy.contains('Submit').click();
  58. cy.get(selector.notification).should('contain', data.createUpstreamSuccess);
  59. cy.url().should('contains', 'upstream/list');
  60. });
  61. it('should create a test service', function () {
  62. cy.visit('/');
  63. cy.get('.ant-empty').should('be.visible');
  64. cy.contains('Service').click();
  65. cy.get(selector.empty).should('be.visible');
  66. cy.contains('Create').click();
  67. cy.get(selector.name).type(data.serviceName);
  68. cy.get(selector.description).type(data.description);
  69. cy.get(selector.upstreamSelector).click();
  70. cy.contains(data.upstreamName).click();
  71. cy.get(selector.input).should('be.disabled');
  72. cy.contains('Next').click();
  73. cy.contains('Next').click();
  74. cy.contains('Submit').click();
  75. cy.get(selector.notification).should('contain', data.createServiceSuccess);
  76. });
  77. it('should edit the service', function () {
  78. cy.visit('/service/list');
  79. cy.get(selector.nameSearch).type(data.serviceName);
  80. cy.contains('Search').click();
  81. cy.contains(data.serviceName).siblings().contains('Configure').click();
  82. cy.contains(data.upstreamName).click();
  83. cy.wait(500);
  84. cy.contains('.ant-select-item-option-content', 'Custom').click();
  85. cy.get(selector.nodes_0_host)
  86. .click({
  87. force: true,
  88. })
  89. .should('value', data.ip1);
  90. cy.get(selector.input).should('be.disabled');
  91. cy.wait(500);
  92. cy.get(selector.upstreamSelector).click();
  93. cy.get(selector.nodes_0_host).should('not.be.disabled').clear().type(data.ip2);
  94. cy.get(selector.nodes_0_port).type(data.port);
  95. cy.get(selector.nodes_0_weight).type(data.weight);
  96. cy.contains('Next').click();
  97. cy.contains('Next').click();
  98. cy.contains('Submit').click();
  99. cy.get(selector.notification).should('contain', data.editServiceSuccess);
  100. });
  101. it('should delete this service and upstream', function () {
  102. cy.visit('/service/list');
  103. cy.get(selector.nameSearch).type(data.serviceName);
  104. cy.contains('Search').click();
  105. cy.contains(data.serviceName).siblings().contains('Delete').click();
  106. cy.contains('button', 'Confirm').click();
  107. cy.get(selector.notification).should('contain', data.deleteServiceSuccess);
  108. cy.visit('/');
  109. cy.contains('Upstream').click();
  110. cy.contains(data.upstreamName).siblings().contains('Delete').click();
  111. cy.contains('button', 'Confirm').click();
  112. cy.get(selector.notification).should('contain', data.deleteUpstreamSuccess);
  113. });
  114. });