fix: use custom-first in presets
This commit is contained in:
parent
846e89f58e
commit
6553d0d957
5 changed files with 77 additions and 7 deletions
|
|
@ -523,9 +523,7 @@ const emitter = defineEmits<{
|
||||||
const config = useConfigStore();
|
const config = useConfigStore();
|
||||||
const toast = useNotification();
|
const toast = useNotification();
|
||||||
const dialog = useDialog();
|
const dialog = useDialog();
|
||||||
const { findPreset, hasPreset, selectItems, getPresetDefault } = usePresetOptions(undefined, {
|
const { findPreset, hasPreset, selectItems, getPresetDefault } = usePresetOptions();
|
||||||
order: 'default-first',
|
|
||||||
});
|
|
||||||
|
|
||||||
const showAdvanced = useStorage<boolean>('show_advanced', false);
|
const showAdvanced = useStorage<boolean>('show_advanced', false);
|
||||||
const separator = useStorage<string>('url_separator', separators[0]?.value ?? ',');
|
const separator = useStorage<string>('url_separator', separators[0]?.value ?? ',');
|
||||||
|
|
|
||||||
|
|
@ -475,7 +475,7 @@ const box = useConfirm();
|
||||||
const app = toRef(configStore, 'app');
|
const app = toRef(configStore, 'app');
|
||||||
const paused = toRef(configStore, 'paused');
|
const paused = toRef(configStore, 'paused');
|
||||||
const presets = toRef(configStore, 'presets');
|
const presets = toRef(configStore, 'presets');
|
||||||
const { selectItems: presetItems } = usePresetOptions(presets, { order: 'custom-first' });
|
const { selectItems: presetItems } = usePresetOptions(presets);
|
||||||
const { queue, history } = storeToRefs(stateStore);
|
const { queue, history } = storeToRefs(stateStore);
|
||||||
|
|
||||||
const embedUrl = ref('');
|
const embedUrl = ref('');
|
||||||
|
|
|
||||||
|
|
@ -521,9 +521,7 @@ const emitter = defineEmits<{
|
||||||
const toast = useNotification();
|
const toast = useNotification();
|
||||||
const config = useConfigStore();
|
const config = useConfigStore();
|
||||||
const dialog = useDialog();
|
const dialog = useDialog();
|
||||||
const { findPreset, getPresetDefault, selectItems } = usePresetOptions(undefined, {
|
const { findPreset, getPresetDefault, selectItems } = usePresetOptions();
|
||||||
order: 'default-first',
|
|
||||||
});
|
|
||||||
const showImport = useStorage('showTaskImport', false);
|
const showImport = useStorage('showTaskImport', false);
|
||||||
|
|
||||||
const createDefaultTask = (source?: Partial<Task>): Task => ({
|
const createDefaultTask = (source?: Partial<Task>): Task => ({
|
||||||
|
|
|
||||||
58
ui/tests/composables/usePresetOptions.test.ts
Normal file
58
ui/tests/composables/usePresetOptions.test.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
import { describe, expect, it } from 'bun:test'
|
||||||
|
|
||||||
|
import { usePresetOptions } from '~/composables/usePresetOptions'
|
||||||
|
import type { Preset } from '~/types/presets'
|
||||||
|
|
||||||
|
const buildPreset = (name: string, isDefault: boolean): Preset => ({
|
||||||
|
name,
|
||||||
|
default: isDefault,
|
||||||
|
description: '',
|
||||||
|
folder: '',
|
||||||
|
template: '',
|
||||||
|
cookies: '',
|
||||||
|
cli: '',
|
||||||
|
priority: 0,
|
||||||
|
})
|
||||||
|
|
||||||
|
const setConfigStore = (presets: Preset[]) => {
|
||||||
|
;(globalThis as any).useConfigStore = () => ({
|
||||||
|
presets,
|
||||||
|
app: {
|
||||||
|
download_path: '/downloads',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('usePresetOptions', () => {
|
||||||
|
it('groups custom presets before default presets by default', () => {
|
||||||
|
setConfigStore([
|
||||||
|
buildPreset('default_video', true),
|
||||||
|
buildPreset('custom_audio', false),
|
||||||
|
])
|
||||||
|
|
||||||
|
const { selectItems } = usePresetOptions()
|
||||||
|
|
||||||
|
expect(selectItems.value).toEqual([
|
||||||
|
{ type: 'label', label: 'Custom presets' },
|
||||||
|
{ label: 'Custom Audio', value: 'custom_audio' },
|
||||||
|
{ type: 'label', label: 'Default presets' },
|
||||||
|
{ label: 'Default Video', value: 'default_video' },
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('supports default-first grouping when requested', () => {
|
||||||
|
setConfigStore([
|
||||||
|
buildPreset('default_video', true),
|
||||||
|
buildPreset('custom_audio', false),
|
||||||
|
])
|
||||||
|
|
||||||
|
const { selectItems } = usePresetOptions(undefined, { order: 'default-first' })
|
||||||
|
|
||||||
|
expect(selectItems.value).toEqual([
|
||||||
|
{ type: 'label', label: 'Default presets' },
|
||||||
|
{ label: 'Default Video', value: 'default_video' },
|
||||||
|
{ type: 'label', label: 'Custom presets' },
|
||||||
|
{ label: 'Custom Audio', value: 'custom_audio' },
|
||||||
|
])
|
||||||
|
})
|
||||||
|
})
|
||||||
16
ui/tests/tsconfig.json
Normal file
16
ui/tests/tsconfig.json
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"extends": "../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"types": [
|
||||||
|
"bun-types",
|
||||||
|
"../app/types/globals"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"./**/*.ts",
|
||||||
|
"../app/**/*.ts",
|
||||||
|
"../app/**/*.d.ts",
|
||||||
|
"../app/**/*.vue",
|
||||||
|
"../.nuxt/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue