feat(editor): adopt backend final-fix contract (client_id, warnings, limits, head parity)
client_id per editor load (memory only), already_saved, save warnings via notices, upload_max_bytes enforced client-side with the server error text on 413, project_max_bytes warning, headCode in the Preview font scan, pinned backend heads. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eb401cd979
commit
9d425afa29
17 files changed
+581
-38
No files matched your search
@@ -75,3 +75,18 @@ describe('NoticeHost', () => {
|
||||
act(() => r.unmount());
|
||||
});
|
||||
});
|
||||
|
||||
describe('NoticeHost shows upload refusals', () => {
|
||||
test('an upload error reported by the upload helpers becomes an error notice with the server text', async () => {
|
||||
const { reportUploadError } = await import('../utils/site-limits');
|
||||
const el = document.createElement('div');
|
||||
document.body.appendChild(el);
|
||||
let r: ReturnType<typeof createRoot>;
|
||||
act(() => { r = createRoot(el); r.render(<NoticeProvider><NoticeHost /></NoticeProvider>); });
|
||||
act(() => { reportUploadError('That file is too large. The site builder accepts files up to 64 MB.'); });
|
||||
const alert = el.querySelector('[role="alert"]');
|
||||
expect(alert?.textContent).toContain('That file is too large. The site builder accepts files up to 64 MB.');
|
||||
act(() => { r.unmount(); });
|
||||
el.remove();
|
||||
});
|
||||
});
|
||||
@@ -1,9 +1,12 @@
|
||||
import React from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import { useNotices } from '../state/NoticeContext';
|
||||
import { onUploadError } from '../utils/site-limits';
|
||||
|
||||
/** Renders the active notice stack (bottom-left; above the bars on mobile). */
|
||||
export const NoticeHost: React.FC = () => {
|
||||
const { notices, dismiss } = useNotices();
|
||||
const { notices, dismiss, notify } = useNotices();
|
||||
// Upload helpers have no React context: they report refusals on a small bus.
|
||||
useEffect(() => onUploadError((message) => { notify({ id: 'upload-error', kind: 'error', message }); }), [notify]);
|
||||
if (notices.length === 0) return null;
|
||||
return (
|
||||
<div className="notice-host">
|
||||
|
||||
Reference in new issue
Block a user