@@ -103,10 +103,21 @@ const FIELDS = {
103103/** One authored list view with no `label`, as a list whose view the author left unnamed. */
104104const LISTVIEWS = { all : { type : 'grid' , columns : [ 'name' ] } } ;
105105
106- const OBJECTS = [
107- { name : 'showcase_project' , label : 'Project' , pluralLabel : 'Projects' , fields : FIELDS , listViews : LISTVIEWS } ,
108- { name : 'showcase_note' , label : 'Note' , fields : FIELDS , listViews : LISTVIEWS } ,
109- ] ;
106+ /**
107+ * The served objects, per language: the server translates what it serves under
108+ * the request's language from the same catalog the console loads, so a zh-CN
109+ * session holds the zh-CN answer (objectstack#30311).
110+ */
111+ const OBJECTS : Record < Lang , Array < Record < string , unknown > > > = {
112+ en : [
113+ { name : 'showcase_project' , label : 'Project' , pluralLabel : 'Projects' , fields : FIELDS , listViews : LISTVIEWS } ,
114+ { name : 'showcase_note' , label : 'Note' , fields : FIELDS , listViews : LISTVIEWS } ,
115+ ] ,
116+ 'zh-CN' : [
117+ { name : 'showcase_project' , label : '项目' , pluralLabel : '项目清单' , fields : FIELDS , listViews : LISTVIEWS } ,
118+ { name : 'showcase_note' , label : 'Note' , fields : FIELDS , listViews : LISTVIEWS } ,
119+ ] ,
120+ } ;
110121
111122/** The catalog as the console loads it: `zh-CN` translates both scalars. */
112123const BUNDLE : Record < Lang , Record < string , unknown > > = {
@@ -132,7 +143,7 @@ afterEach(() => {
132143} ) ;
133144
134145/** The list page's title text for `objectName`, in `lang`. */
135- async function listTitle ( lang : Lang , objectName : string ) : Promise < string > {
146+ async function listTitle ( lang : Lang , objectName : string , objects = OBJECTS [ lang ] ) : Promise < string > {
136147 const i18n = createI18n ( { defaultLanguage : lang , detectBrowserLanguage : false } ) ;
137148 // The instance really booted in the language under test.
138149 expect ( i18n . language ) . toBe ( lang ) ;
@@ -151,7 +162,7 @@ async function listTitle(lang: Lang, objectName: string): Promise<string> {
151162 < Routes >
152163 < Route
153164 path = "/apps/:appName/:objectName"
154- element = { < ObjectView dataSource = { dataSource } objects = { OBJECTS } onEdit = { ( ) => { } } /> }
165+ element = { < ObjectView dataSource = { dataSource } objects = { objects as never } onEdit = { ( ) => { } } /> }
155166 />
156167 </ Routes >
157168 </ MemoryRouter >
@@ -178,3 +189,27 @@ describe('ObjectView — the list page is titled with the plural (objectui#11696
178189 expect ( await listTitle ( 'en' , 'showcase_note' ) ) . toBe ( 'Note' ) ;
179190 } ) ;
180191} ) ;
192+
193+ /**
194+ * objectstack#30311 — a served object's list is titled as served.
195+ *
196+ * A `.custom` override renamed the object, and the `/meta/object` read serves
197+ * the new name by the server's label order for an overridden item; the title
198+ * passed it through the bundle's `objectPluralLabel`, whose packaged
199+ * translation of the old name won. Directions, written before the run: the
200+ * renamed cell RED before the change (`项目清单`), GREEN after; the control
201+ * GREEN on both sides.
202+ */
203+ describe ( 'ObjectView — a served object’s list is titled as served (objectstack#30311)' , ( ) => {
204+ const renamed = ( extra : Record < string , unknown > ) =>
205+ [ { name : 'showcase_project' , fields : FIELDS , listViews : LISTVIEWS , ...extra } ] ;
206+
207+ it ( 'zh-CN: a renamed object titles its list with the served plural, not the packaged string' , async ( ) => {
208+ const title = await listTitle ( 'zh-CN' , 'showcase_project' , renamed ( { label : 'Venture (renamed-30311)' , pluralLabel : 'Ventures (renamed-30311)' } ) ) ;
209+ expect ( title ) . toBe ( 'Ventures (renamed-30311)' ) ;
210+ } ) ;
211+
212+ it ( 'zh-CN: control — an object served with no label is titled by the bundle' , async ( ) => {
213+ expect ( await listTitle ( 'zh-CN' , 'showcase_project' , renamed ( { } ) ) ) . toBe ( '项目清单' ) ;
214+ } ) ;
215+ } ) ;
0 commit comments