diff --git a/craft/src/panels/sitesmith/statusMessages.test.ts b/craft/src/panels/sitesmith/statusMessages.test.ts index 273d0ac..cbb317f 100644 --- a/craft/src/panels/sitesmith/statusMessages.test.ts +++ b/craft/src/panels/sitesmith/statusMessages.test.ts @@ -1,5 +1,5 @@ import { describe, test, expect } from 'vitest'; -import { SITESMITH_CLIENT_STATUSES, SITESMITH_SERVER_STATUSES, type SitesmithStatus } from '../../types/sitesmith'; +import { SITESMITH_CLIENT_STATUSES, SITESMITH_SERVER_STATUSES, isSitesmithStatus, type SitesmithStatus } from '../../types/sitesmith'; import { failureMessage, STATUS_MESSAGES } from './statusMessages'; const FAILURES: SitesmithStatus[] = [...SITESMITH_SERVER_STATUSES, ...SITESMITH_CLIENT_STATUSES].filter((s) => s !== 'OK_BONUS' && s !== 'OK_MONTHLY'); @@ -27,6 +27,15 @@ describe('Sitesmith failure messages (G6)', () => { expect(failureMessage({ ok: false, status: 'AI_INVALID', message: '' })).toMatch(/could not use/i); }); + test('RESPONSE_TOO_LONG is a known server status with its own advice (not the generic ERROR)', () => { + expect(isSitesmithStatus('RESPONSE_TOO_LONG')).toBe(true); + const m = failureMessage({ ok: false, status: 'RESPONSE_TOO_LONG', message: 'That answer was too long for Sitesmith to finish in one go, so nothing was changed. Try asking for less at once -- for example one page, or one section, at a time.' }); + expect(m).toBe(STATUS_MESSAGES.RESPONSE_TOO_LONG.text); + expect(m).not.toBe(STATUS_MESSAGES.ERROR.text); + expect(m).toMatch(/nothing was changed/); + expect(m).toMatch(/one page or one section at a time/); + }); + test('statuses whose server text carries the detail keep it; fixed-meaning statuses use the specific text', () => { expect(failureMessage({ ok: false, status: 'BAD_ATTACHMENT', message: 'Self-review needs an AI model that can see images.' })) .toBe('Self-review needs an AI model that can see images.'); diff --git a/craft/src/panels/sitesmith/statusMessages.ts b/craft/src/panels/sitesmith/statusMessages.ts index 5603781..f4c2922 100644 --- a/craft/src/panels/sitesmith/statusMessages.ts +++ b/craft/src/panels/sitesmith/statusMessages.ts @@ -25,6 +25,8 @@ export const STATUS_MESSAGES: Record