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

test: add edit the plugin #1372

Merged
merged 25 commits into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from 10 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
4 changes: 3 additions & 1 deletion web/cypress/integration/lang/switch-language.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ context('Switch language', () => {

cy.get(domSelector.switcher).click('right');
cy.contains('简体中文').click({
force: true,
timeout,
});
cy.contains('服务').click();

cy.get(domSelector.switcher).click('right');
cy.contains('English').click({
force: true,
timeout,
});
cy.contains('Create');
cy.contains('Create').should('exist');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@

context('Create and Delete Plugin List', () => {
const timeout = 5000;
const domSelectors = {
const data = {
name: 'api-breaker',
};
const domSelector = {
tableCell: '.ant-table-cell',
empty: '.ant-empty-normal',
refresh: '.anticon-reload',
codemirror: '.CodeMirror',
switch: '#disable',
};

beforeEach(() => {
Expand All @@ -37,13 +42,30 @@ context('Create and Delete Plugin List', () => {

// add test plugins
cy.configurePlugins(this.cases);
cy.wait(200);
juzhiyuan marked this conversation as resolved.
Show resolved Hide resolved
});

it('should edit the plugin', () => {
cy.visit('/');
cy.contains('Plugin').click();
cy.contains(data.name).siblings().contains('Edit').click({
force: true,
});
cy.get(domSelector.codemirror)
.first()
.then(() => {
cy.get(domSelector.switch).click();
cy.contains('button', 'Submit').click();
});
cy.contains(data.name).should('not.exist');
});

it('should delete plugin list', () => {
cy.visit('/');
cy.contains('Plugin').click();
cy.get(domSelectors.refresh).click();
cy.get(domSelectors.tableCell).then(function (rows) {

cy.get(domSelector.refresh).click();
cy.get(domSelector.tableCell, { timeout }).should('exist').then(function (rows) {
liuxiran marked this conversation as resolved.
Show resolved Hide resolved
[...rows].forEach((row) => {
const name = row.innerText;
const cases = this.cases[name] || [];
Expand All @@ -56,6 +78,6 @@ context('Create and Delete Plugin List', () => {
});

// check if plugin list is empty
cy.get(domSelectors.empty);
cy.get(domSelector.empty).should('be.visible');
});
});
8 changes: 4 additions & 4 deletions web/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Cypress.Commands.add('configurePlugins', (cases) => {
close: '.anticon-close',
};

cy.get(domSelectors.name).then(function (cards) {
cy.get(domSelectors.name, { timeout }).then(function (cards) {
[...cards].forEach((card) => {
const name = card.innerText;
const pluginCases = cases[name] || [];
Expand All @@ -61,7 +61,7 @@ Cypress.Commands.add('configurePlugins', (cases) => {
});

// NOTE: wait for the Drawer to appear on the DOM
cy.get(domSelectors.drawer, { timeout }).within(() => {
cy.get(domSelectors.drawer, { timeout }).invoke('show').within(() => {
cy.get(domSelectors.switch).click({
force: true,
timeout,
Expand All @@ -74,7 +74,7 @@ Cypress.Commands.add('configurePlugins', (cases) => {
}
});

cy.get(domSelectors.drawer).within(() => {
cy.get(domSelectors.drawer, { timeout }).within(() => {
cy.contains('Submit').click({
force: true,
timeout,
Expand All @@ -92,7 +92,7 @@ Cypress.Commands.add('configurePlugins', (cases) => {
multiple: true,
});

cy.get(domSelectors.drawer).within(() => {
cy.get(domSelectors.drawer, { timeout }).invoke('show').within(() => {
cy.contains('Cancel').click({
force: true,
timeout,
Expand Down