fix: append parsed nodes when loading initial HTML into the Lexical editor

EditorShell's ingest called $generateNodesFromDOM but discarded the
returned nodes, so stored content never appeared in the WYSIWYG editor
in edit mode (the E2E edit test only checked title/points and missed it).
The parsed nodes are now appended to the root (kept empty-paragraph
default when nothing parses).

Hardening tests added while auditing the M6 test checklist:
- E2E: edit view asserts the stored body renders in the editor; new
  hostile-HTML test loads <script> tags, onerror/onload handlers and
  javascript: links through the real editor and asserts none survive
  into the contenteditable and nothing executes.
- E2E/unit: create button is disabled while the request is in flight.
- Backend: SQL metacharacters in the search term behave as literal
  text and leave the table intact.

Milestone doc updated: QA checklist items now cite their tests, plus a
QA-findings note for the ingest bug.
This commit is contained in:
Daniel Samson committed 2026-10-30 21:58:23 +00:00
1 parent b440809548
commit e62fad4a10
5 files changed
+104 -3

No files matched your search

@@ -179,6 +179,28 @@ describe('EditItemPage (create)', () => {
);
});
it('disables the create button while the request is in flight', async () => {
let resolveCreate!: (value: AdminItem) => void;
vi.mocked(adminCreateItem).mockReturnValueOnce(
new Promise<AdminItem>((resolve) => {
resolveCreate = resolve;
}),
);
renderAt('/admin/items/new');
await screen.findByTestId('lexical-stub');
fireEvent.change(screen.getByLabelText(/^Title/), {
target: { value: 'Pending' },
});
screen.getByRole('button', { name: /create item/i }).click();
const button = screen.getByRole('button', { name: /create item/i });
await waitFor(() => expect(button).toBeDisabled());
resolveCreate({ ...ITEM, id: 99, title: 'Pending' });
expect(await screen.findByTestId('dashboard-stub')).toBeInTheDocument();
});
it('shows the backend error when the create request fails', async () => {
vi.mocked(adminCreateItem).mockRejectedValue(
new ApiError(422, 'Validation failed', 'validation_error'),