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:30:19 UTC
[apisix-dashboard] branch master updated: chore: refactored test
create-consumer-with-limit-count (#1846)
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 48eeea9 chore: refactored test create-consumer-with-limit-count (#1846)
48eeea9 is described below
commit 48eeea9b52f30f686608e78848f0eb0a065a78e4
Author: Ayush das <ay...@gmail.com>
AuthorDate: Tue May 18 06:00:14 2021 +0530
chore: refactored test create-consumer-with-limit-count (#1846)
---
...e-consumer-with-limit-count-plugin-form.spec.js | 76 +++++++++++++---------
1 file changed, 44 insertions(+), 32 deletions(-)
diff --git a/web/cypress/integration/consumer/create-consumer-with-limit-count-plugin-form.spec.js b/web/cypress/integration/consumer/create-consumer-with-limit-count-plugin-form.spec.js
index 83b4ca3..6e45667 100644
--- a/web/cypress/integration/consumer/create-consumer-with-limit-count-plugin-form.spec.js
+++ b/web/cypress/integration/consumer/create-consumer-with-limit-count-plugin-form.spec.js
@@ -17,17 +17,19 @@
/* eslint-disable no-undef */
context('Create and delete consumer with limit-count plugin form', () => {
- beforeEach(() => {
- cy.login();
-
- cy.fixture('selector.json').as('domSelector');
- cy.fixture('data.json').as('data');
- });
const selector = {
+ 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',
count: '#count',
time_window: '#time_window',
- redis_timeout: '#time_window',
key: '#key',
rejected_code: '#rejected_code',
policy: '#policy',
@@ -35,32 +37,42 @@ context('Create and delete consumer with limit-count plugin form', () => {
redis_port: '#redis_port',
redis_password: '#redis_password',
redis_database: '#redis_database',
- redis_timeout: '#redis_timeout',
redis_cluster_name: '#redis_cluster_name',
redis_cluster_nodes_0: '#redis_cluster_nodes_0',
redis_cluster_nodes_1: '#redis_cluster_nodes_1',
}
+ const data = {
+ consumerName: 'test_consumer',
+ description: 'desc_by_autotest',
+ createConsumerSuccess: 'Create Consumer Successfully',
+ deleteConsumerSuccess: 'Delete Consumer Successfully'
+ }
+
+ beforeEach(() => {
+ cy.login();
+ });
+
it('should create consumer with limit-count 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(
@@ -71,57 +83,57 @@ context('Create and delete consumer with limit-count plugin form', () => {
cy.contains('button', 'Submit').click();
});
- cy.contains(this.domSelector.pluginCard, 'limit-count').within(() => {
+ cy.contains(selector.pluginCard, 'limit-count').within(() => {
cy.contains('Enable').click({
force: true,
});
});
- cy.focused(this.domSelector.drawer).should('exist');
+ cy.focused(selector.drawer).should('exist');
// config limit-count form with local policy
cy.get(selector.count).type(1);
cy.get(selector.time_window).type(1);
cy.get(selector.rejected_code).type(500);
- cy.get(this.domSelector.drawer).within(() => {
+ 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');
// config limit-count form with redis policy
- cy.contains(this.domSelector.pluginCard, 'limit-count').within(() => {
+ cy.contains(selector.pluginCard, 'limit-count').within(() => {
cy.contains('Enable').click({
force: true,
});
});
- cy.focused(this.domSelector.drawer).should('exist');
+ cy.focused(selector.drawer).should('exist');
cy.contains('local').click();
- cy.get(this.domSelector.dropdown).within(() => {
+ cy.get(selector.dropdown).within(() => {
cy.contains('redis').click({
force: true,
});
});
cy.get(selector.redis_host).type('127.0.0.1');
cy.get(selector.redis_password).type('redis_password');
- cy.get(this.domSelector.drawer).within(() => {
+ 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');
// config limit-count form with redis policy
- cy.contains(this.domSelector.pluginCard, 'limit-count').within(() => {
+ cy.contains(selector.pluginCard, 'limit-count').within(() => {
cy.contains('Enable').click({
force: true,
});
});
- cy.focused(this.domSelector.drawer).should('exist');
+ cy.focused(selector.drawer).should('exist');
cy.contains('redis').click();
- cy.get(this.domSelector.dropdown).within(() => {
+ cy.get(selector.dropdown).within(() => {
cy.contains('redis-cluster').click({
force: true,
});
@@ -129,22 +141,22 @@ context('Create and delete consumer with limit-count plugin form', () => {
cy.get(selector.redis_cluster_name).type('redis_cluster_name');
cy.get(selector.redis_cluster_nodes_0).type('127.0.0.1:5000');
cy.get(selector.redis_cluster_nodes_1).type('127.0.0.1:5001');
- cy.get(this.domSelector.drawer).within(() => {
+ 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);
});
});