Skip to content

Commit

Permalink
feat: improve test cases (#1559)
Browse files Browse the repository at this point in the history
  • Loading branch information
guoqqqi authored Mar 8, 2021
1 parent bf019d6 commit 6dce9e0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
2 changes: 2 additions & 0 deletions web/cypress/fixtures/selector.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@

"fileSelector": "[type=file]",
"fileTypeRadio": "[type=radio]",
"fileSelectorClose": ".ant-modal-close",

"debugUri": "#debugUri",

"hosts_0": "#hosts_0",
"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",
Expand Down
17 changes: 11 additions & 6 deletions web/cypress/integration/route/import_export_route.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
Expand Down
6 changes: 4 additions & 2 deletions web/cypress/integration/route/online-debug.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 4 additions & 7 deletions web/cypress/integration/route/search-route.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
}
});
Expand Down

0 comments on commit 6dce9e0

Please sign in to comment.