Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FE): enhance plugin schema smoke test #1261

Merged
merged 2 commits into from
Jan 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to store the value in a variable first?

how about this style? cy.get('.ant-drawer-content').within

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, we are going to use a public file to store all reuseable selectors in the future.

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