Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: route list search query string #1197

Merged
merged 9 commits into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion web/cypress/fixtures/selector.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"notification": ".ant-notification-notice-message"
"dropdown": ".rc-virtual-list",
"notification": ".ant-notification-notice-message",
"drawerBody": ".ant-drawer-wrapper-body"
}
48 changes: 39 additions & 9 deletions web/cypress/integration/route/search-route.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,30 @@ context('Create and Search Route', () => {
beforeEach(() => {
// init login
cy.login();
cy.fixture('selector.json').as('domSelector');
});

it('should create route test1, test2, test3', () => {
it('should create route test1, test2, test3', function () {
// go to route create page
cy.visit('/');
cy.contains('Route').click();
for (let i = 0; i < 3; i++) {
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('#name').type(`test${i}`);
cy.get('#desc').type(`desc${i}`);
cy.get('#hosts_0').type('11.11.11.11');

// config label
cy.contains('Manage').click();

// 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.contains('Confirm').click();
});

cy.contains('Next').click();
cy.wait(400);
cy.get('#nodes_0_host').type('12.12.12.12', {
Expand All @@ -46,7 +59,7 @@ context('Create and Search Route', () => {
}
});

it('should search the route', () => {
it('should search the route with name', () => {
cy.visit('/');
cy.contains('Route').click();
// full match
Expand All @@ -71,15 +84,32 @@ context('Create and Search Route', () => {
cy.contains('test2').should('not.exist');
});

it('should delete the route', () => {
it('should search the route with labels', function () {
cy.visit('/');
cy.contains('Route').click();

// search one label
cy.get('[title=Labels]').click();
cy.wait(500);
cy.get(this.domSelector.dropdown).within(() => {
cy.contains('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');
});

it('should delete the route', function () {
cy.visit('/routes/list');
for (let i = 0; i < 3; i++) {
cy.contains('test' + i)
for (let i = 0; i < 3; i += 1) {
cy.contains(`test${i}`)
.siblings()
.contains('Delete')
.click();
cy.contains('button', 'Confirm').click();
cy.get('.ant-notification-notice-message').should('contain', 'Delete Route Successfully');
cy.get(this.domSelector.notification).should('contain', 'Delete Route Successfully');
cy.wait(300);
}
});
Expand Down
5 changes: 3 additions & 2 deletions web/src/pages/Route/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ export const fetchItem = (rid: number) =>
request(`/routes/${rid}`).then((data) => transformRouteData(data.data));

export const fetchList = ({ current = 1, pageSize = 10, ...res }) => {
const { labels, API_VERSION, status } = res;
const { labels = [], API_VERSION = [], status } = res;

return request<Res<ResListData<RouteModule.ResponseBody>>>('/routes', {
params: {
name: res.name,
uri: res.uri,
label: (labels || []).concat(API_VERSION).join(','),
label: labels.concat(API_VERSION).join(','),
page: current,
page_size: pageSize,
status
Expand Down