2
0

pluginTemplate-create-plugin-template-with-route.cy.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 PluginTemplate Binding To Route', () => {
  19. const selector = {
  20. empty: '.ant-empty-normal',
  21. description: '#desc',
  22. notification: '.ant-notification-notice-message',
  23. refresh: '.anticon-reload',
  24. descriptionSelector: '[title=Description]',
  25. name: '#name',
  26. nodes_0_host: '#submitNodes_0_host',
  27. nodes_0_port: '#submitNodes_0_port',
  28. nodes_0_weight: '#submitNodes_0_weight',
  29. customSelector: '[title=Custom]',
  30. notificationClose: '.anticon-close',
  31. nameSelector: '[title=Name]',
  32. redirectURIInput: '#redirectURI',
  33. redirectCodeSelector: '#ret_code',
  34. };
  35. const data = {
  36. createPluginTemplateSuccess: 'Create Plugin Template Successfully',
  37. pluginTemplateName: 'test_plugin_template1',
  38. pluginTemplateName2: 'test_plugin_template2',
  39. pluginTemplateErrorAlert: 'Request Error Code: 10000',
  40. routeName: 'test_route',
  41. submitSuccess: 'Submit Successfully',
  42. deletePluginTemplateSuccess: 'Delete Plugin Template Successfully',
  43. deleteRouteSuccess: 'Delete Route Successfully',
  44. ip1: '127.0.0.1',
  45. port: '80',
  46. weight: 1,
  47. };
  48. beforeEach(() => {
  49. cy.login();
  50. });
  51. it('should create test pluginTemplate', function () {
  52. cy.visit('/');
  53. cy.contains('Route').click();
  54. cy.get(selector.empty).should('be.visible');
  55. cy.contains('Advanced').should('be.visible').click();
  56. cy.contains('Advanced').trigger('mouseover');
  57. cy.contains('Plugin Template Config').should('be.visible').click();
  58. cy.get(selector.empty).should('be.visible');
  59. cy.contains('Create').click();
  60. cy.get(selector.description).type(data.pluginTemplateName);
  61. cy.contains('Next').click();
  62. cy.contains('Next').click();
  63. cy.contains('Submit').click();
  64. cy.get(selector.notification).should('contain', data.createPluginTemplateSuccess);
  65. cy.visit('/routes/list');
  66. cy.contains('Create').click();
  67. // NOTE: make sure all components rerender done
  68. cy.contains('Next').click().click();
  69. cy.get(selector.name).type(data.routeName);
  70. cy.contains('Next').click();
  71. cy.get(selector.nodes_0_host).type(data.ip1);
  72. cy.get(selector.nodes_0_port).clear().type(data.port);
  73. cy.get(selector.nodes_0_weight).clear().type(data.weight);
  74. cy.contains('Next').click();
  75. cy.scrollTo(0, 0);
  76. cy.contains('Custom').should('be.visible');
  77. cy.get(selector.customSelector).click();
  78. cy.contains(data.pluginTemplateName).click();
  79. cy.contains('Next').click();
  80. cy.contains('Submit').click();
  81. cy.contains(data.submitSuccess);
  82. cy.contains('Goto List').click();
  83. cy.url().should('contains', 'routes/list');
  84. });
  85. it('should delete the pluginTemplate failure', function () {
  86. cy.visit('plugin-template/list');
  87. cy.get(selector.refresh).click();
  88. cy.get(selector.descriptionSelector).type(data.pluginTemplateName);
  89. cy.contains('button', 'Search').click();
  90. cy.contains(data.pluginTemplateName).siblings().contains('Delete').click();
  91. cy.contains('button', 'Confirm').click();
  92. cy.get(selector.notification).should('contain', data.pluginTemplateErrorAlert);
  93. cy.get(selector.notificationClose).should('be.visible').click();
  94. });
  95. it('should edit the route with pluginTemplate', function () {
  96. cy.visit('routes/list');
  97. cy.get(selector.nameSelector).type(data.routeName);
  98. cy.contains('Search').click();
  99. cy.contains(data.routeName).siblings().contains('Configure').click();
  100. cy.contains('Forbidden').click();
  101. cy.contains('Custom').click();
  102. cy.get(selector.redirectURIInput).clear().type('123');
  103. cy.get(selector.redirectCodeSelector).click();
  104. cy.contains('301(Permanent Redirect)').click();
  105. cy.contains('Next').click();
  106. cy.contains('Submit').click();
  107. cy.contains(data.submitSuccess);
  108. cy.contains('Goto List').click();
  109. cy.url().should('contains', 'routes/list');
  110. });
  111. it('should delete the pluginTemplate successfully', function () {
  112. cy.visit('/routes/list');
  113. cy.get(selector.nameSelector).type(data.routeName);
  114. cy.contains('Search').click();
  115. cy.contains(data.routeName).siblings().contains('More').click();
  116. cy.contains('Delete').should('be.visible').click();
  117. cy.get('.ant-modal-content')
  118. .should('be.visible')
  119. .within(() => {
  120. cy.contains('OK').click();
  121. });
  122. cy.get(selector.notification).should('contain', data.deleteRouteSuccess);
  123. cy.visit('plugin-template/list');
  124. cy.get(selector.refresh).click();
  125. cy.get(selector.descriptionSelector).type(data.pluginTemplateName);
  126. cy.contains('button', 'Search').click();
  127. cy.contains(data.pluginTemplateName).siblings().contains('Delete').click();
  128. cy.contains('button', 'Confirm').click();
  129. cy.get(selector.notification).should('contain', data.deletePluginTemplateSuccess);
  130. });
  131. });