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(ui): show file item when search filter matches only test cases #4736

Merged
merged 6 commits into from
Dec 19, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ui/client/components/TaskTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { task, indent = 0, nested = false, search, onItemClick } = defineProps<{
<!-- maybe provide a KEEP STRUCTURE mode, do not filter by search keyword -->
<!-- v-if = keepStructure || (!search || caseInsensitiveMatch(task.name, search)) -->
<TaskItem
v-if="!search || caseInsensitiveMatch(task.name, search)"
v-if="!nested || !search || caseInsensitiveMatch(task.name, search)"
v-bind="$attrs"
:task="task"
:style="{ paddingLeft: `${indent * 0.75 + 1}rem` }"
Expand Down
18 changes: 18 additions & 0 deletions test/ui/test/ui.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,22 @@ test.describe('ui', () => {
await page.getByTestId('btn-console').click()
await page.getByText('/(?<char>\\w)/').click()
})

test('file-filter', async ({ page }) => {
await page.goto(pageUrl)

// match all files when no filter
await page.getByPlaceholder('Search...').fill('')
await page.getByText('PASS (3)').click()
await expect(page.getByText('fixtures/sample.test.ts', { exact: true })).toBeVisible()

// match nothing
await page.getByPlaceholder('Search...').fill('nothing')
await page.getByText('No matched test').click()

// searching "add" will match "sample.test.ts" since it includes a test case named "add"
await page.getByPlaceholder('Search...').fill('add')
await page.getByText('PASS (1)').click()
await expect(page.getByText('fixtures/sample.test.ts', { exact: true })).toBeVisible()
})
})