mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-11-14 01:53:46 +00:00
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Pre-commit / pre-commit (push) Waiting to run
Test / Run Web + Local Brain Smoke (push) Waiting to run
Test / Run Frontend Guardrails (push) Waiting to run
Test / Run Browser Preview Electron Test (push) Waiting to run
Test / Run Python Tests (push) Waiting to run
Co-authored-by: 4pmtong <web_chentong@163.com>
59 lines
2 KiB
TypeScript
59 lines
2 KiB
TypeScript
// ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
// ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
|
|
|
|
import { workerModelOption } from '@/lib/workerModelOptions';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
describe('worker model configuration identity', () => {
|
|
it('keeps credentials with the exact saved record when names repeat', () => {
|
|
const records = [
|
|
{
|
|
id: 11,
|
|
provider_name: 'openai',
|
|
model_type: 'gpt-5',
|
|
api_key: 'first',
|
|
endpoint_url: '',
|
|
},
|
|
{
|
|
id: 12,
|
|
provider_name: 'openai',
|
|
model_type: 'gpt-5',
|
|
api_key: 'second',
|
|
endpoint_url: '',
|
|
},
|
|
];
|
|
const [first, second] = records.map((record) =>
|
|
workerModelOption(record, 'OpenAI', records)
|
|
);
|
|
expect(first.value).toBe('provider:11');
|
|
expect(second.value).toBe('provider:12');
|
|
expect(first.label).toBe('OpenAI (gpt-5) · …irst');
|
|
expect(second.label).toBe('OpenAI (gpt-5) · …cond');
|
|
expect(first.api_key).toBe('first');
|
|
expect(second.api_key).toBe('second');
|
|
});
|
|
|
|
it('labels a unique configuration without a hint', () => {
|
|
const record = {
|
|
id: 11,
|
|
provider_name: 'openai',
|
|
model_type: 'gpt-5',
|
|
api_key: 'first',
|
|
endpoint_url: '',
|
|
};
|
|
expect(workerModelOption(record, 'OpenAI', [record]).label).toBe(
|
|
'OpenAI (gpt-5)'
|
|
);
|
|
});
|
|
});
|