diff --git a/apps/web/src/app/api/auth/_shared/__tests__/buildHandoffBridgeHtml.test.ts b/apps/web/src/app/api/auth/_shared/__tests__/buildHandoffBridgeHtml.test.ts new file mode 100644 index 0000000000..c20a287c28 --- /dev/null +++ b/apps/web/src/app/api/auth/_shared/__tests__/buildHandoffBridgeHtml.test.ts @@ -0,0 +1,53 @@ +import { describe, it, expect } from 'vitest'; +import { buildHandoffBridgeHtml } from '../buildHandoffBridgeHtml'; + +describe('buildHandoffBridgeHtml', () => { + const baseParams = { + deepLink: 'pagespace://auth-exchange?code=abc123&provider=google', + title: "You're signed in", + body: 'Return to the desktop app — you can close this window.', + }; + + it('embeds the deep link in a meta refresh tag', () => { + const html = buildHandoffBridgeHtml(baseParams); + expect(html).toContain('http-equiv="refresh"'); + // Ampersands inside attributes must be entity-encoded + expect(html).toContain('content="0; url=pagespace://auth-exchange?code=abc123&provider=google"'); + }); + + it('embeds the deep link in the noscript anchor fallback', () => { + const html = buildHandoffBridgeHtml(baseParams); + expect(html).toContain('