mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-11-03 00:53:53 +00:00
We own the ingestion server (hanzoai/insights: Django + rust/capture + nodejs plugin) AND this SDK, so there is no external wire contract to preserve. The server is already 100% posthog-free; this SDK was the last laggard. - $last_posthog_reset -> $last_insights_reset. This FIXES A LIVE MISMATCH: the server taxonomy (insights/taxonomy/taxonomy.py, insights/insightsql/ai.py) already expected the insights form while the SDK emitted the posthog form. - __PosthogExtensions__ -> __InsightsExtensions__; all PostHog/posthog/POSTHOG identifiers -> Insights/insights/INSIGHTS (src, tests, playground, playwright, scripts, rrweb subpackages, package.json keywords). - Hosts: DEFAULT_PLUGIN_HOST + DEFAULT_NUXT_HOST + the core host default pointed at PostHog's cloud (us.i.posthog.com) — a real bug. All -> insights.hanzo.ai. - Removed the us-assets/eu-assets CDN split in getRemoteConfig (PostHog-specific; Hanzo serves remote config from the same host) — it had degenerated to a no-op. - Fixed generate-docs writing to a stray references/@hanzo/ subdir. - Renamed the 3 posthog-named test files; dropped 58MB of stale reference snapshots named for upstream posthog versions we never shipped (they are generated output — references/ is now gitignored). Verified: typecheck errors 42 (HEAD) -> 18 (all pre-existing test-mock looseness); types package 0; every package.json valid with @hanzo/* names. Guard: grep -rioE 'posthog' packages ... | wc -l => 0
89 lines
3.9 KiB
TypeScript
89 lines
3.9 KiB
TypeScript
import { getSurveyResponseKey } from '@/extensions/surveys/surveys-extension-utils'
|
|
import { pollUntilEventCaptured } from '../utils/event-capture-utils'
|
|
import { expect, test } from '../utils/insights-playwright-test-base'
|
|
import { start } from '../utils/setup'
|
|
|
|
const startOptions = {
|
|
options: {
|
|
override_display_language: 'es',
|
|
},
|
|
flagsResponseOverrides: {
|
|
surveys: true,
|
|
},
|
|
url: './playground/cypress/index.html',
|
|
}
|
|
|
|
test.describe('surveys - translations', () => {
|
|
test('renders translated copy and captures the applied language', async ({ page, context }) => {
|
|
const surveysAPICall = page.route('**/surveys/**', async (route) => {
|
|
await route.fulfill({
|
|
json: {
|
|
surveys: [
|
|
{
|
|
id: 'translation-test',
|
|
name: 'Product feedback',
|
|
type: 'popover',
|
|
start_date: '2021-01-01T00:00:00Z',
|
|
questions: [
|
|
{
|
|
type: 'single_choice',
|
|
question: 'How was your experience?',
|
|
choices: ['Good', 'Bad'],
|
|
id: 'experience',
|
|
translations: {
|
|
es: {
|
|
question: '¿Cómo fue tu experiencia?',
|
|
choices: ['Buena', 'Mala'],
|
|
},
|
|
},
|
|
},
|
|
],
|
|
appearance: {
|
|
displayThankYouMessage: true,
|
|
thankYouMessageHeader: 'Thank you!',
|
|
thankYouMessageDescription: 'We appreciate your feedback.',
|
|
},
|
|
translations: {
|
|
es: {
|
|
name: 'Comentarios del producto',
|
|
thankYouMessageHeader: '¡Gracias!',
|
|
thankYouMessageDescription: 'Agradecemos tus comentarios.',
|
|
thankYouMessageCloseButtonText: 'Cerrar',
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
})
|
|
})
|
|
|
|
await start(startOptions, page, context)
|
|
await surveysAPICall
|
|
|
|
const survey = page.locator('.InsightsSurvey-translation-test')
|
|
await expect(survey.locator('.survey-form')).toBeVisible()
|
|
await expect(survey.locator('.survey-question')).toHaveText('¿Cómo fue tu experiencia?')
|
|
await expect(survey.locator('label:has-text("Buena")')).toBeVisible()
|
|
|
|
await survey.locator('label:has-text("Buena")').click()
|
|
await survey.locator('.form-submit').click()
|
|
|
|
await expect(survey.locator('.thank-you-message-header')).toHaveText('¡Gracias!')
|
|
await expect(survey.locator('.thank-you-message-body')).toHaveText('Agradecemos tus comentarios.')
|
|
await expect(survey.locator('.form-submit')).toHaveText('Cerrar')
|
|
|
|
await pollUntilEventCaptured(page, 'survey sent')
|
|
const captures = await page.capturedEvents()
|
|
const surveySent = captures.find((capture) => capture.event === 'survey sent')
|
|
expect(surveySent?.properties.$survey_language).toBe('es')
|
|
expect(surveySent?.properties[getSurveyResponseKey('experience')]).toBe('Buena')
|
|
expect(surveySent?.properties.$survey_questions).toEqual([
|
|
{
|
|
id: 'experience',
|
|
question: '¿Cómo fue tu experiencia?',
|
|
response: 'Buena',
|
|
},
|
|
])
|
|
})
|
|
})
|