Global error page: ErrorView with per-status copy, did-you-mean suggestions, error ids from handleError, static error.html; 404 instead of 500 for bad progress ids; tolerate full header line in DAISY_TASK_WEBHOOK_HEADER and stop logging raw fetch errors
All checks were successful
Deploy production / deploy (push) Successful in 1m9s

This commit is contained in:
2026-10-25 13:10:50 +00:00
parent f86c8ef294
commit a89a187346
13 changed files with 665 additions and 30 deletions

34
src/lib/errors.test.ts Normal file
View File

@@ -0,0 +1,34 @@
import { describe, expect, it } from 'vitest';
import { errorCopy, suggestPages } from './errors';
const hrefs = (path: string, owner = false) => suggestPages(path, owner).map((s) => s.href);
describe('errorCopy', () => {
it('has copy per status family', () => {
expect(errorCopy(404).tone).toBe('missing');
expect(errorCopy(403).title).toBe('Owner only');
expect(errorCopy(500).tone).toBe('broken');
expect(errorCopy(503).tone).toBe('down');
});
});
describe('suggestPages', () => {
it('suggests the parent tracker for a missing detail page', () => {
expect(hrefs('/trackers/cars/does-not-exist')[0]).toBe('/trackers/cars');
});
it('fixes typos in tracker names', () => {
expect(hrefs('/trackers/bokos')).toContain('/trackers/books');
expect(hrefs('/trakcers/trians')).toContain('/trackers/trains');
});
it('finds a tracker by name under the wrong section', () => {
expect(hrefs('/projects/planes')).toContain('/trackers/planes');
});
it('never suggests private trackers to visitors', () => {
expect(hrefs('/trackers/helth')).not.toContain('/trackers/health');
expect(hrefs('/trackers/helth', true)).toContain('/trackers/health');
});
it('returns nothing for the home page or noise', () => {
expect(hrefs('/')).toEqual([]);
expect(hrefs('/zzqxj')).toEqual([]);
});
});