service-create-service-with-service-discovery-upstream.cy.js 4.5 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('Create and Edit Service with Custom CHash Key Upstream', () => {
  19. const selector = {
  20. name: '#name',
  21. description: '#desc',
  22. roundRobinSelect: '[title="Round Robin"]',
  23. upstreamTypeSelect: '[title="Node"]',
  24. discovery_type: '#discovery_type',
  25. service_name: '#service_name',
  26. upstreamType: '.ant-select-item-option-content',
  27. hashPosition: '.ant-select-item-option-content',
  28. discoveryTypeSelect: '.ant-select-item-option-content',
  29. chash_key: '#key',
  30. notification: '.ant-notification-notice-message',
  31. nameSearch: '[title=Name]',
  32. notificationCloseIcon: '.ant-notification-close-icon',
  33. drawer: '.ant-drawer-content',
  34. monacoScroll: '.monaco-scrollable-element',
  35. };
  36. const data = {
  37. createServiceSuccess: 'Create Service Successfully',
  38. deleteServiceSuccess: 'Delete Service Successfully',
  39. editServiceSuccess: 'Configure Service Successfully',
  40. port: '80',
  41. weight: 1,
  42. description: 'desc_by_autotest',
  43. ip1: '127.0.0.1',
  44. port0: '7000',
  45. weight0: '1',
  46. custom_key: 'custom_key',
  47. new_key: 'new_key',
  48. serviceName: 'test.cluster.local',
  49. anotherServiceName: `another.test.cluster.local`,
  50. };
  51. beforeEach(() => {
  52. cy.login();
  53. });
  54. it('should create a service with service discovery Upstream', function () {
  55. cy.visit('/');
  56. cy.contains('Service').click();
  57. cy.contains('Create').click();
  58. cy.get(selector.name).type(data.serviceName);
  59. cy.get(selector.description).type(data.description);
  60. cy.get(selector.upstreamTypeSelect).click();
  61. cy.get(selector.upstreamType).within(() => {
  62. cy.contains('Service Discovery').click();
  63. });
  64. cy.get(selector.discovery_type).click();
  65. cy.get(selector.discoveryTypeSelect).within(() => {
  66. cy.contains('DNS').click();
  67. });
  68. cy.get(selector.service_name).type(data.serviceName);
  69. cy.contains('Next').click();
  70. cy.contains('Next').click();
  71. cy.contains('Submit').click();
  72. cy.get(selector.notification).should('contain', data.createServiceSuccess);
  73. });
  74. it('should edit the service', function () {
  75. cy.visit('/service/list');
  76. cy.get(selector.nameSearch).type(data.serviceName);
  77. cy.contains('Search').click();
  78. cy.contains(data.serviceName).siblings().contains('Configure').click();
  79. cy.wait(1000);
  80. cy.get(selector.name).clear().type(data.anotherServiceName);
  81. // set another service discovery
  82. cy.get(selector.discovery_type).click({ force: true });
  83. cy.get(selector.discoveryTypeSelect).within(() => {
  84. cy.contains('Nacos').click();
  85. });
  86. cy.get(selector.service_name).clear().type(data.anotherServiceName);
  87. cy.contains('Next').click();
  88. cy.contains('Next').click();
  89. cy.contains('Submit').click();
  90. cy.get(selector.notification).should('contain', data.editServiceSuccess);
  91. });
  92. it('should view the test service', function () {
  93. cy.visit('/service/list');
  94. cy.get(selector.nameSearch).type(data.anotherServiceName);
  95. cy.contains('Search').click();
  96. cy.contains(data.anotherServiceName).siblings().contains('View').click();
  97. cy.get(selector.drawer).should('be.visible');
  98. cy.get(selector.monacoScroll).within(() => {
  99. cy.contains('service_name').should('exist');
  100. cy.contains('discovery').should('exist');
  101. });
  102. });
  103. it('should delete this service', function () {
  104. cy.visit('/service/list');
  105. cy.get(selector.nameSearch).type(data.anotherServiceName);
  106. cy.contains('Search').click();
  107. cy.contains(data.anotherServiceName).siblings().contains('Delete').click();
  108. cy.contains('button', 'Confirm').click();
  109. cy.get(selector.notification).should('contain', data.deleteServiceSuccess);
  110. cy.get(selector.notificationCloseIcon).click();
  111. });
  112. });