guoqqqi commented on code in PR #2502:
URL: https://github.com/apache/apisix-dashboard/pull/2502#discussion_r938541872


##########
web/cypress/integration/route/batch-delete-route.spec.js:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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 */
+
+context('Create and Batch Deletion Routes', () => {
+  const timeout = 5000;
+
+  const selector = {
+    name: '#name',
+    description: '#desc',
+    hosts_0: '#hosts_0',
+    uris_0: '#uris_0',
+    labels_0_labelKey: '#labels_0_labelKey',
+    labels_0_labelValue: '#labels_0_labelValue',
+    nodes_0_host: '#submitNodes_0_host',
+    nodes_0_port: '#submitNodes_0_port',
+    nodes_0_weight: '#submitNodes_0_weight',
+    drawerBody: '.ant-drawer-wrapper-body',
+    notification: '.ant-notification-notice-message',
+    notificationClose: '.anticon-close',
+  };
+
+  const data = {
+    host1: '11.11.11.11',
+    host2: '12.12.12.12',
+    port: '80',
+    weight: 1,
+    uris: '/get',
+    uris0: '/get0',
+    uris1: '/get1',
+    uris2: '/get2',
+    urisx: '/getx',
+    submitSuccess: 'Submit Successfully',
+    deleteRouteSuccess: 'Delete Route Successfully',
+    test: 'test',
+    test0: 'test0',
+    test1: 'test1',
+    test2: 'test2',
+    testx: 'testx',
+    value0: 'value0',
+    label0_value0: 'label0:value0',
+  };
+
+  beforeEach(() => {
+    cy.login();
+  });
+
+  it('should create route test0, test1, test2', function () {
+    cy.visit('/');
+    cy.contains('Route').click();
+    for (let i = 0; i < 3; i += 1) {
+      cy.contains('Create').click();
+      cy.contains('Next').click().click();
+      cy.get(selector.name).type(`test${i}`);
+      cy.get(selector.description).type(`desc${i}`);
+      cy.get(selector.hosts_0).type(data.host1);
+      cy.get(selector.uris_0).clear().type(`/get${i}`);
+
+      // config label
+      cy.contains('Manage').click();
+
+      // eslint-disable-next-line no-loop-func
+      cy.get(selector.drawerBody).within(() => {
+        cy.contains('button', 'Add')
+          .should('not.be.disabled')
+          .click()
+          .then(() => {
+            cy.get(selector.labels_0_labelKey).type(`label${i}`);
+            cy.get(selector.labels_0_labelValue).type(`value${i}`);
+            cy.contains('Confirm').click();
+          });
+      });
+
+      cy.contains('button', 'Next').should('not.be.disabled').click();
+      cy.get(selector.nodes_0_host).type(data.host2, {
+        timeout,
+      });
+      cy.get(selector.nodes_0_port).type(data.port);
+      cy.get(selector.nodes_0_weight).type(data.weight);
+      cy.contains('Next').click();
+      cy.contains('Next').click();
+      cy.contains('Submit').click();
+      cy.contains(data.submitSuccess);
+      cy.contains('Goto List').click();
+      cy.url().should('contains', 'routes/list');
+    }

Review Comment:
   It is best to assert that 3 corresponding routes were successfully created



##########
web/cypress/integration/route/batch-delete-route.spec.js:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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 */
+
+context('Create and Batch Deletion Routes', () => {
+  const timeout = 5000;
+
+  const selector = {
+    name: '#name',
+    description: '#desc',
+    hosts_0: '#hosts_0',
+    uris_0: '#uris_0',
+    labels_0_labelKey: '#labels_0_labelKey',
+    labels_0_labelValue: '#labels_0_labelValue',
+    nodes_0_host: '#submitNodes_0_host',
+    nodes_0_port: '#submitNodes_0_port',
+    nodes_0_weight: '#submitNodes_0_weight',
+    drawerBody: '.ant-drawer-wrapper-body',
+    notification: '.ant-notification-notice-message',
+    notificationClose: '.anticon-close',
+  };
+
+  const data = {
+    host1: '11.11.11.11',
+    host2: '12.12.12.12',
+    port: '80',
+    weight: 1,
+    uris: '/get',
+    uris0: '/get0',
+    uris1: '/get1',
+    uris2: '/get2',
+    urisx: '/getx',
+    submitSuccess: 'Submit Successfully',
+    deleteRouteSuccess: 'Delete Route Successfully',
+    test: 'test',
+    test0: 'test0',
+    test1: 'test1',
+    test2: 'test2',
+    testx: 'testx',
+    value0: 'value0',
+    label0_value0: 'label0:value0',
+  };
+
+  beforeEach(() => {
+    cy.login();
+  });
+
+  it('should create route test0, test1, test2', function () {
+    cy.visit('/');
+    cy.contains('Route').click();
+    for (let i = 0; i < 3; i += 1) {
+      cy.contains('Create').click();
+      cy.contains('Next').click().click();
+      cy.get(selector.name).type(`test${i}`);
+      cy.get(selector.description).type(`desc${i}`);
+      cy.get(selector.hosts_0).type(data.host1);
+      cy.get(selector.uris_0).clear().type(`/get${i}`);
+
+      // config label
+      cy.contains('Manage').click();
+
+      // eslint-disable-next-line no-loop-func
+      cy.get(selector.drawerBody).within(() => {
+        cy.contains('button', 'Add')
+          .should('not.be.disabled')
+          .click()
+          .then(() => {
+            cy.get(selector.labels_0_labelKey).type(`label${i}`);
+            cy.get(selector.labels_0_labelValue).type(`value${i}`);
+            cy.contains('Confirm').click();
+          });
+      });
+
+      cy.contains('button', 'Next').should('not.be.disabled').click();
+      cy.get(selector.nodes_0_host).type(data.host2, {
+        timeout,
+      });
+      cy.get(selector.nodes_0_port).type(data.port);
+      cy.get(selector.nodes_0_weight).type(data.weight);
+      cy.contains('Next').click();
+      cy.contains('Next').click();
+      cy.contains('Submit').click();
+      cy.contains(data.submitSuccess);
+      cy.contains('Goto List').click();
+      cy.url().should('contains', 'routes/list');
+    }
+  });
+
+  it('should delete the route', function () {
+    cy.visit('/routes/list');
+    cy.contains(data.test0).get('[type="checkbox"]').check();
+    cy.contains(data.test2).get('[type="checkbox"]').check();
+    cy.contains('BatchDeletion Routes').should('be.visible').click({ timeout 
});
+    cy.get(selector.notification).should('contain', data.deleteRouteSuccess);
+    cy.get(selector.notificationClose).should('be.visible').click({
+      force: true,
+      multiple: true,
+    });
+  });

Review Comment:
   It is better to add an assertion to prove that all data has been deleted



##########
web/src/pages/Route/List.tsx:
##########
@@ -542,6 +545,33 @@ const Page: React.FC = () => {
         actionRef={ref}
         rowKey="id"
         columns={columns}
+        rowSelection={rowSelection}
+        tableAlertRender={() => (
+          <Space size={24}>
+            <span>
+            {formatMessage({ id: 'page.route.chosen' })} 
{selectedRowKeys.length} {formatMessage({ id: 'page.route.item' })}
+            </span>
+          </Space>
+        )}
+        tableAlertOptionRender={() => {
+          return (
+            <Space size={16}>
+              <Button
+               onClick={async () => {
+               await remove(selectedRowKeys).then(() => {
+                handleTableActionSuccessResponse(
+                  `${formatMessage({ id: 'component.global.delete' })} 
${formatMessage({
+                    id: 'menu.routes',
+                  })} ${formatMessage({ id: 'component.status.success' })}`,

Review Comment:
   It is better not to use this method for internationalization, Chinese and 
English are hardly compatible at the same time



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to