Skip to content

Commit

Permalink
feat: enhance plugin schema smoke test (#1261)
Browse files Browse the repository at this point in the history
  • Loading branch information
LiteSun authored Jan 11, 2021
1 parent e5e59e2 commit 61f7c21
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions web/cypress/integration/plugin/schema-smocktest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
/* eslint-disable no-undef */

context('smoke test for plugin schema', () => {
const timeout = 50000;

beforeEach(() => {
cy.login();

Expand All @@ -34,6 +36,7 @@ context('smoke test for plugin schema', () => {
[...cards].forEach((card) => {
const name = card.innerText;
const cases = this.cases[name] || [];
// eslint-disable-next-line consistent-return
cases.forEach(({ shouldValid, data, type = '' }) => {
/**
* NOTE: This test is mainly for GlobalPlugin, which is using non-consumer-type schema.
Expand All @@ -47,35 +50,53 @@ context('smoke test for plugin schema', () => {
.within(() => {
cy.contains('Enable').click({
force: true,
timeout
});
});

// NOTE: wait for the Drawer to appear on the DOM
cy.wait(800);
const switchSelector = '#disable';
cy.get(switchSelector).click();
const drawerSelector = '.ant-drawer-content'
cy.get(drawerSelector).within(() => {
const switchSelector = '#disable';
cy.get(switchSelector).click({
force: true,
timeout
});
});

cy.window().then(({ codemirror }) => {
cy.window().then(({
codemirror
}) => {
if (codemirror) {
codemirror.setValue(JSON.stringify(data));
}
});

cy.contains('Submit').click();
cy.get(drawerSelector).within(() => {
cy.contains('Submit').click({
force: true,
timeout
});
});

// NOTE: wait for the HTTP call
cy.wait(500);
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.get('.anticon-close').click({
force: true,
timeout,
multiple: true,
});
cy.contains('Cancel').click({
force: true,

cy.get(drawerSelector).within(() => {
cy.contains('Cancel').click({
force: true,
timeout,
});
});
}
});
Expand Down

0 comments on commit 61f7c21

Please sign in to comment.