fix(web): align search e2e and mobile layout

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
This commit is contained in:
XiaoSeS 2026-09-09 15:43:46 +08:00
parent f62c1dbb75
commit b92d8da70f
3 changed files with 9 additions and 8 deletions

View file

@ -2,9 +2,9 @@ import { expect, test, type Page } from '@playwright/test'
import { setEnglishLocale } from './helpers/auth-fixtures'
import { E2eTestDataBuilder } from './helpers/test-data-builder'
function waitForResourceSearch(page: Page, options: { namespace?: string; q?: string; sort?: string }) {
function waitForSkillSearch(page: Page, options: { namespace?: string; q?: string; sort?: string }) {
return page.waitForResponse((response) => {
if (!response.ok() || !response.url().includes('/api/web/resources?')) {
if (!response.ok() || !response.url().includes('/api/web/skills?')) {
return false
}
@ -47,7 +47,7 @@ test.describe('Namespace Search (Real API)', () => {
await page.goto('/search')
await page.getByPlaceholder('Search skills...').fill(`@${namespace.slug} roadmap`)
const filteredSearch = waitForResourceSearch(page, { namespace: namespace.slug, q: 'roadmap' })
const filteredSearch = waitForSkillSearch(page, { namespace: namespace.slug, q: 'roadmap' })
await page.getByRole('button', { name: 'Search', exact: true }).click()
await filteredSearch
@ -60,7 +60,7 @@ test.describe('Namespace Search (Real API)', () => {
await page.goto(`/search?q=roadmap&namespace=${namespace.slug}&sort=downloads&page=1&starredOnly=false`)
await expect(page.getByRole('button', { name: `@${namespace.slug}` })).toBeVisible()
const unfilteredSearch = waitForResourceSearch(page, { q: 'roadmap', sort: 'downloads' })
const unfilteredSearch = waitForSkillSearch(page, { q: 'roadmap', sort: 'downloads' })
await page.getByRole('button', { name: `@${namespace.slug}` }).click()
await unfilteredSearch
@ -91,7 +91,7 @@ test.describe('Namespace Search (Real API)', () => {
await page.goto('/search')
await page.getByPlaceholder('Search skills...').fill(`@${namespace.slug} boundary`)
const filteredSearch = waitForResourceSearch(page, { namespace: namespace.slug, q: 'boundary' })
const filteredSearch = waitForSkillSearch(page, { namespace: namespace.slug, q: 'boundary' })
await page.getByRole('button', { name: 'Search', exact: true }).click()
await filteredSearch

View file

@ -42,13 +42,14 @@ test.describe('Search Input (Real API)', () => {
// TC_SEARCH_INPUT_003 P0 - empty search shows the default discovery list
test('TC_SEARCH_INPUT_003: empty search shows the default discovery list', async ({ page }) => {
const emptyQueryResponse = page.waitForResponse((response) => {
if (!response.url().includes('/api/web/resources?')) {
if (!response.url().includes('/api/web/skills?')) {
return false
}
const url = new URL(response.url())
return response.status() === 200
&& (url.searchParams.get('q') ?? '') === ''
&& url.searchParams.has('q')
&& url.searchParams.get('q') === ''
})
await page.goto(searchUrl(''))

View file

@ -241,7 +241,7 @@ export function SearchPage() {
{/* Sort And Filters */}
<div className="space-y-4">
<div className="flex items-center justify-between flex-wrap gap-4">
<div className="flex items-center gap-3">
<div className="flex flex-wrap items-center gap-3">
<span className="text-sm font-medium text-muted-foreground">{t('search.sort.label')}</span>
<div className="flex gap-2">
<Button