mirror of
https://github.com/nexu-io/open-design.git
synced 2026-10-27 09:51:12 +01:00
* feat(analytics): attribute desktop downloads * fix(analytics): initialize attribution routes after HTTP deps * feat(analytics): bridge first-party browser opens * feat(analytics): bridge first-party anchor opens * fix(analytics): make attribution claims idempotent * fix(analytics): record pending attribution results * chore(analytics): bind landing attribution KV * fix(ci): remove landing preview wrangler config override * fix(landing): resolve download attribution function * fix(analytics): harden attribution token consumption * fix(analytics): preserve same-installation claim retries * fix(analytics): merge recovered attribution retries * fix(analytics): preserve attributed browser links * fix(analytics): clear attribution on privacy reset * fix(analytics): bridge stopped AMR console links * fix(ci): deploy attribution schema before Pages * fix(ci): run attribution migrations with Wrangler 4 --------- Co-authored-by: Siri-Ray <2667192167@qq.com> Co-authored-by: PerishCode <perishcode@gmail.com>
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
|
|
import { openFirstPartyExternalLinkFromClick } from '../src/first-party-external-link';
|
|
|
|
describe('openFirstPartyExternalLinkFromClick', () => {
|
|
it('bridges the final URL after a bubbling AMR handler appends attribution parameters', () => {
|
|
const opened = vi.fn();
|
|
const anchor = document.createElement('a');
|
|
anchor.href = 'https://open-design.ai/console';
|
|
anchor.addEventListener('click', () => {
|
|
const url = new URL(anchor.href);
|
|
url.searchParams.set('od_origin', 'open_design');
|
|
url.searchParams.set('od_entry_id', 'settings');
|
|
url.searchParams.set('od_device_id', 'install-123');
|
|
anchor.href = url.toString();
|
|
});
|
|
document.body.append(anchor);
|
|
const listener = (event: MouseEvent) => openFirstPartyExternalLinkFromClick(event, opened);
|
|
document.addEventListener('click', listener);
|
|
const event = new MouseEvent('click', { bubbles: true, cancelable: true });
|
|
anchor.dispatchEvent(event);
|
|
document.removeEventListener('click', listener);
|
|
|
|
expect(event.defaultPrevented).toBe(true);
|
|
expect(opened).toHaveBeenCalledWith(
|
|
'https://open-design.ai/console?od_origin=open_design&od_entry_id=settings&od_device_id=install-123',
|
|
);
|
|
});
|
|
});
|