mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-04 15:10:06 +00:00
## Summary Improves type safety in test files by replacing unsafe type patterns with proper TypeScript idioms. ## Changes - Define typed `TestWindow` interface extending `Window` for Playwright tests with custom properties - Use `Partial<HTMLElement>` with single type assertion for DOM element mocks - Remove redundant type imports - Fix `console.log` → `console.warn` in test fixture ## Files Changed 16 test files across browser_tests, packages, and src/components ## Test Plan - ✅ `pnpm typecheck` passes - ✅ No new `any` types introduced - ✅ All pre-commit hooks pass ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8253-refactor-improve-TypeScript-patterns-in-test-files-Group-1-8-2f16d73d365081548f9ece7bcf0525ee) by [Unito](https://www.unito.io) --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
63 lines
1.5 KiB
Vue
63 lines
1.5 KiB
Vue
<template>
|
|
<div class="flex flex-row gap-4">
|
|
<div
|
|
v-for="option in normalizedOptions"
|
|
:key="option.value"
|
|
class="flex items-center"
|
|
>
|
|
<RadioButton
|
|
:input-id="`${id}-${option.value}`"
|
|
:name="id"
|
|
:value="option.value"
|
|
:model-value="modelValue"
|
|
:aria-describedby="`${option.text}-label`"
|
|
@update:model-value="$emit('update:modelValue', $event)"
|
|
/>
|
|
<label :for="`${id}-${option.value}`" class="ml-2 cursor-pointer">
|
|
{{ option.text }}
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import RadioButton from 'primevue/radiobutton'
|
|
import { computed } from 'vue'
|
|
|
|
import type { SettingOption } from '@/platform/settings/types'
|
|
|
|
const props = defineProps<{
|
|
modelValue: any
|
|
options?: (string | SettingOption | Record<string, string>)[]
|
|
optionLabel?: string
|
|
optionValue?: string
|
|
id?: string
|
|
}>()
|
|
|
|
defineEmits<{
|
|
'update:modelValue': [value: any]
|
|
}>()
|
|
|
|
const normalizedOptions = computed<SettingOption[]>(() => {
|
|
if (!props.options) return []
|
|
|
|
return props.options.map((option) => {
|
|
if (typeof option === 'string') {
|
|
return { text: option, value: option }
|
|
}
|
|
|
|
if ('text' in option) {
|
|
return {
|
|
text: option.text,
|
|
value: option.value ?? option.text
|
|
}
|
|
}
|
|
// Handle optionLabel/optionValue
|
|
return {
|
|
text: option[props.optionLabel || 'text'] || 'Unknown',
|
|
value: option[props.optionValue || 'value']
|
|
}
|
|
})
|
|
})
|
|
</script>
|