Files
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

80 lines
3.2 KiB
TypeScript

import { Page } from '@playwright/test'
import { Scene } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
type LowercaseEnum<T> = {
[K in keyof T]: T[K] extends string ? Lowercase<T[K]> : never
}[keyof T]
/** Derive possible identifiers from the Scene enum. Not all of them are
* actually nav items. This will help keep e2e tests up-to-date when
* refactoring scenes though. */
export type Identifier = LowercaseEnum<typeof Scene>
const IDENTIFIER_URL_FALLBACKS: Record<string, string> = {
projecthomepage: urls.projectHomepage(),
activity: urls.activity(),
datamanagement: urls.eventDefinitions(),
'event-definitions': urls.eventDefinitions(),
annotations: urls.annotations(),
toolbar: urls.toolbarLaunch(),
'sql-editor': urls.sqlEditor(),
settings: urls.settings(),
surveys: '/surveys',
cohorts: '/cohorts',
dashboards: '/dashboard',
people: '/persons',
persons: '/persons',
action: '/data-management/actions',
'product-analytics': '/insights',
insight: '/insights/new',
insights: '/insights',
}
function teamIdFromPath(pathname: string): number | null {
const match = pathname.match(/^\/project\/(\d+)(?:\/|$)/)
return match ? Number(match[1]) : null
}
export class Navigation {
readonly page: Page
constructor(page: Page) {
this.page = page
}
async openHome(): Promise<void> {
await this.page.goto(urls.projectRoot())
}
async openMenuItem(name: string): Promise<void> {
// The legacy PanelLayoutNavBar exposed every scene as `menu-item-<name>` /
// `navbar-<name>`. The AI-first navbar only renders a few `nav-item-*` test-ids
// (and only when the parent collapsible section is expanded), so for known scenes
// we navigate by URL — that's the most reliable cross-layout behavior.
if (IDENTIFIER_URL_FALLBACKS[name]) {
// Caddy proxies the literal paths `/surveys`, `/surveys/`, `/api/surveys`
// to the SDK's hypercache-server, and going through `/project/<teamId>/...`
// avoids that matcher and lets the app load normally.
await this.page.waitForURL(/\/project\/\d+(?:\/|$)/, { timeout: 10_000 }).catch(() => {})
const teamId = teamIdFromPath(new URL(this.page.url()).pathname)
const path = IDENTIFIER_URL_FALLBACKS[name]
const target = teamId !== null ? `/project/${teamId}${path}` : path
await this.page.goto(target)
} else {
// Fall back to legacy selectors for scenes we haven't mapped yet.
const navbarSelector = this.page.getByTestId(`navbar-${name}`)
const menuSelector = this.page.getByTestId(`menu-item-${name}`)
const element = (await navbarSelector.count()) > 0 ? navbarSelector : menuSelector
await element.click()
}
// Wait for navigation to complete and page to be ready
await this.page.waitForLoadState('domcontentloaded')
// Additional wait with timeout for network to settle (catches lazy-loaded components)
await this.page.waitForLoadState('networkidle', { timeout: 5000 }).catch(() => {
// Ignore timeout - networkidle may not occur with long-polling
})
}
}