From 62b8e37109464aca875e306269c181faf6c64ae3 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 29 Sep 2026 08:37:25 -0700 Subject: Confirm discarding substantial post drafts --- tools/post-cancel-test.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/post-cancel-test.js b/tools/post-cancel-test.js index 5527bf2..217e743 100644 --- a/tools/post-cancel-test.js +++ b/tools/post-cancel-test.js @@ -12,6 +12,9 @@ assert(cancel.includes('ui.profCompose = null'), 'composer is closed'); assert(cancel.includes('ui.postMedia = []'), 'pending attachment metadata is removed'); assert(cancel.includes('ui.postPreview = false'), 'preview state is removed'); assert(cancel.includes('discardDraft(POST_DRAFT)'), 'persisted draft is removed immediately'); -assert(source.includes("onClick: cancelPost }, t('cancel')"), 'Cancel button uses the discard handler'); +assert(source.includes("composeText().length > 20"), 'drafts over 20 characters require confirmation'); +assert(source.includes("ui.postUploading || (ui.postMedia || []).length"), 'attachments require confirmation'); +assert(source.includes("onClick: requestCancelPost }, t('cancel')"), 'Cancel button uses the guarded discard handler'); +assert(source.includes("onClick: cancelPost }, t('postDiscard')"), 'warning can confirm the discard'); -console.log('✓ Cancel closes the new-post form and removes its complete saved draft'); +console.log('✓ Cancel warns for substantial drafts, then closes the form and removes its complete saved draft'); -- cgit v1.2.3