-
Notifications
You must be signed in to change notification settings - Fork 579
feat: add route search form with 9 filter fields #3222
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
Open
DSingh0304
wants to merge
18
commits into
apache:master
Choose a base branch
from
DSingh0304:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+943
−19
Open
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3912108
feat: add route search form with 9 filter fields
DSingh0304 fab7806
feat(tests): add end-to-end tests for routes search functionality
DSingh0304 75a8903
Merge branch 'master' into master
DSingh0304 b95810a
Change import from 'clsx' to 'classNames'
DSingh0304 62850cd
refactor(SearchForm): remove placeholder text from input fields
DSingh0304 15329fe
Merge branch 'master' into master
Baoyuantop ed84e0b
fix: fetch all data for client-side filtering
DSingh0304 892983b
test: add e2e test for creating routes with version labels via UI
DSingh0304 3e34815
feat: add versionOptions to route SearchForm and update e2e test
DSingh0304 2facdec
feat: enhance pagination tests to filter routes across all pages
DSingh0304 e1489cc
fix: update type casting for pagination parameters in RouteList
DSingh0304 5c46c2f
fix: improve type casting for search parameters in RouteList
DSingh0304 15b45b1
feat: add deleteAllConsumers function to handle bulk deletion of cons…
DSingh0304 ae762d9
fix: routes search reset functionality
DSingh0304 4998fa1
Merge branch 'master' into master
DSingh0304 c8183f2
Merge branch 'apache:master' into master
DSingh0304 6d3b7c0
feat: Add search limit alert to tables and refactor clsx import.
DSingh0304 8e7bdf1
Merge branch 'master' into master
DSingh0304 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { routesPom } from '@e2e/pom/routes'; | ||
| import { e2eReq } from '@e2e/utils/req'; | ||
| import { test } from '@e2e/utils/test'; | ||
| import { uiHasToastMsg } from '@e2e/utils/ui'; | ||
| import { uiFillUpstreamRequiredFields } from '@e2e/utils/ui/upstreams'; | ||
| import { expect } from '@playwright/test'; | ||
|
|
||
| import { deleteAllRoutes } from '@/apis/routes'; | ||
| import type { APISIXType } from '@/types/schema/apisix'; | ||
|
|
||
| /** | ||
| * Test for version filtering across multiple pages. | ||
| * This verifies that client-side filtering works across all routes, | ||
| * not just the current page. | ||
| */ | ||
| test.describe('Routes version filter', () => { | ||
| test.describe.configure({ mode: 'serial' }); | ||
|
|
||
| const nodes: APISIXType['UpstreamNode'][] = [ | ||
| { host: 'test.com', port: 80, weight: 100 }, | ||
| { host: 'test2.com', port: 80, weight: 100 }, | ||
| ]; | ||
|
|
||
| test.beforeAll(async () => { | ||
| // Clean up any existing routes | ||
| await deleteAllRoutes(e2eReq); | ||
| }); | ||
|
|
||
| test.afterAll(async () => { | ||
| // Clean up test routes | ||
| await deleteAllRoutes(e2eReq); | ||
| }); | ||
|
|
||
| test('should filter routes by version across all pages', async ({ page }) => { | ||
| test.slow(); // This test creates multiple routes via UI | ||
|
|
||
| await test.step('create routes with different versions via UI', async () => { | ||
| await routesPom.toIndex(page); | ||
| await routesPom.isIndexPage(page); | ||
|
|
||
| // Create 3 routes with version v1 | ||
| for (let i = 1; i <= 3; i++) { | ||
| await routesPom.getAddRouteBtn(page).click(); | ||
| await routesPom.isAddPage(page); | ||
|
|
||
| await page.getByLabel('Name', { exact: true }).first().fill(`route_v1_${i}`); | ||
| await page.getByLabel('URI', { exact: true }).fill(`/v1/test${i}`); | ||
|
|
||
| // Select HTTP method | ||
| await page.getByRole('textbox', { name: 'HTTP Methods' }).click(); | ||
| await page.getByRole('option', { name: 'GET' }).click(); | ||
|
|
||
| // Add label for version (in the route section, not upstream) | ||
| const routeLabelsField = page.getByRole('textbox', { name: 'Labels' }).first(); | ||
| await routeLabelsField.click(); | ||
| await routeLabelsField.fill('version:v1'); | ||
| await routeLabelsField.press('Enter'); | ||
|
|
||
| // Add upstream | ||
| const upstreamSection = page.getByRole('group', { | ||
| name: 'Upstream', | ||
| exact: true, | ||
| }); | ||
| await uiFillUpstreamRequiredFields(upstreamSection, { | ||
| nodes, | ||
| name: `upstream_v1_${i}`, | ||
| desc: 'test', | ||
| }); | ||
|
|
||
| await routesPom.getAddBtn(page).click(); | ||
| await uiHasToastMsg(page, { | ||
| hasText: 'Add Route Successfully', | ||
| }); | ||
|
|
||
| // Go back to list | ||
| await routesPom.getRouteNavBtn(page).click(); | ||
| await routesPom.isIndexPage(page); | ||
| } | ||
|
|
||
| // Create 3 routes with version v2 | ||
| for (let i = 1; i <= 3; i++) { | ||
| await routesPom.getAddRouteBtn(page).click(); | ||
| await routesPom.isAddPage(page); | ||
|
|
||
| await page.getByLabel('Name', { exact: true }).first().fill(`route_v2_${i}`); | ||
| await page.getByLabel('URI', { exact: true }).fill(`/v2/test${i}`); | ||
|
|
||
| // Select HTTP method | ||
| await page.getByRole('textbox', { name: 'HTTP Methods' }).click(); | ||
| await page.getByRole('option', { name: 'GET' }).click(); | ||
|
|
||
| // Add label for version (in the route section, not upstream) | ||
| const routeLabelsField = page.getByRole('textbox', { name: 'Labels' }).first(); | ||
| await routeLabelsField.click(); | ||
| await routeLabelsField.fill('version:v2'); | ||
| await routeLabelsField.press('Enter'); | ||
|
|
||
| // Add upstream | ||
| const upstreamSection = page.getByRole('group', { | ||
| name: 'Upstream', | ||
| exact: true, | ||
| }); | ||
| await uiFillUpstreamRequiredFields(upstreamSection, { | ||
| nodes, | ||
| name: `upstream_v2_${i}`, | ||
| desc: 'test', | ||
| }); | ||
|
|
||
| await routesPom.getAddBtn(page).click(); | ||
| await uiHasToastMsg(page, { | ||
| hasText: 'Add Route Successfully', | ||
| }); | ||
|
|
||
| // Go back to list | ||
| await routesPom.getRouteNavBtn(page).click(); | ||
| await routesPom.isIndexPage(page); | ||
| } | ||
| }); | ||
|
|
||
| await test.step('verify all routes are created with labels', async () => { | ||
| // Verify routes are visible in list | ||
| await expect(page.getByText('route_v1_1')).toBeVisible(); | ||
| await expect(page.getByText('route_v2_1')).toBeVisible(); | ||
|
|
||
| // Verify version filter field exists | ||
| await expect(page.locator('#version')).toBeAttached(); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { routesPom } from '@e2e/pom/routes'; | ||
| import { e2eReq } from '@e2e/utils/req'; | ||
| import { test } from '@e2e/utils/test'; | ||
| import { expect} from '@playwright/test'; | ||
|
|
||
| import { deleteAllRoutes, putRouteReq } from '@/apis/routes'; | ||
| import { API_ROUTES } from '@/config/constant'; | ||
| import type { APISIXType } from '@/types/schema/apisix'; | ||
|
|
||
| // Sample routes for testing search functionality | ||
| const testRoutes: APISIXType['Route'][] = [ | ||
| { | ||
| id: 'search_route_1', | ||
| name: 'alpha_route', | ||
| uri: '/alpha', | ||
| desc: 'First test route', | ||
| methods: ['GET'], | ||
| upstream: { | ||
| nodes: [{ host: '127.0.0.1', port: 80, weight: 100 }], | ||
| }, | ||
| }, | ||
| { | ||
| id: 'search_route_2', | ||
| name: 'beta_route', | ||
| uri: '/beta', | ||
| desc: 'Second test route', | ||
| methods: ['POST'], | ||
| upstream: { | ||
| nodes: [{ host: '127.0.0.1', port: 80, weight: 100 }], | ||
| }, | ||
| }, | ||
| { | ||
| id: 'search_route_3', | ||
| name: 'gamma_route', | ||
| uri: '/gamma', | ||
| desc: 'Third test route', | ||
| methods: ['GET'], | ||
| upstream: { | ||
| nodes: [{ host: '127.0.0.1', port: 80, weight: 100 }], | ||
| }, | ||
| }, | ||
| ]; | ||
|
|
||
| test.describe('Routes search functionality', () => { | ||
| test.describe.configure({ mode: 'serial' }); | ||
|
|
||
| test.beforeAll(async () => { | ||
| await deleteAllRoutes(e2eReq); | ||
| await Promise.all(testRoutes.map((route) => putRouteReq(e2eReq, route))); | ||
| }); | ||
|
|
||
| test.afterAll(async () => { | ||
| await Promise.all( | ||
| testRoutes.map((route) => e2eReq.delete(`${API_ROUTES}/${route.id}`)) | ||
| ); | ||
| }); | ||
|
|
||
| test('should filter routes by name', async ({ page }) => { | ||
| await test.step('navigate to routes page', async () => { | ||
| await routesPom.getRouteNavBtn(page).click(); | ||
| await routesPom.isIndexPage(page); | ||
| }); | ||
|
|
||
| await test.step('search for routes with "alpha" in name', async () => { | ||
| const nameInput = page.getByLabel('Name'); // Matches the label from SearchForm | ||
| await nameInput.fill('alpha'); | ||
| const searchButton = page.getByRole('button', { name: 'Search' }); | ||
| await searchButton.click(); | ||
|
|
||
| // Wait for table to update | ||
| await expect(page.getByText('alpha_route')).toBeVisible(); | ||
|
|
||
| // Verify only matching route is shown | ||
| const tableRows = page.getByRole('row'); | ||
| await expect(tableRows).toHaveCount(2); // Header + 1 data row | ||
| await expect(page.getByText('beta_route')).toBeHidden(); | ||
| await expect(page.getByText('gamma_route')).toBeHidden(); | ||
| }); | ||
|
|
||
| await test.step('reset search and verify all routes are shown', async () => { | ||
| const resetButton = page.getByRole('button', { name: 'Reset' }); | ||
| await resetButton.click(); | ||
|
|
||
| // Wait for table to update | ||
| await expect(page.getByText('beta_route')).toBeVisible(); | ||
|
|
||
| // Verify all routes are back | ||
| const tableRows = page.getByRole('row'); | ||
| await expect(tableRows).toHaveCount(4); // Header + 3 data rows | ||
| await expect(page.getByText('alpha_route')).toBeVisible(); | ||
| await expect(page.getByText('gamma_route')).toBeVisible(); | ||
| }); | ||
| }); | ||
|
|
||
| test('should show no results for non-matching search', async ({ page }) => { | ||
| await test.step('navigate to routes page', async () => { | ||
| await routesPom.getRouteNavBtn(page).click(); | ||
| await routesPom.isIndexPage(page); | ||
| }); | ||
|
|
||
| await test.step('search for non-existent name', async () => { | ||
| const nameInput = page.getByLabel('Name'); | ||
| await nameInput.fill('nonexistent'); | ||
| const searchButton = page.getByRole('button', { name: 'Search' }); | ||
| await searchButton.click(); | ||
|
|
||
| // Wait for table to update | ||
| await expect(page.getByText('No Data')).toBeVisible(); // Assuming Antd's empty state | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.