Skip to content

Commit

Permalink
test: Remove wait Reduce test time (#1469)
Browse files Browse the repository at this point in the history
  • Loading branch information
guoqqqi authored Feb 22, 2021
1 parent eba0868 commit 8667c28
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 90 deletions.
38 changes: 0 additions & 38 deletions web/cypress/fixtures/plugin-list.json

This file was deleted.

19 changes: 7 additions & 12 deletions web/cypress/integration/plugin/create-edit-delete-plugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,52 +18,47 @@

context('Create and Delete Plugin List', () => {
const timeout = 5000;
const data = {
name: 'hmac-auth',
};

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

cy.fixture('plugin-list.json').as('cases');
cy.fixture('selector.json').as('domSelector');
cy.fixture('data.json').as('data');
cy.fixture('plugin-dataset.json').as('cases');
});

it('should create plugins', function () {
it('should visit plugin market', function () {
cy.visit('/');
cy.contains('Plugin').click();
cy.contains('Create').click();

// add test plugins
cy.get('@cases').then((cases) => {
cy.configurePlugins(cases);
});
});

it('should edit the plugin', function () {
cy.visit('/plugin/list');

cy.get(this.domSelector.refresh).click();
cy.contains(data.name).should('exist').siblings().contains('Edit').click({
force: true,
});
cy.contains('Edit').click();
cy.get(this.domSelector.codemirror)
.first()
.then(() => {
cy.get(this.domSelector.disabledSwitcher).click();
cy.contains('button', 'Submit').click();
});
cy.contains(data.name).should('not.exist');
});

it('should delete plugin list', function () {
cy.visit('/plugin/list');

cy.get(this.domSelector.deleteButton, { timeout }).each(function ($el) {
cy.get(this.domSelector.refresh).click();
cy.get(this.domSelector.deleteButton, { timeout }).should('exist').each(function ($el) {
cy.wrap($el).click().click({ timeout });
cy.contains('button', 'Confirm').click({ force: true });
cy.get(this.domSelector.notification).should('contain', this.data.deletePluginSuccess);
cy.get(this.domSelector.notificationCloseIcon).click();
cy.get(this.domSelector.notificationCloseIcon).click().should('not.exist');
});

// check if plugin list is empty
Expand Down
36 changes: 0 additions & 36 deletions web/cypress/integration/plugin/schema-smocktest.spec.js

This file was deleted.

9 changes: 5 additions & 4 deletions web/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Cypress.Commands.add('configurePlugins', (cases) => {
});

// NOTE: wait for the Drawer to appear on the DOM
cy.wait(300);
cy.focused(domSelectors.drawer).should('exist');
cy.get(domSelectors.drawer, { timeout }).within(() => {
cy.get(domSelectors.switch).click({
force: true,
Expand All @@ -73,20 +73,21 @@ Cypress.Commands.add('configurePlugins', (cases) => {
if (codemirror) {
codemirror.setValue(JSON.stringify(data));
}
cy.get(domSelectors.drawer).should('exist');
cy.get(domSelectors.drawer, { timeout }).within(() => {
cy.contains('Submit').click({
force: true,
});
cy.get(domSelectors.drawer).should('not.exist');
});
});

cy.wait(300);
if (shouldValid === true) {
cy.get(domSelectors.drawer).should('not.exist');
} else if (shouldValid === false) {
cy.get(this.selector.notification).should('contain', 'Invalid plugin data');
cy.get(this.domSelector.notification).should('contain', 'Invalid plugin data');

cy.get(domSelectors.close).click({
cy.get(domSelectors.close).should('be.visible').click({
force: true,
multiple: true,
});
Expand Down

0 comments on commit 8667c28

Please sign in to comment.