From 46c55496a1a5b511959d6148dea6b4d8f295862c Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Sat, 24 Oct 2026 20:46:48 -0400 Subject: [PATCH] fix(stories): show trimmed-story notice when the popup is blocked Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- scripts/story-dialog.test.mjs | 22 ++++++++++++++++++++++ stories/index.html | 6 ++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/scripts/story-dialog.test.mjs b/scripts/story-dialog.test.mjs index fcf9841..8fdca11 100644 --- a/scripts/story-dialog.test.mjs +++ b/scripts/story-dialog.test.mjs @@ -353,6 +353,28 @@ test("popup blocked: fallback link gets the prefilled URL and copy button yields assert.match(t.el("story-status").textContent, /^Copied\./); }); +test("popup blocked with truncated story: fallback revealed and trimmed-story notice shown", async () => { + const t = boot({ popupBlocked: true }); + const long = "x".repeat(STORY_MAX - 3) + " tail-that-gets-cut"; + t.el("opener-hero").dispatch("click"); + t.fill({ ...VALID, "story-text": long }); + t.submit(); + assert.equal(t.el("story-fallback").hidden, false, "fallback revealed"); + assert.match(t.el("story-status").textContent, /^Your story was trimmed to 1500 characters/, "trimmed-story notice shown when popup blocked"); + const href = new URL(t.el("story-fallback-link").href); + const story = href.searchParams.get("story"); + assert.equal(story, "x".repeat(STORY_MAX - 3), "fallback link carries the trimmed story"); +}); + +test("popup blocked with non-truncated story: fallback revealed but no notice shown", () => { + const t = boot({ popupBlocked: true }); + t.el("opener-hero").dispatch("click"); + t.fill(VALID); + t.submit(); + assert.equal(t.el("story-fallback").hidden, false, "fallback revealed"); + assert.equal(t.el("story-status").textContent, "", "no truncation notice when story not truncated"); +}); + test("copy button tells the user to use the prefilled link when the clipboard write is rejected", async () => { const t = boot({ popupBlocked: true, clipboardOverride: { clipboard: { writeText() { return Promise.reject(new Error("denied")); } } } }); t.el("opener-hero").dispatch("click"); diff --git a/stories/index.html b/stories/index.html index 4ebcc5d..62ff193 100644 --- a/stories/index.html +++ b/stories/index.html @@ -2,7 +2,7 @@ - + Contributor Stories — Hive Commons @@ -504,15 +504,17 @@

Open a contributor story draft

var issueUrl = buildIssue(data); issueText = markdown(data); var opened = window.open("", "_blank"); + var trimmedNotice = "Your story was trimmed to 1500 characters for the GitHub form. "; if (!opened) { fallbackLink.href = issueUrl; fallback.hidden = false; + if (data.story_truncated) status.textContent = trimmedNotice; return; } opened.opener = null; opened.location = issueUrl; var note = "Thanks — your story opened as a draft issue in a new tab. GitHub only prefills text fields, so pick your Role again" + (data.quote_ok ? " and re-tick Can we quote you by name?" : "") + ", then hit Submit new issue there to finish. Not signed in to GitHub? Email us or use the Discord link below."; - if (data.story_truncated) note = "Your story was trimmed to 1500 characters for the GitHub form. " + note; + if (data.story_truncated) note = trimmedNotice + note; status.textContent = note; });