Skip to content

Commit f43fdd8

Browse files
authoredDec 19, 2023
fix(ui): show file item when search filter matches only test cases (#4736)
1 parent fd5d7e6 commit f43fdd8

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
 

‎packages/ui/client/components/TaskTree.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const { task, indent = 0, nested = false, search, onItemClick } = defineProps<{
1717
<!-- maybe provide a KEEP STRUCTURE mode, do not filter by search keyword -->
1818
<!-- v-if = keepStructure || (!search || caseInsensitiveMatch(task.name, search)) -->
1919
<TaskItem
20-
v-if="!search || caseInsensitiveMatch(task.name, search)"
20+
v-if="!nested || !search || caseInsensitiveMatch(task.name, search)"
2121
v-bind="$attrs"
2222
:task="task"
2323
:style="{ paddingLeft: `${indent * 0.75 + 1}rem` }"

‎test/ui/test/ui.spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,22 @@ test.describe('ui', () => {
5353
await page.getByTestId('btn-console').click()
5454
await page.getByText('/(?<char>\\w)/').click()
5555
})
56+
57+
test('file-filter', async ({ page }) => {
58+
await page.goto(pageUrl)
59+
60+
// match all files when no filter
61+
await page.getByPlaceholder('Search...').fill('')
62+
await page.getByText('PASS (3)').click()
63+
await expect(page.getByText('fixtures/sample.test.ts', { exact: true })).toBeVisible()
64+
65+
// match nothing
66+
await page.getByPlaceholder('Search...').fill('nothing')
67+
await page.getByText('No matched test').click()
68+
69+
// searching "add" will match "sample.test.ts" since it includes a test case named "add"
70+
await page.getByPlaceholder('Search...').fill('add')
71+
await page.getByText('PASS (1)').click()
72+
await expect(page.getByText('fixtures/sample.test.ts', { exact: true })).toBeVisible()
73+
})
5674
})

0 commit comments

Comments
 (0)
Please sign in to comment.