create-route-when-not-select-upsteam-id.cy.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 without Upstream', () => {
  19. const selector = {
  20. name: '#name',
  21. nodes_0_host: '#submitNodes_0_host',
  22. nodes_0_port: '#submitNodes_0_port',
  23. nodes_0_weight: '#submitNodes_0_weight',
  24. input: ':input',
  25. nameSelector: '[title=Name]',
  26. deleteAlert: '.ant-modal-body',
  27. notification: '.ant-notification-notice-message',
  28. };
  29. const data = {
  30. routeName: 'test_route',
  31. submitSuccess: 'Submit Successfully',
  32. ip1: '127.0.0.1',
  33. ip2: '127.0.0.2',
  34. port: '80',
  35. weight: 1,
  36. deleteRouteSuccess: 'Delete Route Successfully',
  37. };
  38. beforeEach(() => {
  39. cy.login();
  40. });
  41. it('should create route wittout upstream ', function () {
  42. cy.visit('/');
  43. cy.get('[role=menu]')
  44. .should('be.visible')
  45. .within(() => {
  46. cy.contains('Route').click();
  47. });
  48. cy.contains('Create').click();
  49. cy.contains('Next').click().click();
  50. cy.get(selector.name).type(data.routeName);
  51. cy.contains('Next').click();
  52. cy.get(selector.nodes_0_host).clear().type(data.ip1);
  53. cy.get(selector.nodes_0_port).type(data.port);
  54. cy.get(selector.nodes_0_weight).type(data.weight);
  55. cy.contains('Next').click();
  56. cy.contains('Next').click();
  57. cy.get(selector.input).should('be.disabled');
  58. cy.contains('Submit').click();
  59. cy.contains(data.submitSuccess).should('be.visible');
  60. cy.contains('Goto List').click();
  61. cy.url().should('contains', 'routes/list');
  62. });
  63. it('should edit this route ', function () {
  64. cy.visit('/');
  65. cy.contains('Route').click();
  66. cy.get(selector.nameSelector).type(data.routeName);
  67. cy.contains('Search').click();
  68. cy.contains(data.routeName).siblings().contains('Configure').click();
  69. cy.get(selector.name).should('value', data.routeName);
  70. cy.contains('Next').click({
  71. force: true,
  72. });
  73. // check if the changes have been saved
  74. cy.get(selector.nodes_0_host).should('value', data.ip1);
  75. cy.get(selector.nodes_0_host).clear().type(data.ip2);
  76. cy.get(selector.nodes_0_port).type(data.port);
  77. cy.get(selector.nodes_0_weight).type(data.weight);
  78. cy.contains('Next').click();
  79. cy.contains('Next').click();
  80. cy.get(selector.input).should('be.disabled');
  81. cy.contains('Submit').click();
  82. cy.contains(data.submitSuccess).should('be.visible');
  83. cy.contains('Goto List').click();
  84. cy.url().should('contains', 'routes/list');
  85. // check if the changes have been saved
  86. cy.get(selector.nameSelector).type(data.routeName);
  87. cy.contains('Search').click();
  88. cy.contains(data.routeName).siblings().contains('Configure').click();
  89. // ensure it has already changed to edit page
  90. cy.get(selector.name).should('value', data.routeName);
  91. cy.contains('Next').click({
  92. force: true,
  93. });
  94. cy.get(selector.nodes_0_host).should('value', data.ip2);
  95. });
  96. it('should delete this test route', function () {
  97. cy.visit('/routes/list');
  98. cy.get(selector.nameSelector).type(data.routeName);
  99. cy.contains('Search').click();
  100. cy.contains(data.routeName).siblings().contains('More').click();
  101. cy.contains('Delete').click();
  102. cy.get(selector.deleteAlert)
  103. .should('be.visible')
  104. .within(() => {
  105. cy.contains('OK').click();
  106. });
  107. cy.get(selector.notification).should('contain', data.deleteRouteSuccess);
  108. });
  109. });