-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix homepage localization for chip labels and translations #2275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7459aba
f026e56
0723732
6244913
bba7388
7f9a7cb
26fa6d9
16ab5d8
9199903
465819d
0c53dcf
cfde794
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ import { cleanup, fireEvent, render, screen } from '@testing-library/react'; | |
| import { afterEach, describe, expect, it, vi } from 'vitest'; | ||
| import type { InstalledPluginRecord } from '@open-design/contracts'; | ||
|
|
||
| import { I18nProvider } from '../../src/i18n'; | ||
| import { HomeHero } from '../../src/components/HomeHero'; | ||
| import { | ||
| HOME_HERO_CHIPS, | ||
|
|
@@ -246,4 +247,57 @@ describe('HomeHero intent rail', () => { | |
| }, | ||
| }); | ||
| }); | ||
|
|
||
| it('renders localized chip labels and tooltips in zh-CN', () => { | ||
| render( | ||
| <I18nProvider initial="zh-CN"> | ||
| <HomeHero | ||
| prompt="" | ||
| onPromptChange={() => undefined} | ||
| onSubmit={() => undefined} | ||
| activePluginTitle={null} | ||
| activeChipId={null} | ||
| onClearActivePlugin={() => undefined} | ||
| pluginOptions={[]} | ||
| pluginsLoading={false} | ||
| pendingPluginId={null} | ||
| pendingChipId={null} | ||
| onPickPlugin={vi.fn()} | ||
| onPickChip={vi.fn()} | ||
| contextItemCount={0} | ||
| error={null} | ||
| /> | ||
| </I18nProvider> | ||
| ); | ||
|
|
||
| // Prototype chip label should be zh-CN | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This zh-CN regression test still skips the other always-visible create chip, |
||
| const prototypeChip = screen.getByTestId('home-hero-rail-prototype'); | ||
| expect(prototypeChip.textContent).toContain('原型'); | ||
|
|
||
| // Live artifact chip label and tooltip should be zh-CN | ||
| const liveArtifact = screen.getByTestId('home-hero-rail-live-artifact'); | ||
| expect(liveArtifact.textContent).toContain('实时制品'); | ||
| expect(liveArtifact.getAttribute('title')).toBe('构建可实时预览的交互式 HTML/CSS/JS 制品。'); | ||
|
|
||
| // HyperFrames tooltip should be the zh-CN string | ||
| const hyperframes = screen.getByTestId('home-hero-rail-hyperframes'); | ||
| expect(hyperframes.getAttribute('title')).toBe( | ||
| '创作基于 HTML 的动态内容:字幕、音频响应视觉和场景转场。' | ||
| ); | ||
|
|
||
| // Open shortcuts menu to expose migrate chips | ||
| fireEvent.click(screen.getByTestId('home-hero-shortcuts-trigger')); | ||
|
|
||
| // Migrate chip labels should be zh-CN | ||
| expect(screen.getByTestId('home-hero-rail-create-plugin').textContent).toContain('创建插件'); | ||
| expect(screen.getByTestId('home-hero-rail-figma').textContent).toContain('来自 Figma'); | ||
| expect(screen.getByTestId('home-hero-rail-template').textContent).toContain('来自模板'); | ||
|
|
||
| // Migrate chip tooltips should be zh-CN | ||
| expect(screen.getByTestId('home-hero-rail-create-plugin').getAttribute('title')).toBe('创作可复用的 Open Design 插件,并添加到我的插件。'); | ||
| expect(screen.getByTestId('home-hero-rail-figma').getAttribute('title')).toBe('将 Figma 画框迁移到当前设计体系。'); | ||
| expect(screen.getByTestId('home-hero-rail-template').getAttribute('title')).toBe('从内置模板开始。'); | ||
|
|
||
| }); | ||
|
|
||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regression test only asserts one always-visible create-chip label (
🔁 Powered by Looper · runner=reviewer · agent=opencode · An autonomous AI dev team for your GitHub repos.prototype) and one tooltip (hyperframes), and it never opens theMoreshortcuts menu. That means the zh-CN copy for the changed migrate shortcuts (create-plugin,figma,template) can regress without this suite failing, even though the PR body says no mixed English homepage UI remains. Please extend this test to openhome-hero-shortcuts-triggerunderzh-CNand assert the localized labels/titles for the shortcut chips as well, so the homepage-localization guarantee is covered across both rail rows.