Skip to content

Commit aa62f29

Browse files
committed
chore: removed redundant code
Signed-off-by: Evzen Gasta <[email protected]>
1 parent 15616c1 commit aa62f29

File tree

2 files changed

+0
-118
lines changed

2 files changed

+0
-118
lines changed

packages/frontend/src/lib/select/ModelSelect.spec.ts

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,6 @@ import { render, fireEvent, within } from '@testing-library/svelte';
2222
import ModelSelect from '/@/lib/select/ModelSelect.svelte';
2323
import type { ModelInfo } from '@shared/models/IModelInfo';
2424
import { InferenceType } from '@shared/models/IInference';
25-
import { writable, type Writable } from 'svelte/store';
26-
import type { ExtensionConfiguration } from '@shared/models/IExtensionConfiguration';
27-
import { configuration } from '/@/stores/extensionConfiguration';
28-
29-
vi.mock('../../stores/extensionConfiguration', () => ({
30-
configuration: {
31-
subscribe: vi.fn(),
32-
unsubscribe: vi.fn(),
33-
},
34-
}));
35-
36-
const mockConfiguration: Writable<ExtensionConfiguration> = writable({
37-
inferenceRuntime: 'llama-cpp',
38-
experimentalGPU: false,
39-
showGPUPromotion: false,
40-
modelUploadDisabled: false,
41-
modelsPath: '',
42-
experimentalTuning: false,
43-
apiPort: -1,
44-
appearance: 'dark',
45-
});
4625

4726
const fakeRecommendedModel: ModelInfo = {
4827
id: 'dummy-model-1',
@@ -66,39 +45,9 @@ const fakeRecommendedRemoteModel: ModelInfo = {
6645
name: 'Dummy Model 3',
6746
} as unknown as ModelInfo;
6847

69-
const fakeRemoteModelWhisper: ModelInfo = {
70-
id: 'dummy-model-4',
71-
backend: InferenceType.WHISPER_CPP,
72-
name: 'Dummy Model 4',
73-
} as unknown as ModelInfo;
74-
75-
const fakeRemoteModelNone: ModelInfo = {
76-
id: 'dummy-model-5',
77-
backend: InferenceType.NONE,
78-
name: 'Dummy Model 5',
79-
} as unknown as ModelInfo;
80-
81-
vi.mock('/@/utils/client', async () => {
82-
return {
83-
studioClient: {
84-
updateExtensionConfiguration: vi.fn(),
85-
telemetryLogUsage: vi.fn(),
86-
},
87-
};
88-
});
89-
90-
vi.mock('../../stores/extensionConfiguration', () => ({
91-
configuration: {
92-
subscribe: vi.fn(),
93-
unsubscribe: vi.fn(),
94-
},
95-
}));
96-
9748
beforeEach(() => {
98-
vi.resetAllMocks();
9949
// mock scrollIntoView
10050
window.HTMLElement.prototype.scrollIntoView = vi.fn();
101-
vi.mocked(configuration).subscribe.mockImplementation(run => mockConfiguration.subscribe(run));
10251
});
10352

10453
test('ModelSelect should list all models provided', async () => {
@@ -121,26 +70,6 @@ test('ModelSelect should list all models provided', async () => {
12170
expect(items[1]).toHaveTextContent(fakeRemoteModel.name);
12271
});
12372

124-
test('ModelSelect should list all models based on selected runtime', async () => {
125-
const { container } = render(ModelSelect, {
126-
value: undefined,
127-
disabled: undefined,
128-
models: [fakeRecommendedModel, fakeRemoteModelWhisper, fakeRemoteModel, fakeRemoteModelNone],
129-
recommended: [],
130-
});
131-
132-
// first get the select input
133-
const input = within(container).getByLabelText('Select Model');
134-
await fireEvent.pointerUp(input); // they are using the pointer up event instead of click.
135-
136-
// get all options available
137-
const items = container.querySelectorAll('div[class~="list-item"]');
138-
// ensure we have two options
139-
expect(items.length).toBe(2);
140-
expect(items[0]).toHaveTextContent(fakeRecommendedModel.name);
141-
expect(items[1]).toHaveTextContent(fakeRemoteModel.name);
142-
});
143-
14473
test('ModelSelect should set star icon next to recommended model', async () => {
14574
const { container } = render(ModelSelect, {
14675
value: undefined,
@@ -181,30 +110,3 @@ test('models should be sorted', async () => {
181110
expect(items[1]).toHaveTextContent(fakeRecommendedRemoteModel.name);
182111
expect(items[2]).toHaveTextContent(fakeRemoteModel.name);
183112
});
184-
185-
test('ModelSelect should filter out models based on selected default runtime', async () => {
186-
const { container } = render(ModelSelect, {
187-
value: undefined,
188-
disabled: undefined,
189-
models: [
190-
fakeRecommendedModel,
191-
fakeRemoteModel,
192-
fakeRemoteModelNone,
193-
fakeRemoteModelWhisper,
194-
fakeRecommendedRemoteModel,
195-
],
196-
recommended: [],
197-
});
198-
199-
// first get the select input
200-
const input = within(container).getByLabelText('Select Model');
201-
await fireEvent.pointerUp(input); // they are using the pointer up event instead of click.
202-
203-
// get all options available
204-
const items = container.querySelectorAll('div[class~="list-item"]');
205-
// ensure we have two options
206-
expect(items.length).toBe(3);
207-
expect(items[0]).toHaveTextContent(fakeRecommendedModel.name);
208-
expect(items[1]).toHaveTextContent(fakeRemoteModel.name);
209-
expect(items[2]).toHaveTextContent(fakeRecommendedRemoteModel.name);
210-
});

packages/frontend/src/lib/select/ModelSelect.svelte

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { faCheckCircle, faDownload } from '@fortawesome/free-solid-svg-icons';
33
import Select from './Select.svelte';
44
import Fa from 'svelte-fa';
55
import type { ModelInfo } from '@shared/models/IModelInfo';
6-
import { onMount } from 'svelte';
7-
import { configuration } from '/@/stores/extensionConfiguration';
86
97
interface Props {
108
disabled?: boolean;
@@ -46,23 +44,6 @@ let selected: (ModelInfo & { label: string; value: string }) | undefined = $deri
4644
function handleOnChange(nValue: (ModelInfo & { label: string; value: string }) | undefined): void {
4745
value = nValue;
4846
}
49-
50-
let defaultRuntime: string | undefined = $state();
51-
52-
onMount(() => {
53-
return configuration.subscribe(values => {
54-
if (values?.inferenceRuntime) {
55-
defaultRuntime = values.inferenceRuntime;
56-
}
57-
});
58-
});
59-
60-
function filterModel(model: ModelInfo): boolean {
61-
// If the defaultRuntime is undefined we should not filter any model
62-
if (!defaultRuntime || defaultRuntime === 'all') return true;
63-
64-
return model.backend === defaultRuntime;
65-
}
6647
</script>
6748

6849
<Select
@@ -73,7 +54,6 @@ function filterModel(model: ModelInfo): boolean {
7354
onchange={handleOnChange}
7455
placeholder="Select model to use"
7556
items={models
76-
.filter(filterModel)
7757
.toSorted((a, b) => getModelSortingScore(a) - getModelSortingScore(b))
7858
.map(model => ({ ...model, value: model.id, label: model.name }))}>
7959
<div slot="item" let:item>

0 commit comments

Comments
 (0)