From a1802f7f93b6d4c8dc1c57dc37f6fd4ca00c6264 Mon Sep 17 00:00:00 2001
From: InfinityPacer <160988576+InfinityPacer@users.noreply.github.com>
Date: Fri, 31 Jul 2026 10:59:35 +0800
Subject: [PATCH] test(resource): cover search filtering and lifecycle (#607)
---
src/components/filter/TorrentFilterBar.vue | 10 +-
.../filter/__tests__/TorrentFilterBar.spec.ts | 217 +++++
.../__tests__/useTorrentFilter.spec.ts | 260 +++++
src/composables/useTorrentFilter.ts | 16 +-
src/pages/__tests__/resource.spec.ts | 897 ++++++++++++++++++
src/pages/resource.vue | 68 +-
src/utils/__tests__/searchStream.spec.ts | 37 +
vite.config.ts | 28 +
8 files changed, 1507 insertions(+), 26 deletions(-)
create mode 100644 src/components/filter/__tests__/TorrentFilterBar.spec.ts
create mode 100644 src/composables/__tests__/useTorrentFilter.spec.ts
create mode 100644 src/pages/__tests__/resource.spec.ts
diff --git a/src/components/filter/TorrentFilterBar.vue b/src/components/filter/TorrentFilterBar.vue
index abc54691..ee25e5d2 100644
--- a/src/components/filter/TorrentFilterBar.vue
+++ b/src/components/filter/TorrentFilterBar.vue
@@ -4,7 +4,9 @@ import { useEventListener } from '@vueuse/core'
import { openSharedDialog } from '@/composables/useSharedDialog'
const TorrentAllFiltersDialog = defineAsyncComponent(() => import('@/components/dialog/TorrentAllFiltersDialog.vue'))
-const TorrentSingleFilterDialog = defineAsyncComponent(() => import('@/components/dialog/TorrentSingleFilterDialog.vue'))
+const TorrentSingleFilterDialog = defineAsyncComponent(
+ () => import('@/components/dialog/TorrentSingleFilterDialog.vue'),
+)
// 国际化
const { t } = useI18n()
@@ -288,6 +290,11 @@ onMounted(() => {
}, 500)
})
})
+
+onUnmounted(() => {
+ closeAllFilterDialog()
+ closeFilterDialog()
+})
@@ -593,7 +600,6 @@ onMounted(() => {
-