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 2020/12/21 03:34:22 UTC

[GitHub] [apisix-dashboard] juzhiyuan commented on a change in pull request #1068: test: add frontend e2e test (create and delete consumer with key-auth)

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



##########
File path: web/cypress/integration/consumer/create_and_delete_consumer.spec.js
##########
@@ -0,0 +1,88 @@
+/*
+ * 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 Delete Consumer', () => {
+        const root_name = `root_${new Date().valueOf()}`;
+      
+        beforeEach(() => {
+          // init login 
+          cy.login();
+        })
+      
+        it('create consumer with key-auth', () => {

Review comment:
       ```suggestion
           it('should create consumer with key-auth', () => {
   ```

##########
File path: web/cypress/integration/consumer/create_and_delete_consumer.spec.js
##########
@@ -0,0 +1,88 @@
+/*
+ * 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 Delete Consumer', () => {
+        const root_name = `root_${new Date().valueOf()}`;
+      
+        beforeEach(() => {
+          // init login 
+          cy.login();
+        })
+      
+        it('create consumer with key-auth', () => {
+          // go to consumer create page
+          cy.visit('/consumer/create');
+          cy.contains('Consumer').click();
+          cy.wait(500);
+          cy.contains('Create').click();
+
+          // Basic Information
+          cy.get('#username').type('autotest_'+root_name);

Review comment:
       format codes

##########
File path: web/cypress/integration/consumer/create_and_delete_consumer.spec.js
##########
@@ -0,0 +1,88 @@
+/*
+ * 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 Delete Consumer', () => {
+        const root_name = `root_${new Date().valueOf()}`;
+      
+        beforeEach(() => {
+          // init login 
+          cy.login();
+        })
+      
+        it('create consumer with key-auth', () => {
+          // go to consumer create page
+          cy.visit('/consumer/create');
+          cy.contains('Consumer').click();
+          cy.wait(500);
+          cy.contains('Create').click();
+
+          // Basic Information
+          cy.get('#username').type('autotest_'+root_name);
+          cy.get('#desc').type('desc_by_autotest');
+          cy.contains('Next').click();
+          cy.wait(300);
+
+          // Plugin Config
+          cy.contains('.ant-card', 'key-auth').within(($form) => {
+            cy.get('button').first().click();
+          })
+          // edit CodeMirror
+          cy.get('.CodeMirror')
+            .first()
+            .then((editor) => {
+              editor[0].CodeMirror.setValue('{"key":"test"}');
+              cy.contains('button', 'Submit').click();
+          });
+          cy.contains('button', 'Next').click();
+          cy.contains('button', 'Submit').click();
+        });
+      
+        it('delete the consumer', () => {
+          cy.visit('/consumer/list');

Review comment:
       no, from Menu on left side.

##########
File path: web/cypress/integration/consumer/create_and_delete_consumer.spec.js
##########
@@ -0,0 +1,88 @@
+/*
+ * 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 Delete Consumer', () => {
+        const root_name = `root_${new Date().valueOf()}`;
+      
+        beforeEach(() => {
+          // init login 
+          cy.login();
+        })
+      
+        it('create consumer with key-auth', () => {

Review comment:
       ```suggestion
           it('creates consumer with key-auth', () => {
   ```

##########
File path: web/cypress/integration/consumer/create_and_delete_consumer.spec.js
##########
@@ -0,0 +1,88 @@
+/*
+ * 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 Delete Consumer', () => {
+        const root_name = `root_${new Date().valueOf()}`;
+      
+        beforeEach(() => {
+          // init login 
+          cy.login();
+        })
+      
+        it('create consumer with key-auth', () => {
+          // go to consumer create page
+          cy.visit('/consumer/create');
+          cy.contains('Consumer').click();
+          cy.wait(500);
+          cy.contains('Create').click();
+
+          // Basic Information
+          cy.get('#username').type('autotest_'+root_name);
+          cy.get('#desc').type('desc_by_autotest');
+          cy.contains('Next').click();
+          cy.wait(300);
+
+          // Plugin Config
+          cy.contains('.ant-card', 'key-auth').within(($form) => {
+            cy.get('button').first().click();
+          })
+          // edit CodeMirror
+          cy.get('.CodeMirror')
+            .first()
+            .then((editor) => {
+              editor[0].CodeMirror.setValue('{"key":"test"}');

Review comment:
       ```js
   JOSN.stringify({
     key: "test"
   })
   ```

##########
File path: web/cypress/integration/consumer/create_and_delete_consumer.spec.js
##########
@@ -0,0 +1,88 @@
+/*
+ * 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 Delete Consumer', () => {
+        const root_name = `root_${new Date().valueOf()}`;
+      
+        beforeEach(() => {
+          // init login 
+          cy.login();
+        })
+      
+        it('create consumer with key-auth', () => {
+          // go to consumer create page
+          cy.visit('/consumer/create');
+          cy.contains('Consumer').click();
+          cy.wait(500);
+          cy.contains('Create').click();
+
+          // Basic Information
+          cy.get('#username').type('autotest_'+root_name);
+          cy.get('#desc').type('desc_by_autotest');
+          cy.contains('Next').click();
+          cy.wait(300);
+
+          // Plugin Config
+          cy.contains('.ant-card', 'key-auth').within(($form) => {
+            cy.get('button').first().click();
+          })
+          // edit CodeMirror
+          cy.get('.CodeMirror')
+            .first()
+            .then((editor) => {
+              editor[0].CodeMirror.setValue('{"key":"test"}');
+              cy.contains('button', 'Submit').click();
+          });
+          cy.contains('button', 'Next').click();
+          cy.contains('button', 'Submit').click();
+        });
+      
+        it('delete the consumer', () => {
+          cy.visit('/consumer/list');
+          cy.contains(root_name).siblings().contains('Delete').click();
+          cy.contains('button', 'Confirm').click();
+          cy.get('.ant-notification-notice-message').should('contain', 'Delete Consumer Successfully');

Review comment:
       All message component has the same class name, please refer it from a global file.
   
   Why not create a file called `constant.ts` under the `cypress` directory, let it contain some global classnames.

##########
File path: web/cypress/integration/consumer/create_and_delete_consumer.spec.js
##########
@@ -0,0 +1,88 @@
+/*
+ * 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 Delete Consumer', () => {
+        const root_name = `root_${new Date().valueOf()}`;
+      
+        beforeEach(() => {
+          // init login 
+          cy.login();
+        })
+      
+        it('create consumer with key-auth', () => {
+          // go to consumer create page
+          cy.visit('/consumer/create');
+          cy.contains('Consumer').click();
+          cy.wait(500);
+          cy.contains('Create').click();
+
+          // Basic Information
+          cy.get('#username').type('autotest_'+root_name);
+          cy.get('#desc').type('desc_by_autotest');
+          cy.contains('Next').click();
+          cy.wait(300);
+
+          // Plugin Config
+          cy.contains('.ant-card', 'key-auth').within(($form) => {
+            cy.get('button').first().click();
+          })
+          // edit CodeMirror
+          cy.get('.CodeMirror')
+            .first()
+            .then((editor) => {
+              editor[0].CodeMirror.setValue('{"key":"test"}');
+              cy.contains('button', 'Submit').click();
+          });
+          cy.contains('button', 'Next').click();
+          cy.contains('button', 'Submit').click();
+        });
+      
+        it('delete the consumer', () => {
+          cy.visit('/consumer/list');
+          cy.contains(root_name).siblings().contains('Delete').click();
+          cy.contains('button', 'Confirm').click();
+          cy.get('.ant-notification-notice-message').should('contain', 'Delete Consumer Successfully');
+        });
+
+        it('create consumer with wrong json', () => {
+          // go to consumer create page
+          cy.visit('/consumer/create');
+          cy.contains('Consumer').click();
+          cy.wait(500);
+          cy.contains('Create').click();
+
+          // Basic Information
+          cy.get('#username').type('autotest_'+root_name);

Review comment:
       If you use VSCode as IDE, please use `command+p` then select `format document` to format codes.

##########
File path: web/cypress/integration/consumer/create_and_delete_consumer.spec.js
##########
@@ -0,0 +1,88 @@
+/*
+ * 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 Delete Consumer', () => {
+        const root_name = `root_${new Date().valueOf()}`;
+      
+        beforeEach(() => {
+          // init login 
+          cy.login();
+        })
+      
+        it('create consumer with key-auth', () => {
+          // go to consumer create page
+          cy.visit('/consumer/create');
+          cy.contains('Consumer').click();
+          cy.wait(500);
+          cy.contains('Create').click();
+
+          // Basic Information
+          cy.get('#username').type('autotest_'+root_name);
+          cy.get('#desc').type('desc_by_autotest');
+          cy.contains('Next').click();
+          cy.wait(300);
+
+          // Plugin Config
+          cy.contains('.ant-card', 'key-auth').within(($form) => {

Review comment:
       `$form` is unused here

##########
File path: web/cypress/integration/consumer/create_and_delete_consumer.spec.js
##########
@@ -0,0 +1,88 @@
+/*
+ * 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 Delete Consumer', () => {
+        const root_name = `root_${new Date().valueOf()}`;
+      
+        beforeEach(() => {
+          // init login 
+          cy.login();
+        })
+      
+        it('create consumer with key-auth', () => {
+          // go to consumer create page
+          cy.visit('/consumer/create');

Review comment:
       
   ![image](https://user-images.githubusercontent.com/2106987/102736248-69363580-437f-11eb-95ae-145f7f092f91.png)
   
   
   Wired

##########
File path: web/cypress/integration/consumer/create_and_delete_consumer.spec.js
##########
@@ -0,0 +1,61 @@
+/*
+ * 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 Delete Consumer', () => {
+        const root_name = `root_${new Date().valueOf()}`;

Review comment:
       Just because the example is not appropriate, you cannot continue to imitate it. If you think it is incorrect here, change it to the correct one.
   
   Please use camelCase in FE, and here should be consumerName or name.

##########
File path: web/cypress/integration/consumer/create_and_delete_consumer.spec.js
##########
@@ -0,0 +1,88 @@
+/*
+ * 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 Delete Consumer', () => {
+        const root_name = `root_${new Date().valueOf()}`;
+      
+        beforeEach(() => {
+          // init login 
+          cy.login();
+        })
+      
+        it('create consumer with key-auth', () => {
+          // go to consumer create page
+          cy.visit('/consumer/create');
+          cy.contains('Consumer').click();
+          cy.wait(500);
+          cy.contains('Create').click();
+
+          // Basic Information
+          cy.get('#username').type('autotest_'+root_name);
+          cy.get('#desc').type('desc_by_autotest');
+          cy.contains('Next').click();
+          cy.wait(300);
+
+          // Plugin Config
+          cy.contains('.ant-card', 'key-auth').within(($form) => {
+            cy.get('button').first().click();
+          })
+          // edit CodeMirror
+          cy.get('.CodeMirror')
+            .first()
+            .then((editor) => {
+              editor[0].CodeMirror.setValue('{"key":"test"}');
+              cy.contains('button', 'Submit').click();
+          });
+          cy.contains('button', 'Next').click();
+          cy.contains('button', 'Submit').click();
+        });
+      
+        it('delete the consumer', () => {
+          cy.visit('/consumer/list');
+          cy.contains(root_name).siblings().contains('Delete').click();
+          cy.contains('button', 'Confirm').click();
+          cy.get('.ant-notification-notice-message').should('contain', 'Delete Consumer Successfully');
+        });
+
+        it('create consumer with wrong json', () => {
+          // go to consumer create page
+          cy.visit('/consumer/create');
+          cy.contains('Consumer').click();
+          cy.wait(500);
+          cy.contains('Create').click();
+
+          // Basic Information
+          cy.get('#username').type('autotest_'+root_name);
+          cy.get('#desc').type('desc_by_autotest');
+          cy.contains('Next').click();
+          cy.wait(300);
+
+          // Plugin Config
+          cy.contains('.ant-card', 'key-auth').within(($form) => {

Review comment:
       ditto




----------------------------------------------------------------
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:
users@infra.apache.org