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/01/06 14:52:26 UTC

[GitHub] [apisix-dashboard] juzhiyuan commented on a change in pull request #1214: feat: added E2E test for plugins

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



##########
File path: web/cypress/integration/plugin/schema-smocktest.spec.js
##########
@@ -0,0 +1,79 @@
+/*
+ * 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('smoke test for plugin schmea', () => {
+  beforeEach(() => {
+    cy.login();
+
+    cy.fixture('selector.json').as('selector');
+    cy.fixture('plugin-dataset.json').as('cases');
+  });
+
+  it('should visit plugin market', function () {
+    cy.visit('/');
+    cy.contains('Plugin').click();
+    cy.contains('Create').click();
+
+    const nameSelector = '[data-cy-plugin-name]';
+    cy.get(nameSelector).then(function (cards) {
+      [...cards].forEach((card) => {
+        const name = card.innerText;
+        const cases = (this.cases[name] || [])
+        cases.forEach(({ shouldValid, data, type = "" }) => {
+          /**
+           * NOTE: This test is mainly for GlobalPlugin, which is using non-consumer-type schema.
+          */
+          if (type === "consumer") {
+            return true
+          }
+
+          cy.contains(name)
+            .parents('.ant-card-bordered')
+            .within(() => {
+              cy.contains('Enable').click({
+                force: true,
+              });
+
+              cy.wait(500);
+            });
+
+          const switchSelector = '#disable';
+          cy.get(switchSelector).click();
+
+          cy.window().then(({ codemirror }) => {
+            if (codemirror) {
+              codemirror.setValue(JSON.stringify(data));
+            }
+          });
+
+          cy.contains('Submit').click();
+
+          if (shouldValid) {
+            const drawerSelector = '.ant-drawer-content';
+            cy.get(drawerSelector).should('not.exist');
+          } else {
+            cy.get(this.selector.notification).should('contain', 'Invalid plugin data');
+            cy.contains('Cancel').click({
+              force: true,
+            });
+          }
+        });
+      });
+    });
+  });
+});

Review comment:
       When I running the E2E test using public manager-api, the disable action has been covered as well :)




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