-
Notifications
You must be signed in to change notification settings - Fork 2
feat(app): replace release notes dialog with subtle toast (#486) #488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6989634
feat(ui): add subtle toast variant and onDismiss hook
Astro-Han 5e8bbb9
feat(app): replace release notes dialog with subtle toast
Astro-Han d8788a6
chore(app): remove DialogReleaseNotes
Astro-Han c2b6840
feat(app): rename release notes i18n keys to toast namespace
Astro-Han 48ccb80
refactor(app): drop unused release notes toast i18n keys
Astro-Han 27e6601
test(app): e2e coverage for release notes toast
Astro-Han dfebfcb
fix(app): only mark release seen on explicit user dismiss
Astro-Han 78946c9
test(app): use expect.poll for release notes toast e2e
Astro-Han 5909d69
style(test): rename release notes spec constants to SCREAMING_SNAKE_CASE
Astro-Han 388681b
fix(app): preserve filtered releases when slicing toast window
Astro-Han 23df996
fix(app): unify toast locale across merged release segments
Astro-Han 5216a8d
fix(ui): mark toast seen on swipe and escape dismissal
Astro-Han 7fc344a
chore(opencode): register release notes smoke test in inventory
Astro-Han c7a2dfa
fix(app): anchor toast title and link on current app version
Astro-Han 2eaeacf
fix(ui): harden toast dismiss paths
Astro-Han 3e55c4a
fix(app): tag every description segment that does not match current v…
Astro-Han 9399c5d
test(app): cover release notes action click path
Astro-Han ee020cf
test(app): extract LANGUAGE_KEY constant in release notes spec
Astro-Han File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
350 changes: 350 additions & 0 deletions
350
packages/app/e2e/release-notes/release-notes-toast.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,350 @@ | ||
| import { test, expect, settingsKey } from "../fixtures" | ||
|
|
||
| const RELEASES_URL_PATTERN = "**/api.github.com/repos/Astro-Han/pawwork/releases**" | ||
| const HIGHLIGHTS_KEY = "highlights.v1" | ||
|
|
||
| const SINGLE_RELEASE_PAYLOAD = [ | ||
| { | ||
| tag_name: "v2026.5.7", | ||
| body: [ | ||
| "## App Update Notice", | ||
| "", | ||
| "Important refresh for this release.", | ||
| "", | ||
| "- Added subtle toast variant", | ||
| "- Replaced release notes dialog", | ||
| ].join("\n"), | ||
| }, | ||
| ] | ||
|
|
||
| const MULTI_VERSION_PAYLOAD = [ | ||
| { | ||
| tag_name: "v2026.5.7", | ||
| body: "## App Update Notice\n\n- Newest highlight A\n- Newest highlight B\n", | ||
| }, | ||
| { | ||
| tag_name: "v2026.5.6", | ||
| body: "## App Update Notice\n\n- Older highlight C\n", | ||
| }, | ||
| ] | ||
|
|
||
| const LOCALIZED_PAYLOAD = [ | ||
| { | ||
| tag_name: "v2026.5.7", | ||
| body: [ | ||
| "## App Update Notice", | ||
| "", | ||
| "- English bullet only", | ||
| "", | ||
| "## 中文版本", | ||
| "", | ||
| "### 主要更新", | ||
| "", | ||
| "- 中文要点 A", | ||
| "- 中文要点 B", | ||
| ].join("\n"), | ||
| }, | ||
| ] | ||
|
|
||
| const TOAST_SELECTOR = '[data-component="toast"][data-variant="subtle"]' | ||
| const TOAST_TITLE_SELECTOR = `${TOAST_SELECTOR} [data-slot="toast-title"]` | ||
| const TOAST_DESCRIPTION_SELECTOR = `${TOAST_SELECTOR} [data-slot="toast-description"]` | ||
| const TOAST_ACTION_SELECTOR = `${TOAST_SELECTOR} [data-slot="toast-action"]` | ||
| const TOAST_CLOSE_BUTTON_SELECTOR = `${TOAST_SELECTOR} [data-slot="toast-close-button"]` | ||
| const TOAST_ICON_SELECTOR = `${TOAST_SELECTOR} [data-slot="toast-icon"]` | ||
|
|
||
| test.describe("release notes toast", () => { | ||
| test("@smoke shows subtle toast when stored version is older than current", async ({ page, gotoSession }) => { | ||
| await page.route(RELEASES_URL_PATTERN, async (route) => { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| contentType: "application/json", | ||
| body: JSON.stringify(SINGLE_RELEASE_PAYLOAD), | ||
| }) | ||
| }) | ||
|
|
||
| await page.addInitScript((key) => { | ||
| localStorage.setItem(key, JSON.stringify({ version: "2026.5.6" })) | ||
| }, HIGHLIGHTS_KEY) | ||
|
|
||
| await gotoSession() | ||
|
|
||
| await expect(page.locator(TOAST_SELECTOR)).toBeVisible({ timeout: 10_000 }) | ||
| await expect(page.locator(TOAST_TITLE_SELECTOR)).toHaveText("Updated to v2026.5.7") | ||
| await expect(page.locator(TOAST_DESCRIPTION_SELECTOR)).toContainText("Important refresh for this release.") | ||
| await expect(page.locator(TOAST_DESCRIPTION_SELECTOR)).toContainText("• Added subtle toast variant") | ||
| await expect(page.locator(TOAST_DESCRIPTION_SELECTOR)).toContainText("• Replaced release notes dialog") | ||
| await expect(page.locator(TOAST_ACTION_SELECTOR)).toHaveText("Full release notes →") | ||
| await expect(page.locator(TOAST_ICON_SELECTOR)).toBeVisible() | ||
| }) | ||
|
|
||
| test("clicking the close button marks the current version as seen", async ({ page, gotoSession }) => { | ||
| await page.route(RELEASES_URL_PATTERN, async (route) => { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| contentType: "application/json", | ||
| body: JSON.stringify(SINGLE_RELEASE_PAYLOAD), | ||
| }) | ||
| }) | ||
|
|
||
| await page.addInitScript((key) => { | ||
| localStorage.setItem(key, JSON.stringify({ version: "2026.5.6" })) | ||
| }, HIGHLIGHTS_KEY) | ||
|
|
||
| await gotoSession() | ||
| await expect(page.locator(TOAST_SELECTOR)).toBeVisible({ timeout: 10_000 }) | ||
|
|
||
| await page.locator(TOAST_CLOSE_BUTTON_SELECTOR).click() | ||
| await expect(page.locator(TOAST_SELECTOR)).toBeHidden() | ||
|
|
||
| await expect | ||
| .poll(() => | ||
| page.evaluate((key) => { | ||
| const raw = localStorage.getItem(key) | ||
| return raw ? (JSON.parse(raw)?.version ?? null) : null | ||
| }, HIGHLIGHTS_KEY), | ||
| ) | ||
| .toBe("2026.5.7") | ||
| }) | ||
|
|
||
| test("pressing Escape marks the current version as seen", async ({ page, gotoSession }) => { | ||
| await page.route(RELEASES_URL_PATTERN, async (route) => { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| contentType: "application/json", | ||
| body: JSON.stringify(SINGLE_RELEASE_PAYLOAD), | ||
| }) | ||
| }) | ||
|
|
||
| await page.addInitScript((key) => { | ||
| localStorage.setItem(key, JSON.stringify({ version: "2026.5.6" })) | ||
| }, HIGHLIGHTS_KEY) | ||
|
|
||
| await gotoSession() | ||
| await expect(page.locator(TOAST_SELECTOR)).toBeVisible({ timeout: 10_000 }) | ||
|
|
||
| // Escape key dismisses via Kobalte's onEscapeKeyDown → close() path, | ||
| // which bypasses CloseButton's onClick. This guards the same code path | ||
| // used by swipe-to-dismiss on touch devices: both must mark the version | ||
| // as seen via the onSwipeEnd / onEscapeKeyDown handlers we add to the | ||
| // Toast root, otherwise the toast re-shows on next launch. | ||
| await page.locator(TOAST_SELECTOR).focus() | ||
| await page.keyboard.press("Escape") | ||
| await expect(page.locator(TOAST_SELECTOR)).toBeHidden() | ||
|
|
||
| await expect | ||
| .poll(() => | ||
| page.evaluate((key) => { | ||
| const raw = localStorage.getItem(key) | ||
| return raw ? (JSON.parse(raw)?.version ?? null) : null | ||
| }, HIGHLIGHTS_KEY), | ||
| ) | ||
| .toBe("2026.5.7") | ||
| }) | ||
|
|
||
| test("releaseNotes=false suppresses the toast", async ({ page, gotoSession }) => { | ||
| await page.route(RELEASES_URL_PATTERN, async (route) => { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| contentType: "application/json", | ||
| body: JSON.stringify(SINGLE_RELEASE_PAYLOAD), | ||
| }) | ||
| }) | ||
|
|
||
| await page.addInitScript( | ||
| ([highlightsKey, settingsStorageKey]) => { | ||
| localStorage.setItem(highlightsKey, JSON.stringify({ version: "2026.5.6" })) | ||
| const existing = localStorage.getItem(settingsStorageKey) | ||
| const parsed = existing ? JSON.parse(existing) : {} | ||
| parsed.general = { ...(parsed.general ?? {}), releaseNotes: false } | ||
| localStorage.setItem(settingsStorageKey, JSON.stringify(parsed)) | ||
| }, | ||
| [HIGHLIGHTS_KEY, settingsKey], | ||
| ) | ||
|
|
||
| await gotoSession() | ||
|
|
||
| // releaseNotes=false short-circuits start() to call markSeen() synchronously, | ||
| // so polling localStorage is the deterministic readiness signal that the | ||
| // controller has run. Once the version advances, we know the toast was | ||
| // suppressed (not merely "not yet rendered"). | ||
| await expect | ||
| .poll(() => | ||
| page.evaluate((key) => { | ||
| const raw = localStorage.getItem(key) | ||
| return raw ? (JSON.parse(raw)?.version ?? null) : null | ||
| }, HIGHLIGHTS_KEY), | ||
| ) | ||
| .toBe("2026.5.7") | ||
| await expect(page.locator(TOAST_SELECTOR)).toHaveCount(0) | ||
| }) | ||
|
|
||
| test("merges multiple skipped versions into one description", async ({ page, gotoSession }) => { | ||
| await page.route(RELEASES_URL_PATTERN, async (route) => { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| contentType: "application/json", | ||
| body: JSON.stringify(MULTI_VERSION_PAYLOAD), | ||
| }) | ||
| }) | ||
|
|
||
| await page.addInitScript((key) => { | ||
| localStorage.setItem(key, JSON.stringify({ version: "2026.5.5" })) | ||
| }, HIGHLIGHTS_KEY) | ||
|
|
||
| await gotoSession() | ||
|
|
||
| await expect(page.locator(TOAST_SELECTOR)).toBeVisible({ timeout: 10_000 }) | ||
| await expect(page.locator(TOAST_TITLE_SELECTOR)).toHaveText("Updated to v2026.5.7") | ||
| const description = page.locator(TOAST_DESCRIPTION_SELECTOR) | ||
| await expect(description).toContainText("• Newest highlight A") | ||
| await expect(description).toContainText("• Newest highlight B") | ||
| await expect(description).toContainText("v2026.5.6") | ||
| await expect(description).toContainText("• Older highlight C") | ||
| }) | ||
|
|
||
| test("falls back to English when zh release section is missing", async ({ page, gotoSession }) => { | ||
| await page.route(RELEASES_URL_PATTERN, async (route) => { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| contentType: "application/json", | ||
| body: JSON.stringify([ | ||
| { | ||
| tag_name: "v2026.5.7", | ||
| body: "## App Update Notice\n\n- English fallback bullet\n", | ||
| }, | ||
| ]), | ||
| }) | ||
| }) | ||
|
|
||
| await page.addInitScript((highlightsKey) => { | ||
| localStorage.setItem(highlightsKey, JSON.stringify({ version: "2026.5.6" })) | ||
| localStorage.setItem("pawwork.global.dat:language", JSON.stringify({ locale: "zh" })) | ||
| }, HIGHLIGHTS_KEY) | ||
|
|
||
| await gotoSession() | ||
|
|
||
| await expect(page.locator(TOAST_SELECTOR)).toBeVisible({ timeout: 10_000 }) | ||
| // Title and action must follow the parsed body's locale (en) — never mix with zh UI locale. | ||
| await expect(page.locator(TOAST_TITLE_SELECTOR)).toHaveText("Updated to v2026.5.7") | ||
| await expect(page.locator(TOAST_ACTION_SELECTOR)).toHaveText("Full release notes →") | ||
| await expect(page.locator(TOAST_DESCRIPTION_SELECTOR)).toContainText("• English fallback bullet") | ||
| }) | ||
|
|
||
| test("uses zh title and action when zh release section is present", async ({ page, gotoSession }) => { | ||
| await page.route(RELEASES_URL_PATTERN, async (route) => { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| contentType: "application/json", | ||
| body: JSON.stringify(LOCALIZED_PAYLOAD), | ||
| }) | ||
| }) | ||
|
|
||
| await page.addInitScript((highlightsKey) => { | ||
| localStorage.setItem(highlightsKey, JSON.stringify({ version: "2026.5.6" })) | ||
| localStorage.setItem("pawwork.global.dat:language", JSON.stringify({ locale: "zh" })) | ||
| }, HIGHLIGHTS_KEY) | ||
|
|
||
| await gotoSession() | ||
|
|
||
| await expect(page.locator(TOAST_SELECTOR)).toBeVisible({ timeout: 10_000 }) | ||
| await expect(page.locator(TOAST_TITLE_SELECTOR)).toHaveText("已更新到 v2026.5.7") | ||
| await expect(page.locator(TOAST_ACTION_SELECTOR)).toHaveText("查看完整发布说明 →") | ||
| await expect(page.locator(TOAST_DESCRIPTION_SELECTOR)).toContainText("• 中文要点 A") | ||
| await expect(page.locator(TOAST_DESCRIPTION_SELECTOR)).toContainText("• 中文要点 B") | ||
| }) | ||
|
|
||
| test("title and link anchor on the app's current version even when its release lacks a notice in the resolved locale", async ({ | ||
| page, | ||
| gotoSession, | ||
| }) => { | ||
| await page.route(RELEASES_URL_PATTERN, async (route) => { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| contentType: "application/json", | ||
| body: JSON.stringify([ | ||
| { | ||
| tag_name: "v2026.5.7", | ||
| // newest release: zh-only notice, no English App Update Notice | ||
| body: ["## 中文版本", "", "### 主要更新", "", "- 仅中文要点"].join("\n"), | ||
| }, | ||
| { | ||
| tag_name: "v2026.5.6", | ||
| // older skipped release: en-only notice, no 中文版本 | ||
| body: "## App Update Notice\n\n- older en-only bullet\n", | ||
| }, | ||
| ]), | ||
| }) | ||
| }) | ||
|
|
||
| await page.addInitScript((highlightsKey) => { | ||
| localStorage.setItem(highlightsKey, JSON.stringify({ version: "2026.5.5" })) | ||
| localStorage.setItem("pawwork.global.dat:language", JSON.stringify({ locale: "zh" })) | ||
| }, HIGHLIGHTS_KEY) | ||
|
|
||
| await gotoSession() | ||
|
|
||
| await expect(page.locator(TOAST_SELECTOR)).toBeVisible({ timeout: 10_000 }) | ||
| // First-pass zh resolves to mixed (v2026.5.7 zh + v2026.5.6 en fallback), | ||
| // so we re-resolve the whole window in English. The English window does | ||
| // not contain v2026.5.7 (no App Update Notice there), but the title and | ||
| // link must still anchor on the app's current version, not summaries[0]. | ||
| await expect(page.locator(TOAST_TITLE_SELECTOR)).toHaveText("Updated to v2026.5.7") | ||
| await expect(page.locator(TOAST_ACTION_SELECTOR)).toHaveText("Full release notes →") | ||
| // Description's first segment must carry the v2026.5.6 tag, otherwise | ||
| // the older release's bullet would read as if it described the current | ||
| // version (the title says v2026.5.7 but summaries[0] here is v2026.5.6 | ||
| // because the English fallback dropped v2026.5.7). | ||
| await expect(page.locator(TOAST_DESCRIPTION_SELECTOR)).toContainText("v2026.5.6") | ||
| await expect(page.locator(TOAST_DESCRIPTION_SELECTOR)).toContainText("• older en-only bullet") | ||
| }) | ||
|
|
||
| test("falls back to English across the whole window when an older skipped release has no zh section", async ({ | ||
| page, | ||
| gotoSession, | ||
| }) => { | ||
| await page.route(RELEASES_URL_PATTERN, async (route) => { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| contentType: "application/json", | ||
| body: JSON.stringify([ | ||
| { | ||
| tag_name: "v2026.5.7", | ||
| body: [ | ||
| "## App Update Notice", | ||
| "", | ||
| "- newest en bullet", | ||
| "", | ||
| "## 中文版本", | ||
| "", | ||
| "### 主要更新", | ||
| "", | ||
| "- 最新中文 bullet", | ||
| ].join("\n"), | ||
| }, | ||
| { | ||
| tag_name: "v2026.5.6", | ||
| body: "## App Update Notice\n\n- older en only\n", | ||
| }, | ||
| ]), | ||
| }) | ||
| }) | ||
|
|
||
| await page.addInitScript((highlightsKey) => { | ||
| localStorage.setItem(highlightsKey, JSON.stringify({ version: "2026.5.5" })) | ||
| localStorage.setItem("pawwork.global.dat:language", JSON.stringify({ locale: "zh" })) | ||
| }, HIGHLIGHTS_KEY) | ||
|
|
||
| await gotoSession() | ||
|
|
||
| await expect(page.locator(TOAST_SELECTOR)).toBeVisible({ timeout: 10_000 }) | ||
| // The newest release has a zh section but the older skipped release does | ||
| // not. Spec #486 forbids mixing languages, so the entire toast — title, | ||
| // action, and every segment — must be English. | ||
| await expect(page.locator(TOAST_TITLE_SELECTOR)).toHaveText("Updated to v2026.5.7") | ||
| await expect(page.locator(TOAST_ACTION_SELECTOR)).toHaveText("Full release notes →") | ||
| await expect(page.locator(TOAST_DESCRIPTION_SELECTOR)).toContainText("• newest en bullet") | ||
| await expect(page.locator(TOAST_DESCRIPTION_SELECTOR)).toContainText("• older en only") | ||
| await expect(page.locator(TOAST_DESCRIPTION_SELECTOR)).not.toContainText("中文") | ||
| }) | ||
| }) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.