You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/07/27 10:04:19 UTC

[GitHub] [apisix-dashboard] foolwc commented on a change in pull request #1982: fix: make service chash key Input inputable and selectable

foolwc commented on a change in pull request #1982:
URL: https://github.com/apache/apisix-dashboard/pull/1982#discussion_r677305462



##########
File path: web/cypress/integration/service/create-service-with-chash-upstream.spec.js
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/* eslint-disable no-undef */
+
+context('Create and Edit Service with custom chash key Upstream', () => {
+  const selector = {
+    name: '#name',
+    description: '#desc',
+    nodes_0_host: '#nodes_0_host',
+    nodes_0_port: '#nodes_0_port',
+    nodes_0_weight: '#nodes_0_weight',
+    upstreamType: ".ant-select-item-option-content",
+    hashPosition: ".ant-select-item-option-content",
+    chash_key: '#key',
+    notification: '.ant-notification-notice-message',
+    nameSearch: '[title=Name]',
+    notificationCloseIcon: '.ant-notification-close-icon',
+  };
+
+  const data = {
+    serviceName: 'chash-service',
+    createServiceSuccess: 'Create Service Successfully',
+    deleteServiceSuccess: 'Delete Service Successfully',
+    editServiceSuccess: 'Configure Service Successfully',
+    port: '80',
+    weight: 1,
+    description: 'desc_by_autotest',
+    ip1: '127.0.0.1',
+    port0: '7000',
+    weight0: '1',
+    custom_key: 'custom_key',
+    new_key: 'new_key',
+  };
+
+  beforeEach(() => {
+    cy.login();
+  });
+
+  it('should create a service with custom chash key Upstream', function () {
+    cy.visit('/');
+    cy.contains('Service').click();
+    cy.contains('Create').click();
+    cy.get(selector.name).type(data.serviceName);
+    cy.get(selector.description).type(data.description);
+    cy.get('[title="Round Robin"]').click();
+    cy.get(selector.upstreamType).within(() => {
+      cy.contains('CHash').click();
+    });
+    cy.get('[title="vars"]').click();
+    cy.get(selector.hashPosition).within(() => {
+      cy.contains('cookie').click();
+    });
+    cy.get('[value="remote_addr"]').click();
+    cy.get('[value="remote_addr"]').clear().type('custom_key');
+    cy.get(selector.nodes_0_host).click();
+    cy.get(selector.nodes_0_host).type(data.ip1);
+    cy.get(selector.nodes_0_port).clear().type(data.port0);
+    cy.get(selector.nodes_0_weight).clear().type(data.weight0);
+    cy.contains('Next').click();
+    cy.contains('Next').click();
+    cy.contains('Submit').click();
+    cy.get(selector.notification).should('contain', data.createServiceSuccess);
+  });
+
+  it('should edit the service', function () {
+    cy.visit('/service/list');
+
+    cy.get(selector.nameSearch).type(data.serviceName);
+    cy.contains('Search').click();
+    cy.contains(data.serviceName).siblings().contains('Configure').click();
+    cy.wait(500);

Review comment:
       Thanks for your invaluable guidance. I copied `cy.wait` from another test file so I just removed it and the test case can  also work. Please help me review my code again. Thanks a lot.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org