Files
insights-js/packages/react-native/test/resolveSurveyAlignment.spec.ts
zooqueenandzeekay 4712ee9d98 chore: complete posthog->insights rebrand (zero @posthog/* identity)
Decomplect the half-finished fork so the dependency graph has ONE source
with no posthog package identity, living under github.com/hanzoinsights.

LAYER 1 (package identity): rename straggler package.json names —
@posthog/next->@hanzo/insights-next (Next.js SDK; distinct from the existing
@hanzo/insights-nextjs config helper), @posthog/mcp->@hanzo/insights-mcp,
@posthog/plugin-utils->@hanzo/insights-plugin-utils,
@posthog/react-slim->@hanzo/react-slim, @posthog-tooling/release->
@hanzo/insights-tooling-release, and the @posthog/rrweb* family->@hanzo/rrweb*
(matching the already-published @hanzo/rrweb*@0.0.47 + minimumReleaseAgeExclude).
Repoint every repository.url/homepage/bugs to github.com/hanzoinsights/insights-js
and rebrand the PostHog author/description identity to Hanzo AI.

LAYER 2 (cross-package imports): rewrite every internal @posthog/* import to its
@hanzo/insights*|@hanzo/rrweb* equivalent and the bare module specifiers
posthog-js->@hanzo/insights, posthog-node->@hanzo/insights-node, mirrored in
package.json deps + the pnpm-lock importer keys. Result: 0 @posthog/* specifiers
in packages/tooling/examples/playground source.

LAYER 4 (wire protocol) PRESERVED: window.posthog global, ph_* keys,
$-prefixed event names, distinct_id, /decide, /e/, /flags, and the
__PosthogExtensions__ hook are left unchanged — the Insights server expects them.

Also repair pre-existing fork merge damage that blocked compilation (unrelated to
naming; identical to origin/main): restore the @hanzo/insights-core ./process
subpath (spawn-local/utils, re-matching the published artifact), the lost
constructor/var declarations in core + node clients, the mangled
external-scripts-loader, the missing TreeShakeable/isPlainError imports, the
DeviceId enum member, and stale ../posthog-core-stateless module paths. 26/34
turbo build tasks now pass; remaining failures (browser/react-native and their
dependents) are pre-existing fork damage, not rebrand-caused.
2026-07-16 09:09:17 -07:00

41 lines
1.8 KiB
TypeScript

import { SurveyPosition } from '@hanzo/insights-core'
import { resolveSurveyAlignment } from '../src/surveys/surveys-utils'
describe('resolveSurveyAlignment', () => {
it.each([
[SurveyPosition.TopLeft, 'flex-start', 'flex-start'],
[SurveyPosition.TopCenter, 'flex-start', 'center'],
[SurveyPosition.TopRight, 'flex-start', 'flex-end'],
[SurveyPosition.MiddleLeft, 'center', 'flex-start'],
[SurveyPosition.MiddleCenter, 'center', 'center'],
[SurveyPosition.MiddleRight, 'center', 'flex-end'],
[SurveyPosition.Left, 'flex-end', 'flex-start'],
[SurveyPosition.Center, 'flex-end', 'center'],
[SurveyPosition.Right, 'flex-end', 'flex-end'],
])('maps %s to vertical=%s, horizontal=%s', (position, vertical, horizontal) => {
expect(resolveSurveyAlignment(position)).toEqual({ vertical, horizontal })
})
it('falls back to the Center default when position is undefined', () => {
expect(resolveSurveyAlignment(undefined)).toEqual({ vertical: 'flex-end', horizontal: 'center' })
})
it('warns once and falls back to the default for unknown position strings', () => {
// Module-scope dedup of warned positions persists across tests, so use a
// unique unknown string per run to avoid coupling to other tests' state.
const unknown = `unknown-${Math.random().toString(36).slice(2)}`
const warn = jest.spyOn(console, 'warn').mockImplementation(() => {})
try {
const result = resolveSurveyAlignment(unknown)
expect(result).toEqual({ vertical: 'flex-end', horizontal: 'center' })
expect(warn).toHaveBeenCalledTimes(1)
expect(warn.mock.calls[0][0]).toContain(unknown)
// Calling again with the same unknown string does not re-warn.
resolveSurveyAlignment(unknown)
expect(warn).toHaveBeenCalledTimes(1)
} finally {
warn.mockRestore()
}
})
})