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 6dce9e0 feat: improve test cases (#1559)
6dce9e0 is described below
commit 6dce9e09640b1c81f14dbb88e5f6f8c43371af31
Author: guoqqqi <[email protected]>
AuthorDate: Mon Mar 8 23:56:16 2021 +0800
feat: improve test cases (#1559)
---
web/cypress/fixtures/selector.json | 2 ++
.../integration/route/import_export_route.spec.js | 17 +++++++++++------
web/cypress/integration/route/online-debug.spec.js | 6 ++++--
web/cypress/integration/route/search-route.spec.js | 11 ++++-------
4 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/web/cypress/fixtures/selector.json
b/web/cypress/fixtures/selector.json
index e7b2abb..61615f2 100644
--- a/web/cypress/fixtures/selector.json
+++ b/web/cypress/fixtures/selector.json
@@ -43,6 +43,7 @@
"fileSelector": "[type=file]",
"fileTypeRadio": "[type=radio]",
+ "fileSelectorClose": ".ant-modal-close",
"debugUri": "#debugUri",
@@ -50,6 +51,7 @@
"labels_0_labelKey": "#labels_0_labelKey",
"labels_0_labelValue": "#labels_0_labelValue",
"labelSelector": "[title=Labels]",
+ "labelSelect_0": ".ant-select-selection-overflow",
"pageContainer": ".ant-pro-page-container",
"notificationMessage": ".ant-notification-notice-message",
diff --git a/web/cypress/integration/route/import_export_route.spec.js
b/web/cypress/integration/route/import_export_route.spec.js
index dcf9c1a..1786b40 100644
--- a/web/cypress/integration/route/import_export_route.spec.js
+++ b/web/cypress/integration/route/import_export_route.spec.js
@@ -45,6 +45,7 @@ context('import and export routes', () => {
cy.fixture('data.json').as('data');
cy.fixture('export-route-dataset.json').as('exportFile');
});
+
it('should create route1 and route2', function () {
cy.visit('/');
// create two routes
@@ -146,24 +147,28 @@ context('import and export routes', () => {
cy.get(this.domSelector.fileSelector).attachFile(file);
// click submit
cy.contains(componentLocaleUS['component.global.confirm']).click();
+
// show upload notification
if (file === 'import-error.txt') {
// show error msg
cy.get(this.domSelector.notificationDesc).should('contain',
data.importErrorMsg);
// close modal
cy.contains(componentLocaleUS['component.global.cancel']).click();
- } else {
+ cy.get(this.domSelector.notificationCloseIcon).click();
+ } else if (file !== 'import-error.txt') {
cy.get(this.domSelector.notification).should(
'contain', 'Success'
);
- cy.get(this.domSelector.notificationCloseIcon).click();
+ cy.get(this.domSelector.fileSelectorClose).click();
+
cy.get(this.domSelector.notificationCloseIcon).click().should('not.exist');
// delete route just imported
- cy.contains(componentLocaleUS['component.global.delete']).click();
- cy.contains(componentLocaleUS['component.global.confirm']).click();
+ cy.reload();
+ cy.get(this.domSelector.deleteButton).should('exist').click();
+ cy.contains('button',
componentLocaleUS['component.global.confirm']).click({ force: true });
+
// show delete successfully notification
cy.get(this.domSelector.notification).should(
- 'contain',
- `${componentLocaleUS['component.global.delete']}
${menuLocaleUS['menu.routes']}
${componentLocaleUS['component.status.success']}`,
+ 'contain', this.data.deleteRouteSuccess
);
cy.get(this.domSelector.notificationCloseIcon).click();
}
diff --git a/web/cypress/integration/route/online-debug.spec.js
b/web/cypress/integration/route/online-debug.spec.js
index b8b1883..f491a1c 100644
--- a/web/cypress/integration/route/online-debug.spec.js
+++ b/web/cypress/integration/route/online-debug.spec.js
@@ -151,8 +151,10 @@ context('Online debug', () => {
cy.contains(routeLocaleUS['page.route.button.send']).click();
// assert: send request return
- cy.get(domSelector.codeMirrorCode).contains('data').should('be.visible');
- cy.get(domSelector.codeMirrorCode).contains('routes').should('be.visible');
+ cy.get(domSelector.codeMirrorCode).within(() => {
+ cy.contains('data').should('be.visible');
+ cy.contains('routes').should('be.visible');
+ });
// close debug drawer
cy.get(this.domSelector.drawerClose).click();
diff --git a/web/cypress/integration/route/search-route.spec.js
b/web/cypress/integration/route/search-route.spec.js
index be3e0c2..9bc2951 100644
--- a/web/cypress/integration/route/search-route.spec.js
+++ b/web/cypress/integration/route/search-route.spec.js
@@ -97,17 +97,14 @@ context('Create and Search Route', () => {
});
it('should search the route with labels', function () {
- cy.visit('/');
- cy.contains('Route').click();
-
+ cy.visit('/routes/list');
// search one label
- cy.get(this.domSelector.refresh).click();
- cy.get(this.domSelector.labelSelector).click();
+ cy.contains(data.test0).should('exist');
+ cy.get(this.domSelector.labelSelect_0).click({ timeout });
cy.get(this.domSelector.dropdown).should('be.visible').within(() => {
cy.contains(data.value0).click();
});
cy.contains('Search').click();
-
cy.contains(data.test0).siblings().should('contain', data.label0_value0);
cy.contains(data.test1).should('not.exist');
cy.contains(data.test2).should('not.exist');
@@ -117,7 +114,7 @@ context('Create and Search Route', () => {
cy.visit('/routes/list');
for (let i = 0; i < 3; i += 1) {
cy.contains(`test${i}`).siblings().contains('Delete').click({ timeout });
- cy.contains('button', 'Confirm').click({ timeout });
+ cy.contains('button', 'Confirm').should('be.visible').click({ timeout });
cy.get(this.domSelector.notification).should('contain',
this.data.deleteRouteSuccess);
}
});