create-route-both-use-uri-uris.cy.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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('Create Route Both use uri and uris', () => {
  19. const selector = {
  20. empty: '.ant-empty-normal',
  21. name: '#name',
  22. description: '#desc',
  23. hosts_0: '#hosts_0',
  24. hosts_1: '#hosts_1',
  25. uris_0: '#uris_0',
  26. uris_1: '#uris_1',
  27. remote_addrs_0: '#remote_addrs_0',
  28. remote_addrs_1: '#remote_addrs_1',
  29. nodes_0_host: '#submitNodes_0_host',
  30. nodes_0_port: '#submitNodes_0_port',
  31. nodes_0_weight: '#submitNodes_0_weight',
  32. nameSelector: '[title=Name]',
  33. drawer: '.ant-drawer-content',
  34. monacoScroll: '.monaco-scrollable-element',
  35. addHost: '[data-cy=addHost]',
  36. addUri: '[data-cy=addUri]',
  37. addRemoteAddr: '[data-cy=addRemoteAddr]',
  38. deleteAlert: '.ant-modal-body',
  39. notificationCloseIcon: '.ant-notification-close-icon',
  40. notification: '.ant-notification-notice-message',
  41. };
  42. const data = {
  43. name: 'test_route',
  44. description: 'desc_by_autotest',
  45. host: '12.12.12.12',
  46. port: '80',
  47. weight: 1,
  48. host_0: '0.0.0.0',
  49. uri_0: '/test',
  50. remote_addr_0: '192.168.1.0',
  51. host_1: '1.1.1.1',
  52. uri_1: '/test1',
  53. remote_addr_1: '192.168.1.1',
  54. submitSuccess: 'Submit Successfully',
  55. deleteRouteSuccess: 'Delete Route Successfully',
  56. };
  57. before(() => {
  58. cy.clearLocalStorageSnapshot();
  59. cy.login();
  60. cy.saveLocalStorage();
  61. });
  62. beforeEach(() => {
  63. cy.restoreLocalStorage();
  64. });
  65. it('should create route with uri/host/remote_addr', () => {
  66. cy.visit('/');
  67. cy.contains('Route').click();
  68. cy.get(selector.empty).should('be.visible');
  69. cy.contains('Create').click();
  70. cy.contains('Next').click().click();
  71. cy.get(selector.name).type(data.name);
  72. cy.get(selector.description).type(data.description);
  73. cy.get(selector.hosts_0).type(data.host_0);
  74. cy.get(selector.uris_0).clear().type(data.uri_0);
  75. cy.get(selector.remote_addrs_0).type(data.remote_addr_0);
  76. cy.contains('Next').click();
  77. cy.get(selector.nodes_0_host).type(data.host);
  78. cy.get(selector.nodes_0_port).type(data.port);
  79. cy.get(selector.nodes_0_weight).type(data.weight);
  80. cy.contains('Next').click();
  81. cy.contains('Next').click();
  82. cy.contains('Submit').click();
  83. cy.contains(data.submitSuccess);
  84. // back to route list page
  85. cy.contains('Goto List').click();
  86. cy.url().should('contains', 'routes/list');
  87. });
  88. it('Raw Data should have uri/host/remote_addr', () => {
  89. cy.visit('/');
  90. cy.contains('Route').click();
  91. cy.get(selector.nameSelector).type(data.name);
  92. cy.contains('Search').click();
  93. cy.contains(data.name).siblings().contains('More').click();
  94. cy.contains('View').click();
  95. cy.get(selector.drawer).should('be.visible');
  96. cy.get(selector.monacoScroll).within(() => {
  97. cy.contains('uri').should('exist');
  98. cy.contains('host').should('exist');
  99. cy.contains('remote_addr').should('exist');
  100. });
  101. });
  102. it('should create route with uris/hosts/remote_addrs', () => {
  103. cy.visit('/');
  104. cy.contains('Route').click();
  105. cy.get(selector.nameSelector).type(data.name);
  106. cy.contains('Search').click();
  107. cy.contains(data.name).siblings().contains('Configure').click();
  108. cy.get('#status').should('have.class', 'ant-switch-checked');
  109. cy.get(selector.hosts_0).should('have.value', data.host_0);
  110. cy.get(selector.uris_0).should('have.value', data.uri_0);
  111. cy.get(selector.remote_addrs_0).should('have.value', data.remote_addr_0);
  112. cy.get(selector.addHost).click();
  113. cy.get(selector.hosts_1).type(data.host_1);
  114. cy.get(selector.addUri).click();
  115. cy.get(selector.uris_1).clear().type(data.uri_1);
  116. cy.get(selector.addRemoteAddr).click();
  117. cy.get(selector.remote_addrs_1).type(data.remote_addr_1);
  118. cy.contains('Next').click();
  119. cy.get(selector.nodes_0_host).type(data.host);
  120. cy.get(selector.nodes_0_port).type(data.port);
  121. cy.get(selector.nodes_0_weight).type(data.weight);
  122. cy.contains('Next').click();
  123. cy.contains('Next').click();
  124. cy.contains('Submit').click();
  125. cy.contains(data.submitSuccess);
  126. // back to route list page
  127. cy.contains('Goto List').click();
  128. cy.url().should('contains', 'routes/list');
  129. });
  130. it('Raw Data should have uris/hosts/remote_addrs', () => {
  131. cy.visit('/');
  132. cy.contains('Route').click();
  133. cy.get(selector.nameSelector).type(data.name);
  134. cy.contains('Search').click();
  135. cy.contains(data.name).siblings().contains('More').click();
  136. cy.contains('View').click();
  137. cy.get(selector.drawer).should('be.visible');
  138. cy.get(selector.monacoScroll).within(() => {
  139. cy.contains('uris').should('exist');
  140. cy.contains('hosts').should('exist');
  141. cy.contains('remote_addrs').should('exist');
  142. });
  143. });
  144. it('confirm the configure view render normally', () => {
  145. cy.visit('/');
  146. cy.contains('Route').click();
  147. cy.get(selector.nameSelector).type(data.name);
  148. cy.contains('Search').click();
  149. cy.contains(data.name).siblings().contains('Configure').click();
  150. cy.get('#status').should('have.class', 'ant-switch-checked');
  151. cy.get(selector.hosts_0).should('have.value', data.host_0);
  152. cy.get(selector.hosts_1).should('have.value', data.host_1);
  153. cy.get(selector.uris_0).should('have.value', data.uri_0);
  154. cy.get(selector.uris_1).should('have.value', data.uri_1);
  155. cy.get(selector.remote_addrs_0).should('have.value', data.remote_addr_0);
  156. cy.get(selector.remote_addrs_1).should('have.value', data.remote_addr_1);
  157. });
  158. it('should delete the route', function () {
  159. cy.visit('/routes/list');
  160. cy.get(selector.name).clear().type(data.name);
  161. cy.contains('Search').click();
  162. cy.contains(data.name).siblings().contains('More').click();
  163. cy.contains('Delete').click();
  164. cy.get(selector.deleteAlert)
  165. .should('be.visible')
  166. .within(() => {
  167. cy.contains('OK').click();
  168. });
  169. cy.get(selector.notification).should('contain', data.deleteRouteSuccess);
  170. cy.get(selector.notificationCloseIcon).click();
  171. });
  172. });