Skip to content

fix: Dashboard can not search route from hosts name #2807

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

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 3 additions & 0 deletions api/internal/handler/route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ func (h *Handler) List(c droplet.Context) (interface{}, error) {
}

if input.Host != "" && !strings.Contains(obj.(*entity.Route).Host, input.Host) {
if strings.Contains(strings.Join(obj.(*entity.Route).Hosts, ""), input.Host) {
return true
}
return false
}

Expand Down
33 changes: 33 additions & 0 deletions web/cypress/e2e/route/search-route.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ context('Create and Search Route', () => {
name: '#name',
description: '#desc',
hosts_0: '#hosts_0',
hosts_1: '#hosts_1',
add_host: 'button[data-cy="addHost"]',
uris_0: '#uris_0',
labels_0_labelKey: '#labels_0_labelKey',
labels_0_labelValue: '#labels_0_labelValue',
nodes_0_host: '#submitNodes_0_host',
nodes_0_port: '#submitNodes_0_port',
nodes_0_weight: '#submitNodes_0_weight',
nameSearchInput: '#name',
hostSearchInput: '#host',
pathSearchInput: '#uri',
labelSelect_0: '.ant-select-selection-overflow',
dropdown: '.rc-virtual-list',
Expand All @@ -45,6 +48,7 @@ context('Create and Search Route', () => {
const data = {
host1: '11.11.11.11',
host2: '12.12.12.12',
hostx: 'aa.com',
port: '80',
weight: 1,
uris: '/get',
Expand Down Expand Up @@ -86,6 +90,11 @@ context('Create and Search Route', () => {
cy.get(selector.name).type(`test${i}`);
cy.get(selector.description).type(`desc${i}`);
cy.get(selector.hosts_0).type(data.host1);
if (i == 2) {
cy.get(selector.add_host).click();
cy.get(selector.hosts_1).type(data.hostx);
}

cy.get(selector.uris_0).clear().type(`/get${i}`);

// config label
Expand Down Expand Up @@ -143,6 +152,30 @@ context('Create and Search Route', () => {
cy.contains(data.test2).should('not.exist');
});

it('should search the route with host', function () {
cy.visit('/');
cy.contains('Route').click();
cy.wait(timeout);
// only one host
cy.get(selector.hostSearchInput).type(data.hostx);
cy.contains('Search').click();
cy.contains(data.test2).siblings().should('contain', data.hostx);
cy.contains(data.test0).should('not.exist');
cy.contains(data.test1).should('not.exist');
// search hosts
cy.get(selector.hostSearchInput).clear().type(data.host1);
cy.contains('Search').click();
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 host
cy.get(selector.hostSearchInput).clear().type(data.host2);
cy.contains('Search').click();
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 path', function () {
cy.visit('/');
cy.contains('Route').click();
Expand Down