diff options
| author | Adam Soltys <[email protected]> | 2026-09-29 08:36:41 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-09-29 08:36:41 -0700 |
| commit | 6ee2e4e000c9513d09c98554ed0162a97a4f7824 (patch) | |
| tree | ec4c234ae47223eb1209a1e234120a82ae76d343 /tools | |
| parent | bdb8c3878df0439e3ebbcede5e2555f949a0cd7a (diff) | |
| download | coinosv3-6ee2e4e000c9513d09c98554ed0162a97a4f7824.tar.gz coinosv3-6ee2e4e000c9513d09c98554ed0162a97a4f7824.zip | |
Discard canceled post drafts
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/post-cancel-test.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/post-cancel-test.js b/tools/post-cancel-test.js new file mode 100644 index 0000000..5527bf2 --- /dev/null +++ b/tools/post-cancel-test.js @@ -0,0 +1,17 @@ +// Canceling a new post closes the composer and discards every part of its +// saved state, including a late attachment result. +import assert from 'node:assert/strict'; + +const source = await Bun.file('src/features/messages.js').text(); +const start = source.indexOf('function cancelPost()'); +const end = source.indexOf('\n }', start); +const cancel = source.slice(start, end); +assert(start > 0, 'post cancel handler exists'); +assert(cancel.includes('postAttachGeneration++'), 'late uploads are invalidated'); +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'); + +console.log('✓ Cancel closes the new-post form and removes its complete saved draft'); |
