You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by li...@apache.org on 2021/05/18 00:29:30 UTC
[apisix-dashboard] branch master updated: chore: refactored test
create-consumer-with-proxy-mirror-form-plugin (#1847)
This is an automated email from the ASF dual-hosted git repository.
liuxiran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new 95fc061 chore: refactored test create-consumer-with-proxy-mirror-form-plugin (#1847)
95fc061 is described below
commit 95fc061b26644a586d2f7f51aa81eaee1fc5d1af
Author: Ayush das <ay...@gmail.com>
AuthorDate: Tue May 18 05:59:21 2021 +0530
chore: refactored test create-consumer-with-proxy-mirror-form-plugin (#1847)
---
.../create-consumer-with-proxy-mirror-form.spec.js | 70 ++++++++++++++--------
1 file changed, 44 insertions(+), 26 deletions(-)
diff --git a/web/cypress/integration/consumer/create-consumer-with-proxy-mirror-form.spec.js b/web/cypress/integration/consumer/create-consumer-with-proxy-mirror-form.spec.js
index 2325ec4..e6f7f6b 100644
--- a/web/cypress/integration/consumer/create-consumer-with-proxy-mirror-form.spec.js
+++ b/web/cypress/integration/consumer/create-consumer-with-proxy-mirror-form.spec.js
@@ -17,38 +17,56 @@
/* eslint-disable no-undef */
context('Create and delete consumer with proxy-mirror plugin form', () => {
- beforeEach(() => {
- cy.login();
-
- cy.fixture('selector.json').as('domSelector');
- cy.fixture('data.json').as('data');
- });
const selector = {
- host: "#host",
- alert: "[role=alert]"
+ empty:'.ant-empty-normal',
+ username: '#username',
+ description: '#desc',
+ pluginCard: '.ant-card',
+ drawer: '.ant-drawer-content',
+ dropdown: '.rc-virtual-list',
+ disabledSwitcher: '#disable',
+ codeMirror: '.CodeMirror',
+ notification: '.ant-notification-notice-message',
+ notificationCloseIcon: '.ant-notification-close-icon',
+ max_age: '#max_age',
+ allow_origins_by_regex: '#allow_origins_by_regex_0',
+ host: '#host',
+ alert: '[role=alert]'
+ }
+
+ const data = {
+ consumerName: 'test_consumer',
+ description: 'desc_by_autotest',
+ createConsumerSuccess: 'Create Consumer Successfully',
+ deleteConsumerSuccess: 'Delete Consumer Successfully',
+ time: 2,
}
+ beforeEach(() => {
+ cy.login();
+ });
+
it('should create consumer with proxy-mirror form', function () {
cy.visit('/');
cy.contains('Consumer').click();
- cy.get(this.domSelector.empty).should('be.visible');
+ cy.get(selector.empty).should('be.visible');
cy.contains('Create').click();
// basic information
- cy.get(this.domSelector.username).type(this.data.consumerName);
- cy.get(this.domSelector.description).type(this.data.description);
+ cy.get(selector.username).type(data.consumerName);
+ cy.get(selector.description).type(data.description);
cy.contains('Next').click();
// config auth plugin
- cy.contains(this.domSelector.pluginCard, 'key-auth').within(() => {
+ cy.contains(selector.pluginCard, 'key-auth').within(() => {
cy.contains('Enable').click({
force: true,
});
});
- cy.focused(this.domSelector.drawer).should('exist');
- cy.get(this.domSelector.disabledSwitcher).click();
+ cy.focused(selector.drawer).should('exist');
+ cy.get(selector.disabledSwitcher).click();
// edit codemirror
- cy.get(this.domSelector.codeMirror)
+ cy.get(selector.codeMirror)
.first()
.then((editor) => {
editor[0].CodeMirror.setValue(
@@ -59,45 +77,45 @@ context('Create and delete consumer with proxy-mirror plugin form', () => {
cy.contains('button', 'Submit').click();
});
- cy.contains(this.domSelector.pluginCard, 'proxy-mirror').within(() => {
+ cy.contains(selector.pluginCard, 'proxy-mirror').within(() => {
cy.contains('Enable').click({
force: true,
});
});
- cy.focused(this.domSelector.drawer).should('exist');
+ cy.focused(selector.drawer).should('exist');
// config proxy-mirror form with wrong host
cy.get(selector.host).type('127.0.0.1:1999');
cy.get(selector.alert).contains('address needs to contain schema: http or https, not URI part');
- cy.get(this.domSelector.drawer).within(() => {
+ cy.get(selector.drawer).within(() => {
cy.contains('Submit').click({
force: true,
});
});
- cy.get(this.domSelector.notification).should('contain', 'Invalid plugin data');
- cy.get(this.domSelector.notificationCloseIcon).click();
+ cy.get(selector.notification).should('contain', 'Invalid plugin data');
+ cy.get(selector.notificationCloseIcon).click();
// config proxy-mirror form with correct host
cy.get(selector.host).clear().type('http://127.0.0.1:1999');
cy.get(selector.alert).should('not.exist');
- cy.get(this.domSelector.disabledSwitcher).click();
- cy.get(this.domSelector.drawer).within(() => {
+ cy.get(selector.disabledSwitcher).click();
+ cy.get(selector.drawer).within(() => {
cy.contains('Submit').click({
force: true,
});
});
- cy.get(this.domSelector.drawer).should('not.exist');
+ cy.get(selector.drawer).should('not.exist');
cy.contains('button', 'Next').click();
cy.contains('button', 'Submit').click();
- cy.get(this.domSelector.notification).should('contain', this.data.createConsumerSuccess);
+ cy.get(selector.notification).should('contain', data.createConsumerSuccess);
});
it('should delete the consumer', function () {
cy.visit('/consumer/list');
- cy.contains(this.data.consumerName).should('be.visible').siblings().contains('Delete').click();
+ cy.contains(data.consumerName).should('be.visible').siblings().contains('Delete').click();
cy.contains('button', 'Confirm').click();
- cy.get(this.domSelector.notification).should('contain', this.data.deleteConsumerSuccess);
+ cy.get(selector.notification).should('contain', data.deleteConsumerSuccess);
});
});