juzhiyuan commented on a change in pull request #1308:
URL: https://github.com/apache/apisix-dashboard/pull/1308#discussion_r559356088



##########
File path: web/cypress/integration/route/create-route-with-upstream.spec.js
##########
@@ -0,0 +1,130 @@
+/*
+ * 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 Route with Upstream', () => {
+  const domSelector = {
+    input: ':input',
+    notification: '.ant-notification-notice-message',
+  };
+  const data = {
+    upstreamName: 'test_upstream',
+    routeName: 'test_route',
+    desc: 'desc_by_autotes',
+    initialIp: '10.89.90.237',
+    testIp: '127.0.0.1',
+    verificationIp: '127.0.0.2',
+    deleteRouteSuccess: 'Delete Route Successfully',
+    deleteUpstreamSuccess: 'Delete successfully',

Review comment:
       We may have a unified specification in the next milestone.

##########
File path: web/cypress/integration/route/create-route-with-upstream.spec.js
##########
@@ -0,0 +1,130 @@
+/*
+ * 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 Route with Upstream', () => {
+  const domSelector = {
+    input: ':input',
+    notification: '.ant-notification-notice-message',
+  };
+  const data = {
+    upstreamName: 'test_upstream',
+    routeName: 'test_route',
+    desc: 'desc_by_autotes',
+    initialIp: '10.89.90.237',
+    testIp: '127.0.0.1',
+    verificationIp: '127.0.0.2',
+    deleteRouteSuccess: 'Delete Route Successfully',
+    deleteUpstreamSuccess: 'Delete successfully',
+  };
+
+  beforeEach(() => {
+    cy.login();
+  });
+
+  it('should create route with upstream', () => {
+    // create a test upstream
+    cy.visit('/');
+    cy.contains('Upstream').click();
+    cy.contains('Create').click();
+
+    cy.get('#name').type(data.upstreamName);
+    cy.get('#desc').type(data.desc);
+    cy.get('#nodes_0_host').type(data.initialIp);
+    cy.contains('Next').click();
+    cy.contains('Submit').click();
+
+    cy.visit('/');
+    cy.contains('Route').click();
+    cy.contains('Create').click();
+
+    cy.get('#name').type(data.routeName);
+    cy.contains('Next').click();
+
+    // select existed upstream_id will be disabled
+    cy.contains('Custom').click();
+    cy.contains(data.upstreamName).click();
+    cy.get(domSelector.input).should('be.disabled');
+
+    // select Custom upstream_id will not be disabled
+    cy.contains(data.upstreamName).click();
+    cy.contains('Custom').click();
+    cy.get(domSelector.input).should('not.be.disabled');
+
+    // change domain name/IP
+    cy.get('#nodes_0_host').clear().type(data.testIp);
+    cy.contains('Next').click();
+    cy.contains('Next').click();
+    cy.contains('Submit').click();
+    cy.contains('Goto List').click();
+    cy.url().should('contains', 'routes/list');
+  });
+
+  it('should edit this route with upstream', () => {
+    cy.visit('/');
+    cy.contains('Route').click();
+
+    // edit existed router
+    cy.get('[title=Name]').type(data.routeName);
+    cy.contains('Search').click();
+    cy.contains(data.routeName).siblings().contains('Edit').click();
+
+    // wait for resource to resolve 
+    cy.wait(500);
+    cy.contains('Next').click();
+
+    // check if the changes have been saved
+    cy.get('#nodes_0_host').should('value', data.testIp);
+
+    cy.get('#upstream_id').click();
+    cy.contains(data.upstreamName).click();
+    cy.get(domSelector.input).should('be.disabled');
+
+    cy.contains('test_upstream').click();

Review comment:
       we should use `data.xxx` here.




----------------------------------------------------------------
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.

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


Reply via email to