2
0

create-route-with-chash-upstream.cy.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 and Edit Route With Custom CHash Key Upstream', () => {
  19. const selector = {
  20. name: '#name',
  21. menu: '[role=menu]',
  22. roundRobinSelect: '[title="Round Robin"]',
  23. varSelect: '[title="vars"]',
  24. defaultCHashKey: '[value="remote_addr"]',
  25. upstreamType: '.ant-select-item-option-content',
  26. hashPosition: '.ant-select-item-option-content',
  27. nodes_0_host: '#submitNodes_0_host',
  28. nodes_0_port: '#submitNodes_0_port',
  29. nodes_0_weight: '#submitNodes_0_weight',
  30. nameSelector: '[title=Name]',
  31. chash_key: '#key',
  32. deleteAlert: '.ant-modal-body',
  33. notificationCloseIcon: '.ant-notification-close-icon',
  34. notification: '.ant-notification-notice-message',
  35. };
  36. const data = {
  37. routeName: 'roteName',
  38. ip: '127.0.0.1',
  39. port: '7000',
  40. weight: '1',
  41. deleteRouteSuccess: 'Delete Route Successfully',
  42. submitSuccess: 'Submit Successfully',
  43. custom_key: 'custom_key',
  44. new_key: 'new_key',
  45. };
  46. beforeEach(() => {
  47. cy.login();
  48. });
  49. it('should create route with custom chash key Upstream', function () {
  50. cy.visit('/');
  51. cy.get(selector.menu)
  52. .should('be.visible')
  53. .within(() => {
  54. cy.contains('Route').click();
  55. });
  56. cy.contains('Create').click();
  57. cy.contains('Next').click().click();
  58. cy.get(selector.name).type(data.routeName);
  59. cy.contains('Next').click();
  60. cy.get(selector.roundRobinSelect).click();
  61. cy.get(selector.upstreamType).within(() => {
  62. cy.contains('CHash').click();
  63. });
  64. cy.get(selector.varSelect).click();
  65. cy.get(selector.hashPosition).within(() => {
  66. cy.contains('cookie').click();
  67. });
  68. cy.get(selector.defaultCHashKey).click();
  69. cy.get(selector.defaultCHashKey).clear().type(data.custom_key);
  70. cy.get(selector.nodes_0_host).click();
  71. cy.get(selector.nodes_0_host).type(data.ip);
  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.contains('Next').click();
  76. cy.contains('Submit').click();
  77. cy.contains(data.submitSuccess).should('be.visible');
  78. // back to route list page
  79. cy.contains('Goto List').click();
  80. cy.url().should('contains', 'routes/list');
  81. });
  82. it('should edit this route ', function () {
  83. cy.visit('/');
  84. cy.contains('Route').click();
  85. cy.get(selector.nameSelector).type(data.routeName);
  86. cy.contains('Search').click();
  87. cy.contains(data.routeName).siblings().contains('Configure').click();
  88. cy.get(selector.name).should('value', data.routeName);
  89. cy.contains('Next').click({
  90. force: true,
  91. });
  92. cy.get(selector.chash_key).should('value', data.custom_key);
  93. cy.get(selector.chash_key).clear().type(data.new_key);
  94. cy.contains('Next').click();
  95. cy.contains('Next').click();
  96. cy.contains('Submit').click();
  97. cy.contains(data.submitSuccess).should('be.visible');
  98. });
  99. it('should delete the route', function () {
  100. cy.visit('/routes/list');
  101. cy.get(selector.name).clear().type(data.routeName);
  102. cy.contains('Search').click();
  103. cy.contains(data.routeName).siblings().contains('More').click();
  104. cy.contains('Delete').click();
  105. cy.get(selector.deleteAlert)
  106. .should('be.visible')
  107. .within(() => {
  108. cy.contains('OK').click();
  109. });
  110. cy.get(selector.notification).should('contain', data.deleteRouteSuccess);
  111. cy.get(selector.notificationCloseIcon).click({ multiple: true });
  112. });
  113. });