From 97b6258797da245c6e2bb694befca281e9504189 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 7 Jul 2024 09:19:50 +1000 Subject: [PATCH] [PUI] Fix saveNotes callback (#7545) * [PUI] Fix saveNotes callback * add delay to playwright test --- src/frontend/src/components/editors/NotesEditor.tsx | 7 ++++++- src/frontend/tests/pages/pui_part.spec.ts | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/components/editors/NotesEditor.tsx b/src/frontend/src/components/editors/NotesEditor.tsx index c849311f99..2d04ca75a6 100644 --- a/src/frontend/src/components/editors/NotesEditor.tsx +++ b/src/frontend/src/components/editors/NotesEditor.tsx @@ -142,7 +142,12 @@ export default function NotesEditor({ // Callback to save notes to the server const saveNotes = useCallback(() => { - const markdown = ref.current?.getMarkdown() ?? ''; + const markdown = ref.current?.getMarkdown(); + + if (!noteUrl || markdown === undefined) { + return; + } + api .patch(noteUrl, { notes: markdown }) .then(() => { diff --git a/src/frontend/tests/pages/pui_part.spec.ts b/src/frontend/tests/pages/pui_part.spec.ts index bcf8d86ff1..92df792a54 100644 --- a/src/frontend/tests/pages/pui_part.spec.ts +++ b/src/frontend/tests/pages/pui_part.spec.ts @@ -212,6 +212,7 @@ test('PUI - Pages - Part - Notes', async ({ page }) => { .fill('This is some data\n'); // Save + await page.waitForTimeout(1000); await page.getByLabel('save-notes').click(); await page.getByText('Notes saved successfully').waitFor();