Skip to content

Commit 1553cdd

Browse files
committed
test(app-shell): serve the zh-CN answer in three label-less and plural header fixtures
AppHeader.objectCrumbPlural-11696, AppHeader.labelLessViewTitle-12805 and ObjectView.labelLessViewTab-12774 served the English object label and plural to a zh-CN session. Under the served-first label rule the header and the view tabs draw the served text, so those seven zh-CN cells read the English plural. The fixtures now serve each language's own answer, as the server does; no assertion changed. Claude-Session: https://claude.ai/code/session_01Utp6CZywtebM5fE7KZuMEM Co-authored-by: Claude <noreply@anthropic.com>
1 parent ec3b0e6 commit 1553cdd

3 files changed

Lines changed: 41 additions & 19 deletions

File tree

‎ui/packages/app-shell/src/layout/__tests__/AppHeader.labelLessViewTitle-12805.test.tsx‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,15 @@ const BUNDLE = {
172172
* item with no `label`), the `/meta/object` answer (its own `listViews`: one
173173
* with no `label`, one with a `label`, one with only a `title`), and the
174174
* object as `MetadataProvider` merges the two.
175+
* The served object document carries the session language's text, as the
176+
* server translates it (objectstack#30311: a served label is drawn as served),
177+
* so a zh-CN session is served the zh-CN label and plural.
175178
*/
176-
function world() {
179+
function world(language: 'en' | 'zh-CN' = 'en') {
177180
const viewItem = { name: DEFAULT_VIEW_ID, object: OBJECT_NAME, viewKind: 'list', config: { type: 'grid' } };
178181
const doc = {
179182
name: OBJECT_NAME,
180-
label: 'QA Gate',
181-
pluralLabel: 'QA Gates',
183+
...(language === 'en' ? { label: 'QA Gate', pluralLabel: PLURAL.en } : { label: '质检关', pluralLabel: PLURAL['zh-CN'] }),
182184
listViews: {
183185
pending: { type: 'grid' },
184186
open: { type: 'grid', label: AUTHORED_LABEL },
@@ -221,21 +223,21 @@ const LANGUAGES = ['en', 'zh-CN'] as const;
221223

222224
describe('AppHeader — a label-less view is titled by its object\'s plural label (objectui#12805)', () => {
223225
it.each(LANGUAGES)('%s: a served view with no label, bare URL', (language) => {
224-
renderAt(`/apps/showcase_app/${OBJECT_NAME}/view/default`, language, world());
226+
renderAt(`/apps/showcase_app/${OBJECT_NAME}/view/default`, language, world(language));
225227

226228
expect(screen.getAllByText(PLURAL[language]).length).toBeGreaterThan(0);
227229
expect(screen.queryAllByText('Default')).toHaveLength(0);
228230
});
229231

230232
it.each(LANGUAGES)('%s: a served view with no label, qualified URL', (language) => {
231-
renderAt(`/apps/showcase_app/${OBJECT_NAME}/view/${DEFAULT_VIEW_ID}`, language, world());
233+
renderAt(`/apps/showcase_app/${OBJECT_NAME}/view/${DEFAULT_VIEW_ID}`, language, world(language));
232234

233235
expect(screen.getAllByText(PLURAL[language]).length).toBeGreaterThan(0);
234236
expect(screen.queryAllByText('Recheck Gate.Default')).toHaveLength(0);
235237
});
236238

237239
it.each(LANGUAGES)('%s: a view the object document embeds with no label', (language) => {
238-
renderAt(`/apps/showcase_app/${OBJECT_NAME}/view/pending`, language, world());
240+
renderAt(`/apps/showcase_app/${OBJECT_NAME}/view/pending`, language, world(language));
239241

240242
expect(screen.getAllByText(PLURAL[language]).length).toBeGreaterThan(0);
241243
expect(screen.queryAllByText('Pending')).toHaveLength(0);

‎ui/packages/app-shell/src/layout/__tests__/AppHeader.objectCrumbPlural-11696.test.tsx‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,28 @@ const BUNDLE = {
167167
},
168168
};
169169

170-
/** The objects as served: two declare a plural, one does not. */
171-
const OBJECTS = [
172-
{ name: 'showcase_project', label: 'Project', pluralLabel: 'Projects' },
173-
{ name: 'showcase_task', label: 'Task', pluralLabel: 'Tasks' },
174-
{ name: 'showcase_note', label: 'Note' },
175-
];
170+
/**
171+
* The objects as served: two declare a plural, one does not.
172+
* The served object document carries the session language's text, as the
173+
* server translates it (objectstack#30311: a served label is drawn as served),
174+
* so a zh-CN session is served the zh-CN label and plural.
175+
*/
176+
const SERVED_OBJECTS = {
177+
en: [
178+
{ name: 'showcase_project', label: 'Project', pluralLabel: 'Projects' },
179+
{ name: 'showcase_task', label: 'Task', pluralLabel: 'Tasks' },
180+
{ name: 'showcase_note', label: 'Note' },
181+
],
182+
'zh-CN': [
183+
{ name: 'showcase_project', label: '项目', pluralLabel: '项目清单' },
184+
{ name: 'showcase_task', label: '任务', pluralLabel: '任务清单' },
185+
{ name: 'showcase_note', label: 'Note' },
186+
],
187+
};
176188

177189
function renderAt(pathname: string, language: 'en' | 'zh-CN', recordTitle?: string) {
178190
route.pathname = pathname;
191+
const OBJECTS = SERVED_OBJECTS[language];
179192
meta.value = {
180193
apps: [],
181194
objects: OBJECTS,

‎ui/packages/app-shell/src/views/ObjectView.labelLessViewTab-12774.test.tsx‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,19 @@ const BUNDLE = {
132132
'zh-CN': { showcase: { objects: { recheck_gate: { label: '质检关', pluralLabel: PLURAL['zh-CN'], _views: { timeline: { label: CATALOGUED['zh-CN'] } } } } } },
133133
};
134134

135-
/** The `/meta/object` answer, BEFORE the merge: its own `listViews`. */
136-
function servedObject() {
135+
/** The object's label and plural as the server serves them per language. */
136+
const SERVED = { en: { label: 'QA Gate', pluralLabel: PLURAL.en }, 'zh-CN': { label: '质检关', pluralLabel: PLURAL['zh-CN'] } } as const;
137+
138+
/**
139+
* The `/meta/object` answer, BEFORE the merge: its own `listViews`.
140+
* The served object document carries the session language's text, as the
141+
* server translates it (objectstack#30311: a served label is drawn as served),
142+
* so a zh-CN session is served the zh-CN label and plural.
143+
*/
144+
function servedObject(language: 'en' | 'zh-CN') {
137145
return {
138146
name: OBJECT_NAME,
139-
label: 'QA Gate',
140-
pluralLabel: 'QA Gates',
147+
...SERVED[language],
141148
fields: { name: { type: 'text', label: 'Name' } },
142149
listViews: {
143150
[EMBEDDED_KEY]: { type: 'grid', columns: ['name'] },
@@ -154,8 +161,8 @@ function servedObject() {
154161
* entries the console expands itself — `board` with no label and no catalogue
155162
* entry, `timeline` with no label and a catalogue entry.
156163
*/
157-
function world(source: 'viewItem' | 'container') {
158-
const doc = servedObject();
164+
function world(source: 'viewItem' | 'container', language: 'en' | 'zh-CN') {
165+
const doc = servedObject(language);
159166
const viewItem = { name: DEFAULT_VIEW_ID, object: OBJECT_NAME, viewKind: 'list', config: { type: 'grid', columns: ['name'] } };
160167
const container = {
161168
name: OBJECT_NAME,
@@ -199,7 +206,7 @@ function makeDataSource() {
199206
}
200207

201208
async function renderIn(language: 'en' | 'zh-CN', source: 'viewItem' | 'container') {
202-
const { objects, metadata } = world(source);
209+
const { objects, metadata } = world(source, language);
203210
render(
204211
<I18nProvider config={{ defaultLanguage: language, detectBrowserLanguage: false, resources: BUNDLE }}>
205212
<MetadataCtx.Provider value={metadata as any}>

0 commit comments

Comments
 (0)