Files
docs/packages/base-ui/test/page-actions-i18n.test.ts
zeekayandHanzo Dev 263e077f6c page actions: Edit with Enso, our own assistant ahead of the third-party links
The per-page Open popover deep-linked Scira, ChatGPT, Claude and Cursor with a
read-this-page prompt while Hanzo's own assistant was absent from Hanzo's own
pages. Add the Enso item before the third-party links: it opens hanzo.chat/c/new
with an edit-intent prompt carrying the page URL (chat's composer prefills from
?q=), and the raw MDX every page already exports beside itself gives the
assistant the exact source being edited.

Title and prompt ride the existing i18n contract (pageActionsOpenEnso,
pageActionsEditInLLMPrompt) in both UI twins and both locale packs; the edit
intent stays a distinct value from the ask intent. Tests pin the keys across all
four translation surfaces and that rendering substitutes the URL without
residue.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-28 08:58:31 -07:00

28 lines
1.2 KiB
TypeScript

import { describe, expect, test } from 'vitest';
import { defaultTranslations } from '../src/i18n';
import { renderTranslation } from '@hanzo/docs-core/i18n';
// The Enso page action is i18n-driven: a title key and an edit-intent prompt
// rendered with the page URL. These pin the contract ViewOptionsPopover builds
// its hanzo.chat deep link from.
describe('Enso page action translations', () => {
const url = 'https://docs.hanzo.ai/docs/cloud';
test('title and edit prompt exist', () => {
expect(defaultTranslations.pageActionsOpenEnso).toBe('Edit with Enso');
expect(defaultTranslations.pageActionsEditInLLMPrompt).toContain('{url}');
});
test('edit prompt renders the page URL with no residue', () => {
const rendered = renderTranslation(defaultTranslations.pageActionsEditInLLMPrompt, { url });
expect(rendered).toContain(url);
expect(rendered).not.toContain('{url}');
});
test('edit intent stays distinct from the ask intent', () => {
const edit = renderTranslation(defaultTranslations.pageActionsEditInLLMPrompt, { url });
const ask = renderTranslation(defaultTranslations.pageActionsOpenInLLMPrompt, { url });
expect(edit).not.toBe(ask);
});
});