- ipalKit({ searchSettings }): switches off / reshapes Site Settings → Search & AI
without `seo`; read as options.searchSettings ?? options.seo?.searchSettings.
- shouldLoadGoogle moved to a pure module (analytics/shouldLoadGoogle.ts) and
exported from @intecion/ipal-kit and /client.
- consentLog.collectionOverrides and stats.collectionOverrides (object merges
access/admin/hooks key by key, function takes over), via the new exported
applyCollectionOverride / CollectionOverride. The stats view and dashboard
chart now follow the stats-visits read access, so overrides narrow them too.
All additive; defaults unchanged. Docs: AGENT.md, ipal-reference, consent,
stats, seo, analytics, ipal-setup.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
30 lines
1.7 KiB
TypeScript
30 lines
1.7 KiB
TypeScript
import { describe, expect, test } from 'vitest'
|
|
|
|
import { shouldLoadGoogle } from '../src/modules/analytics/shouldLoadGoogle.js'
|
|
|
|
const none = { analytics: false, marketing: false }
|
|
|
|
describe("Google tag and consent", () => {
|
|
test("'basic': no Google request before an analytics or marketing grant", () => {
|
|
expect(shouldLoadGoogle({ consentMode: 'basic', ready: true, state: none })).toBe(false)
|
|
expect(shouldLoadGoogle({ consentMode: 'basic', ready: true, state: { ...none, analytics: true } })).toBe(true)
|
|
expect(shouldLoadGoogle({ consentMode: 'basic', ready: true, state: { ...none, marketing: true } })).toBe(true)
|
|
})
|
|
|
|
test("'advanced' (default) loads with denied signals; `defer` still holds both back", () => {
|
|
expect(shouldLoadGoogle({ consentMode: 'advanced', ready: true, state: none })).toBe(true)
|
|
expect(shouldLoadGoogle({ consentMode: 'advanced', ready: false, state: none })).toBe(false)
|
|
expect(shouldLoadGoogle({ consentMode: 'basic', ready: false, state: { analytics: true } })).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('shouldLoadGoogle is public', () => {
|
|
test('exported from the root and /client, from a module without React', async () => {
|
|
const { readFileSync } = await import('node:fs')
|
|
const read = (p: string) => readFileSync(new URL(`../${p}`, import.meta.url), 'utf8')
|
|
expect(read('src/index.ts')).toMatch(/export \{ shouldLoadGoogle \} from '\.\/modules\/analytics\/shouldLoadGoogle\.js'/)
|
|
expect(read('src/exports/client.ts')).toMatch(/export \{ shouldLoadGoogle \} from '\.\.\/modules\/analytics\/shouldLoadGoogle\.js'/)
|
|
expect(read('src/modules/analytics/shouldLoadGoogle.ts')).not.toMatch(/^import|'use client'/m)
|
|
})
|
|
})
|