Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma strängvärde byggs med konkatenering i stället för att matcha mönstret.
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { friendlyModelError } from '../run-turn'
|
|
|
|
describe('friendlyModelError', () => {
|
|
it('429 status → "Anna är upptagen"', () => {
|
|
expect(friendlyModelError({ status: 429, message: 'Too Many Requests' })).toMatch(/upptagen/i)
|
|
})
|
|
|
|
it('throttling message → busy', () => {
|
|
expect(friendlyModelError(new Error('ThrottlingException: Rate exceeded'))).toMatch(/upptagen/i)
|
|
})
|
|
|
|
it('timeout / dropped connection → "Anslutningen ... bröts"', () => {
|
|
expect(friendlyModelError(new Error('socket hang up ETIMEDOUT'))).toMatch(/anslutningen/i)
|
|
})
|
|
|
|
it('5xx → temporary service error', () => {
|
|
expect(friendlyModelError({ status: 503, message: 'Service Unavailable' })).toMatch(/tillfälligt fel/i)
|
|
})
|
|
|
|
it('unknown error → generic Swedish line', () => {
|
|
expect(friendlyModelError(new Error('weird'))).toMatch(/något gick fel/i)
|
|
})
|
|
|
|
it('never leaks the raw English SDK message to the user', () => {
|
|
const out = friendlyModelError(new Error('ValidationException: model id invalid'))
|
|
expect(out).not.toContain('ValidationException')
|
|
expect(out).not.toContain('model id')
|
|
})
|
|
})
|