feat(web): improve invite landing recovery

This commit is contained in:
jjbrunton committed 2026-09-06 12:31:48 +01:00
1 parent 402c027b14
commit ff2cf09170
4 files changed
+187 -63

No files matched your search

+28 -3
View File
@@ -12,12 +12,13 @@ describe('/join/[code] JoinClient', () => {
expect(source).not.toMatch(/fetch\(/)
})
it('attempts the app scheme link and shows the raw code fallback', async () => {
it('only attempts the app scheme link after an explicit Open in Sauci action', async () => {
const source = await readFile(componentPath, 'utf8')
expect(source).toContain('buildInviteSchemeUrl')
expect(source).toContain('Open in Sauci')
expect(source.indexOf('const handleOpenInApp')).toBeLessThan(source.indexOf('window.location.href = buildInviteSchemeUrl'))
expect(source).toContain('invite-code-display')
expect(source).toContain('Copy code')
})
it('copies only the raw code, not a share message', async () => {
@@ -37,13 +38,37 @@ describe('/join/[code] JoinClient', () => {
const source = await readFile(componentPath, 'utf8')
expect(source).toContain("posthog?.capture('join_page_viewed'")
expect(source).toContain("posthog?.capture('join_page_code_copied')")
expect(source).toContain("posthog?.capture('join_page_code_copied'")
expect(source).toContain("posthog?.capture('join_page_store_button_clicked'")
expect(source).toContain("posthog?.capture('join_page_open_app_clicked'")
expect(source).toContain("posthog?.capture('join_page_open_app_fallback_shown'")
expect(source).toContain("posthog?.capture('join_page_offline_shown'")
})
it('does not put an invite code in a PostHog payload', async () => {
const source = await readFile(componentPath, 'utf8')
expect(source).not.toMatch(/posthog\?\.capture\([^)]*normalizedCode/)
expect(source).not.toMatch(/posthog\?\.capture\([^)]*\bcode\s*:/)
})
it('uses the required recovery and accessibility states', async () => {
const source = await readFile(componentPath, 'utf8')
expect(source).toContain('Copy this before you install')
expect(source).toContain('setTimeout(() =>')
expect(source).toContain('}, 1500)')
expect(source).toContain("document.visibilityState === 'visible'")
expect(source).toContain("aria-live=\"polite\"")
expect(source).toContain('navigator.onLine')
expect(source).toContain('surface-solid')
expect(source).not.toContain('glass-light')
})
it('shows a clear fallback message for a malformed invite code', async () => {
const source = await readFile(componentPath, 'utf8')
expect(source).toContain('Invite link not recognized')
expect(source).not.toContain('has expired')
})
})