mirror of
https://github.com/nexu-io/open-design.git
synced 2026-09-20 06:15:06 +08:00
b3e338ddb2
* test(web): cover stored-mode ZIP encoder CRC and central directory * test(web): cover design-system audit repair-actions and chat-events dedup * test(web): cover @mention parsing and agent label normalization * test(web): cover error flattener, prompt-template categories, design-system sentinel * fix(web): set ZIP UTF-8 filename flag (bit 11) for non-ASCII names buildZip wrote UTF-8 filename bytes (TextEncoder) but left the general-purpose bit flag at 0 in both the local and central headers, so readers fall back to CP437 and mis-decode non-ASCII names like 日本.md. Set general-purpose bit 11 (0x0800, EFS) in both headers when the filename contains a non-ASCII byte; pure-ASCII archives are unchanged (ASCII == CP437 == UTF-8), matching how Python/Go zip encoders behave. Strengthen the UTF-8 test to assert the flag + filename in BOTH the local and central-directory headers (parsed via EOCD), and add a case asserting pure-ASCII names do not set the flag. Addresses review feedback on #2451.
36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { formatPickAndImportErrorDetails } from '../../src/utils/pickAndImportError';
|
|
|
|
describe('formatPickAndImportErrorDetails', () => {
|
|
it('returns a non-empty string input unchanged', () => {
|
|
expect(formatPickAndImportErrorDetails('disk full')).toBe('disk full');
|
|
});
|
|
|
|
it('returns undefined for empty string, null, or unsupported scalar input', () => {
|
|
expect(formatPickAndImportErrorDetails('')).toBeUndefined();
|
|
expect(formatPickAndImportErrorDetails(null)).toBeUndefined();
|
|
expect(formatPickAndImportErrorDetails(42)).toBeUndefined();
|
|
});
|
|
|
|
it('surfaces error.message from a structured envelope', () => {
|
|
expect(
|
|
formatPickAndImportErrorDetails({ error: { message: 'permission denied' } }),
|
|
).toBe('permission denied');
|
|
});
|
|
|
|
it('appends nested reason in parentheses when both message and reason are present', () => {
|
|
expect(
|
|
formatPickAndImportErrorDetails({
|
|
error: { message: 'open folder failed', details: { reason: 'not a directory' } },
|
|
}),
|
|
).toBe('open folder failed (not a directory)');
|
|
});
|
|
|
|
it('returns undefined when the envelope has no usable message', () => {
|
|
expect(formatPickAndImportErrorDetails({ error: {} })).toBeUndefined();
|
|
expect(formatPickAndImportErrorDetails({ unrelated: true })).toBeUndefined();
|
|
expect(formatPickAndImportErrorDetails({ error: { message: '' } })).toBeUndefined();
|
|
});
|
|
});
|