Files
wehub-resource-sync 0d3cb498a3
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Has been cancelled
Test and Publish Multi-arch Docker Image / test (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Has been cancelled
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Has been cancelled
Validate Renovate Config / Validate Renovate Configuration (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:24:08 +08:00

52 lines
1.6 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { matchesSelectBest } from '../../src/matchers/comparison';
import { createMockProvider } from '../factories/provider';
import type { ApiProvider, GradingConfig } from '../../src/types/index';
function createSelectBestProvider(output: string): ApiProvider {
return createMockProvider({
id: 'select-best-test-provider',
response: {
output,
tokenUsage: { total: 7, prompt: 3, completion: 4 },
},
});
}
describe('matchesSelectBest', () => {
it('should parse multi-digit verdict indexes', async () => {
const provider = createSelectBestProvider('10');
const outputs = Array.from({ length: 12 }, (_value, index) => `Output ${index}`);
const grading: GradingConfig = { provider };
const result = await matchesSelectBest('choose the best output', outputs, grading);
expect(result[10]).toMatchObject({
pass: true,
score: 1,
reason: 'Output selected as the best: choose the best output',
});
expect(result.filter((item) => item.pass)).toHaveLength(1);
});
it('should return independent failure results for invalid verdicts', async () => {
const provider = createSelectBestProvider('no verdict');
const grading: GradingConfig = { provider };
const result = await matchesSelectBest('choose the best output', ['A', 'B'], grading);
expect(result).toHaveLength(2);
expect(result[0]).not.toBe(result[1]);
expect(result[0]).toMatchObject({
pass: false,
reason: 'Invalid select-best verdict: NaN',
tokensUsed: {
total: 7,
prompt: 3,
completion: 4,
},
});
});
});