This is an automated email from the ASF dual-hosted git repository.
juzhiyuan 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 dea4d83 feat: add domSelector and data (#1339)
dea4d83 is described below
commit dea4d83bef1fc0ed72a6d62ff0d209d3541509ed
Author: guoqqqi <[email protected]>
AuthorDate: Thu Jan 21 10:32:08 2021 +0800
feat: add domSelector and data (#1339)
---
web/cypress/integration/route/search-route.spec.js | 80 ++++++++++++++--------
1 file changed, 52 insertions(+), 28 deletions(-)
diff --git a/web/cypress/integration/route/search-route.spec.js
b/web/cypress/integration/route/search-route.spec.js
index 89a635d..da4bde2 100644
--- a/web/cypress/integration/route/search-route.spec.js
+++ b/web/cypress/integration/route/search-route.spec.js
@@ -17,8 +17,34 @@
/* eslint-disable no-undef */
context('Create and Search Route', () => {
+ const timeout = 500;
+ const data = {
+ host1: '11.11.11.11',
+ host2: '12.12.12.12',
+ test: 'test',
+ test0: 'test0',
+ test1: 'test1',
+ test2: 'test2',
+ testx: 'testx',
+ desc0: 'desc0',
+ desc1: 'desc1',
+ desc2: 'desc2',
+ value0: 'value0',
+ label0_value0: 'label0:value0',
+ deleteRouteSuccess: 'Delete Route Successfully',
+ };
+ const domSelector = {
+ name: '#name',
+ desc: '#desc',
+ hosts_0: '#hosts_0',
+ labels_0_labelKey: '#labels_0_labelKey',
+ labels_0_labelValue: '#labels_0_labelValue',
+ nodes_0_host: '#nodes_0_host',
+ searchName: '[title=Name]',
+ searchLabels: '[title=Labels]',
+ };
+
beforeEach(() => {
- // init login
cy.login();
cy.fixture('selector.json').as('domSelector');
});
@@ -29,9 +55,9 @@ context('Create and Search Route', () => {
cy.contains('Route').click();
for (let i = 0; i < 3; i += 1) {
cy.contains('Create').click();
- cy.get('#name').type(`test${i}`);
- cy.get('#desc').type(`desc${i}`);
- cy.get('#hosts_0').type('11.11.11.11');
+ cy.get(domSelector.name).type(`test${i}`);
+ cy.get(domSelector.desc).type(`desc${i}`);
+ cy.get(domSelector.hosts_0).type(data.host1);
// config label
cy.contains('Manage').click();
@@ -39,15 +65,14 @@ context('Create and Search Route', () => {
// eslint-disable-next-line no-loop-func
cy.get(this.domSelector.drawerBody).within(() => {
cy.contains('Add').click();
- cy.get('#labels_0_labelKey').type(`label${i}`);
- cy.get('#labels_0_labelValue').type(`value${i}`);
+ cy.get(domSelector.labels_0_labelKey).type(`label${i}`);
+ cy.get(domSelector.labels_0_labelValue).type(`value${i}`);
cy.contains('Confirm').click();
});
cy.contains('Next').click();
- cy.wait(400);
- cy.get('#nodes_0_host').type('12.12.12.12', {
- timeout: 500,
+ cy.get(domSelector.nodes_0_host).type(data.host2, {
+ timeout,
});
cy.contains('Next').click();
cy.contains('Next').click();
@@ -63,25 +88,25 @@ context('Create and Search Route', () => {
cy.visit('/');
cy.contains('Route').click();
// full match
- cy.get('[title=Name]').type('test1');
+ cy.get(domSelector.searchName).type(data.test1);
cy.contains('Search').click();
- cy.contains('test1').siblings().should('contain', 'desc1');
- cy.contains('test0').should('not.exist');
- cy.contains('test2').should('not.exist');
+ cy.contains(data.test1).siblings().should('contain', data.desc1);
+ cy.contains(data.test0).should('not.exist');
+ cy.contains(data.test2).should('not.exist');
// partial match
cy.reload();
- cy.get('[title=Name]').type('test');
+ cy.get(domSelector.searchName).type(data.test);
cy.contains('Search').click();
- cy.contains('test0').siblings().should('contain', 'desc0');
- cy.contains('test1').siblings().should('contain', 'desc1');
- cy.contains('test2').siblings().should('contain', 'desc2');
+ cy.contains(data.test0).siblings().should('contain', data.desc0);
+ cy.contains(data.test1).siblings().should('contain', data.desc1);
+ cy.contains(data.test2).siblings().should('contain', data.desc2);
// no match
cy.reload();
- cy.get('[title=Name]').type('testx');
+ cy.get(domSelector.searchName).type(data.testx);
cy.contains('Search').click();
- cy.contains('test0').should('not.exist');
- cy.contains('test1').should('not.exist');
- cy.contains('test2').should('not.exist');
+ cy.contains(data.test0).should('not.exist');
+ cy.contains(data.test1).should('not.exist');
+ cy.contains(data.test2).should('not.exist');
});
it('should search the route with labels', function () {
@@ -89,16 +114,16 @@ context('Create and Search Route', () => {
cy.contains('Route').click();
// search one label
- cy.get('[title=Labels]').click();
cy.wait(500);
+ cy.get(domSelector.searchLabels).click();
cy.get(this.domSelector.dropdown).within(() => {
- cy.contains('value0').click();
+ cy.contains(data.value0).click();
});
cy.contains('Search').click();
- cy.contains('test0').siblings().should('contain', 'label0:value0');
- cy.contains('test1').should('not.exist');
- cy.contains('test2').should('not.exist');
+ cy.contains(data.test0).siblings().should('contain', data.label0_value0);
+ cy.contains(data.test1).should('not.exist');
+ cy.contains(data.test2).should('not.exist');
});
it('should delete the route', function () {
@@ -106,8 +131,7 @@ context('Create and Search Route', () => {
for (let i = 0; i < 3; i += 1) {
cy.contains(`test${i}`).siblings().contains('Delete').click();
cy.contains('button', 'Confirm').click();
- cy.get(this.domSelector.notification).should('contain', 'Delete Route
Successfully');
- cy.wait(300);
+ cy.get(this.domSelector.notification).should('contain',
data.deleteRouteSuccess);
}
});
});