Skip to content

Commit 5f3a666

Browse files
committed
fix: improve test type safety and fix import paths
- Fix TypeScript errors in useConflictDetection, useImportFailedDetection, useUpdateAvailableNodes tests - Remove all any types and apply proper type assertions - Reflect backend SystemStats structure changes (add pytorch_version, embedded_python fields) - Fix OS mapping logic in systemCompatibility.ts (resolve darwin/win conflict) - Fix incorrect import paths (@/composables → @/workbench/extensions/manager/composables) - Remove unnecessary properties from mock objects and align with actual implementations - Add new utility tests (conflictUtils, systemCompatibility, versionUtil)
1 parent c53d050 commit 5f3a666

19 files changed

+1518
-1014
lines changed

src/components/helpcenter/HelpCenterMenuContent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,13 @@ import {
141141
import { useI18n } from 'vue-i18n'
142142
143143
import PuzzleIcon from '@/components/icons/PuzzleIcon.vue'
144-
import { useConflictAcknowledgment } from '@/composables/useConflictAcknowledgment'
145144
import { useSettingStore } from '@/platform/settings/settingStore'
146145
import type { ReleaseNote } from '@/platform/updates/common/releaseService'
147146
import { useReleaseStore } from '@/platform/updates/common/releaseStore'
148147
import { useCommandStore } from '@/stores/commandStore'
149148
import { electronAPI, isElectron } from '@/utils/envUtil'
150149
import { formatVersionAnchor } from '@/utils/formatUtil'
150+
import { useConflictAcknowledgment } from '@/workbench/extensions/manager/composables/useConflictAcknowledgment'
151151
import { useManagerState } from '@/workbench/extensions/manager/composables/useManagerState'
152152
import { ManagerTab } from '@/workbench/extensions/manager/types/comfyManagerTypes'
153153

src/components/sidebar/SidebarHelpCenterIcon.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ import { storeToRefs } from 'pinia'
6262
import { computed, onMounted } from 'vue'
6363
6464
import HelpCenterMenuContent from '@/components/helpcenter/HelpCenterMenuContent.vue'
65-
import { useConflictAcknowledgment } from '@/composables/useConflictAcknowledgment'
66-
import { useConflictDetection } from '@/composables/useConflictDetection'
6765
import { useSettingStore } from '@/platform/settings/settingStore'
6866
import { useReleaseStore } from '@/platform/updates/common/releaseStore'
6967
import ReleaseNotificationToast from '@/platform/updates/components/ReleaseNotificationToast.vue'
7068
import WhatsNewPopup from '@/platform/updates/components/WhatsNewPopup.vue'
7169
import { useDialogService } from '@/services/dialogService'
7270
import { useHelpCenterStore } from '@/stores/helpCenterStore'
71+
import { useConflictAcknowledgment } from '@/workbench/extensions/manager/composables/useConflictAcknowledgment'
72+
import { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection'
7373
7474
import SidebarIcon from './SidebarIcon.vue'
7575

src/utils/systemCompatibility.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ function getRegistryOS(systemOS?: string): RegistryOS | undefined {
1515
if (!systemOS) return undefined
1616

1717
const lower = systemOS.toLowerCase()
18-
if (lower.includes('win')) return 'Windows'
18+
// Check darwin first to avoid matching 'win' in 'darwin'
1919
if (lower.includes('darwin') || lower.includes('mac')) return 'macOS'
20+
if (lower.includes('win')) return 'Windows'
2021
if (lower.includes('linux')) return 'Linux'
2122

2223
return undefined

src/utils/versionUtil.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,6 @@ function cleanVersion(version: string): string {
1616
return clean(version) || version
1717
}
1818

19-
/**
20-
* Checks if a version satisfies a version range
21-
* @param version Current version
22-
* @param range Version range (e.g., ">=1.0.0", "^1.2.0", "1.0.0 - 2.0.0")
23-
* @returns true if version satisfies the range
24-
*/
25-
function satisfiesVersion(version: string, range: string): boolean {
26-
try {
27-
const cleanedVersion = cleanVersion(version)
28-
return satisfies(cleanedVersion, range)
29-
} catch {
30-
return false
31-
}
32-
}
33-
3419
/**
3520
* Checks version compatibility and returns conflict details.
3621
* Supports all semver ranges including >=, <=, >, <, ~, ^ operators.
@@ -55,15 +40,27 @@ export function checkVersionCompatibility(
5540
}
5641

5742
// Clean and check version compatibility
58-
const cleanCurrent = cleanVersion(currentVersion ?? '')
59-
const isCompatible = satisfiesVersion(cleanCurrent, supportedVersion ?? '')
43+
const cleanCurrent = cleanVersion(currentVersion)
44+
45+
// Check if version satisfies the range
46+
let isCompatible = false
47+
try {
48+
isCompatible = satisfies(cleanCurrent, supportedVersion)
49+
} catch {
50+
// If semver can't parse it, return conflict
51+
return {
52+
type,
53+
current_value: currentVersion,
54+
required_value: supportedVersion
55+
}
56+
}
6057

6158
if (isCompatible) return null
6259

6360
return {
6461
type,
65-
current_value: currentVersion ?? '',
66-
required_value: supportedVersion ?? ''
62+
current_value: currentVersion,
63+
required_value: supportedVersion
6764
}
6865
}
6966

src/workbench/extensions/manager/components/ManagerProgressFooter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ import { computed, ref } from 'vue'
7474
import { useI18n } from 'vue-i18n'
7575
7676
import DotSpinner from '@/components/common/DotSpinner.vue'
77-
import { useConflictDetection } from '@/composables/useConflictDetection'
7877
import { useSettingStore } from '@/platform/settings/settingStore'
7978
import { useWorkflowService } from '@/platform/workflow/core/services/workflowService'
8079
import { api } from '@/scripts/api'
8180
import { useCommandStore } from '@/stores/commandStore'
8281
import { useDialogStore } from '@/stores/dialogStore'
82+
import { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection'
8383
import { useComfyManagerService } from '@/workbench/extensions/manager/services/comfyManagerService'
8484
import {
8585
useComfyManagerStore,

src/workbench/extensions/manager/components/manager/NodeConflictDialogContent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ import { computed, ref } from 'vue'
168168
import { useI18n } from 'vue-i18n'
169169
170170
import ContentDivider from '@/components/common/ContentDivider.vue'
171-
import { useConflictDetection } from '@/composables/useConflictDetection'
172171
import type {
173172
ConflictDetail,
174173
ConflictDetectionResult
175174
} from '@/types/conflictDetectionTypes'
176175
import { getConflictMessage } from '@/utils/conflictMessageUtil'
176+
import { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection'
177177
178178
const { showAfterWhatsNew = false, conflictedPackages } = defineProps<{
179179
showAfterWhatsNew?: boolean

src/workbench/extensions/manager/components/manager/PackVersionSelectorPopover.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ import { useI18n } from 'vue-i18n'
9191
import ContentDivider from '@/components/common/ContentDivider.vue'
9292
import NoResultsPlaceholder from '@/components/common/NoResultsPlaceholder.vue'
9393
import VerifiedIcon from '@/components/icons/VerifiedIcon.vue'
94-
import { useConflictDetection } from '@/composables/useConflictDetection'
9594
import { useComfyRegistryService } from '@/services/comfyRegistryService'
9695
import type { components } from '@/types/comfyRegistryTypes'
9796
import { getJoinedConflictMessages } from '@/utils/conflictMessageUtil'
97+
import { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection'
9898
import { useComfyManagerStore } from '@/workbench/extensions/manager/stores/comfyManagerStore'
9999
import type { components as ManagerComponents } from '@/workbench/extensions/manager/types/generatedManagerTypes'
100100

src/workbench/extensions/manager/components/manager/button/PackInstallButton.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ import { computed } from 'vue'
2727
2828
import IconTextButton from '@/components/button/IconTextButton.vue'
2929
import DotSpinner from '@/components/common/DotSpinner.vue'
30-
import { useConflictDetection } from '@/composables/useConflictDetection'
3130
import { t } from '@/i18n'
3231
import { useDialogService } from '@/services/dialogService'
3332
import type { ButtonSize } from '@/types/buttonTypes'
3433
import type { components } from '@/types/comfyRegistryTypes'
3534
import type { ConflictDetectionResult } from '@/types/conflictDetectionTypes'
3635
import type { ConflictDetail } from '@/types/conflictDetectionTypes'
36+
import { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection'
3737
import { useComfyManagerStore } from '@/workbench/extensions/manager/stores/comfyManagerStore'
3838
import type { components as ManagerComponents } from '@/workbench/extensions/manager/types/generatedManagerTypes'
3939

src/workbench/extensions/manager/components/manager/infoPanel/InfoPanelHeader.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@
4545
import { computed, inject, ref, watch } from 'vue'
4646
4747
import NoResultsPlaceholder from '@/components/common/NoResultsPlaceholder.vue'
48-
import { useConflictDetection } from '@/composables/useConflictDetection'
4948
import type { components } from '@/types/comfyRegistryTypes'
5049
import type { ConflictDetail } from '@/types/conflictDetectionTypes'
5150
import { ImportFailedKey } from '@/types/importFailedTypes'
5251
import PackInstallButton from '@/workbench/extensions/manager/components/manager/button/PackInstallButton.vue'
5352
import PackUninstallButton from '@/workbench/extensions/manager/components/manager/button/PackUninstallButton.vue'
5453
import PackIcon from '@/workbench/extensions/manager/components/manager/packIcon/PackIcon.vue'
54+
import { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection'
5555
import { useComfyManagerStore } from '@/workbench/extensions/manager/stores/comfyManagerStore'
5656
5757
const { nodePacks, hasConflict } = defineProps<{

src/workbench/extensions/manager/components/manager/packCard/PackCardFooter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
import { computed, inject } from 'vue'
2626
import { useI18n } from 'vue-i18n'
2727
28-
import { useConflictDetection } from '@/composables/useConflictDetection'
2928
import type { components } from '@/types/comfyRegistryTypes'
3029
import type { ConflictDetail } from '@/types/conflictDetectionTypes'
3130
import PackEnableToggle from '@/workbench/extensions/manager/components/manager/button/PackEnableToggle.vue'
3231
import PackInstallButton from '@/workbench/extensions/manager/components/manager/button/PackInstallButton.vue'
32+
import { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection'
3333
import { useComfyManagerStore } from '@/workbench/extensions/manager/stores/comfyManagerStore'
3434
import { IsInstallingKey } from '@/workbench/extensions/manager/types/comfyManagerTypes'
3535

0 commit comments

Comments
 (0)