@@ -148,6 +148,25 @@ async function storedViewBody(name: string, item: unknown): Promise<any> {
148148 return JSON . parse ( row ! . metadata ) ;
149149}
150150
151+ /**
152+ * [#26711] Save a view the door refuses: the 422 envelope, NO row written, and
153+ * the `unrecognized_keys` issue the claimed member raised for the undeclared keys.
154+ */
155+ async function refusedUndeclared ( item : Record < string , unknown > ) : Promise < { message : string } > {
156+ const { protocol, rows } = makeProtocol ( ) ;
157+ let err : any ;
158+ try {
159+ await ( protocol as any ) . saveMetaItem ( { type : 'view' , name : item . name as string , item } ) ;
160+ } catch ( e ) { err = e ; }
161+ expect ( err ?. code ) . toBe ( 'INVALID_METADATA' ) ;
162+ expect ( err ?. status ) . toBe ( 422 ) ;
163+ expect ( Array . from ( rows . values ( ) ) . filter ( ( r ) => r . type === 'view' ) ) . toHaveLength ( 0 ) ;
164+ const issue = ( err . issues as Array < { code ?: string ; message : string } > )
165+ . find ( ( i ) => i . code === 'unrecognized_keys' ) ;
166+ expect ( issue , JSON . stringify ( err . issues ) ) . toBeDefined ( ) ;
167+ return { message : issue ! . message } ;
168+ }
169+
151170/** The one section every fixture below declares, in the authored spelling. */
152171const SECTION = { label : 'About you' , fields : [ 'name' , 'email' ] } ;
153172const SHARING = { allowAnonymous : true , publicLink : '/forms/contact-us' } ;
@@ -214,22 +233,23 @@ describe('#7134 the save path persists the folded `sections`, at every depth a f
214233 expect ( body ) . not . toHaveProperty ( 'groups' ) ;
215234 } ) ;
216235
217- it ( '[#20051] the fold and the form overlay\'s declared keys coexist on one save; its undeclared ones do not' , async ( ) => {
218- // Re-judged at stage (iv) of #20051, which stores a view's parsed
219- // body. The fold is stored, and so is `isDefault`, which the flattened
220- // FORM overlay declares. `isPinned` and `sortOrder` are the list
221- // switcher's row state: the form member declares neither and the
222- // console writes neither on a form row (`VIEW_CONSOLE_ROUND_TRIP_KEYS`
223- // maps no key to `formOverlay`), so the stored row drops both.
224- const body = await storedViewBody (
225- 'contact_us' ,
226- flatForm ( { groups : [ SECTION ] , isPinned : true , isDefault : false , sortOrder : 3 } ) ,
227- ) ;
236+ it ( '[#26711] the fold and the form overlay\'s declared keys coexist on one save; its undeclared ones are refused by name' , async ( ) => {
237+ // Re-judged twice. At stage (iv) of #20051, which stores a view's parsed
238+ // body, the undeclared keys were dropped from the row on a `200`. Since
239+ // #26711 the form member is closed, so they are refused. The fold is
240+ // stored, and so is `isDefault`, which the flattened FORM overlay
241+ // declares. `isPinned` and `sortOrder` are the list switcher's row
242+ // state: the form member declares neither and the console writes
243+ // neither on a form row (`VIEW_CONSOLE_ROUND_TRIP_KEYS` maps no key to
244+ // `formOverlay`).
245+ const body = await storedViewBody ( 'contact_us' , flatForm ( { groups : [ SECTION ] , isDefault : false } ) ) ;
228246 expect ( body . sections ) . toEqual ( [ SECTION ] ) ;
229247 expect ( body ) . not . toHaveProperty ( 'groups' ) ;
230248 expect ( body . isDefault ) . toBe ( false ) ;
231- expect ( body ) . not . toHaveProperty ( 'isPinned' ) ;
232- expect ( body ) . not . toHaveProperty ( 'sortOrder' ) ;
249+ const refusal = await refusedUndeclared (
250+ flatForm ( { groups : [ SECTION ] , isPinned : true , isDefault : false , sortOrder : 3 } ) ,
251+ ) ;
252+ expect ( refusal . message ) . toMatch ( / ^ U n r e c o g n i z e d k e y \( s \) o n t h i s i n l i n e f o r m v i e w : ` i s P i n n e d ` , ` s o r t O r d e r ` \. / ) ;
233253 } ) ;
234254} ) ;
235255
@@ -258,22 +278,22 @@ describe('#7134 what the save path must NOT change', () => {
258278 expect ( await storedViewBody ( authored . name , authored ) ) . toEqual ( authored ) ;
259279 } ) ;
260280
261- it ( '[#20051] a form authored with canonical `sections` is stored as authored — no section default, no `sharing.enabled`, no undeclared key ' , async ( ) => {
281+ it ( '[#20051] a form authored with canonical `sections` is stored as authored — no section default, no `sharing.enabled`' , async ( ) => {
262282 // Re-judged at stage (iv): was "stored byte-identical", with an
263- // `isPinned` the form member does not declare riding along. The parse
264- // adds `collapsible` / `collapsed` to the section and `enabled: false`
265- // to `sharing`; ruling B stores none of them (ADR-0087's `storable`
266- // rule), and the undeclared `isPinned` is dropped. A section's `columns`
267- // has no default: undeclared, the parse adds no key (the renderer picks
268- // the density by available width).
269- const authored = flatForm ( { sections : [ SECTION ] , isPinned : true } ) ;
283+ // `isPinned` the form member does not declare riding along, which the
284+ // row then dropped. The parse adds `collapsible` / `collapsed` to the
285+ // section and `enabled: false` to `sharing`; ruling B stores none of
286+ // them (ADR-0087's `storable` rule). A section's `columns` has no
287+ // default: undeclared, the parse adds no key (the renderer picks the
288+ // density by available width). [#26711] The undeclared `isPinned` is
289+ // now refused by name (the test above), so the fixture no longer
290+ // carries it and the row is the body as authored.
291+ const authored = flatForm ( { sections : [ SECTION ] } ) ;
270292 const parsed = ( ViewMetadataSchema as any ) . parse ( authored ) ;
271293 expect ( parsed . sections [ 0 ] ) . toMatchObject ( { collapsible : false , collapsed : false } ) ;
272294 expect ( 'columns' in parsed . sections [ 0 ] ) . toBe ( false ) ;
273295 expect ( parsed . sharing . enabled ) . toBe ( false ) ;
274- const body = await storedViewBody ( 'contact_us' , authored ) ;
275- const { isPinned : _dropped , ...declared } = authored as Record < string , unknown > ;
276- expect ( body ) . toEqual ( declared ) ;
296+ expect ( await storedViewBody ( 'contact_us' , authored ) ) . toEqual ( authored ) ;
277297 } ) ;
278298
279299 it ( 'GUARD: a LIST overlay is untouched — this walk is form-shaped only' , async ( ) => {
@@ -511,7 +531,10 @@ describe('#20186 the save door judges a flattened overlay by the member its view
511531 } ) ;
512532
513533 it ( 'a column-less list overlay that names a `type`: 422 at `columns`, with the prescription' , async ( ) => {
514- const issue = at ( await refused ( { ...LIST , type : 'kanban' , groupByField : 'stage' } ) , 'columns' ) ;
534+ // [#26711] The kanban setting goes where the list view declares it: a
535+ // top-level `groupByField` is now refused as an unknown key, before
536+ // the column check runs.
537+ const issue = at ( await refused ( { ...LIST , type : 'kanban' , kanban : { groupByField : 'stage' , columns : [ 'name' ] } } ) , 'columns' ) ;
515538 expect ( issue . code ) . toBe ( 'custom' ) ;
516539 expect ( issue . message ) . toMatch ( / ^ T h i s l i s t v i e w o v e r l a y s e t s ` t y p e ` b u t l i s t s n o ` c o l u m n s ` \. / ) ;
517540 } ) ;
@@ -583,9 +606,14 @@ describe('[#20051] stage (iv): a saved view stores the parsed value of every key
583606 expect ( stored . sort ) . toEqual ( [ { field : 'name' , order : 'desc' } ] ) ;
584607 } ) ;
585608
586- it ( 'an undeclared key is dropped: the saved-view toolbar toggle\'s `id` / `objectName`, and a form-only `layout`' , async ( ) => {
587- // W6b's shape: `buildPersistedViewBody`'s saved-view branch writes the
588- // whole tab back, and the tab carries `id` and `objectName`.
609+ it ( '[#26711] an undeclared key is refused by name: a saved-view tab\'s `id` / `objectName`, and a form-only `layout`' , async ( ) => {
610+ // W6b's shape: `buildPersistedViewBody`'s saved-view branch wrote the
611+ // whole tab back, and the tab carried `id` and `objectName`. At stage
612+ // (iv) the row dropped them on a `200`; since #26711 the list member is
613+ // closed and the save is refused, naming each key and pointing the two
614+ // alias spellings at the declared ones. The console no longer writes
615+ // this shape: `buildViewConfigSaveBody` copies only the list view's
616+ // declared keys under the ViewItem envelope.
589617 const declared = {
590618 name : 'crm_lead.my_leads' ,
591619 object : 'crm_lead' ,
@@ -596,10 +624,12 @@ describe('[#20051] stage (iv): a saved view stores the parsed value of every key
596624 data : { provider : 'object' , object : 'crm_lead' } ,
597625 isDefault : false ,
598626 } ;
599- const stored = await storedViewBody ( declared . name , {
627+ expect ( await storedViewBody ( declared . name , declared ) ) . toEqual ( declared ) ;
628+ const refusal = await refusedUndeclared ( {
600629 ...declared , id : 'crm_lead.my_leads' , objectName : 'crm_lead' , layout : 'diagonal' ,
601630 } ) ;
602- expect ( stored ) . toEqual ( declared ) ;
631+ expect ( refusal . message ) . toMatch ( / ^ U n r e c o g n i z e d k e y \( s \) o n t h i s i n l i n e l i s t v i e w : ` i d ` , ` o b j e c t N a m e ` , ` l a y o u t ` \. / ) ;
632+ expect ( refusal . message ) . toContain ( 'Did you mean `id` → `name`, `objectName` → `object`?' ) ;
603633 } ) ;
604634
605635 it ( 'a declared key keeps its normalised value' , async ( ) => {
@@ -641,7 +671,7 @@ describe('[#20051] stage (iv): a saved view stores the parsed value of every key
641671 it ( 'the persisted body parses to exactly what the save parsed' , async ( ) => {
642672 const bodies : Array < Record < string , unknown > > = [
643673 ...TOOLBAR_SAVES . map ( ( [ , patch ] ) => ( { ...patch , ...OVERLAY_ID } ) ) ,
644- flatForm ( { groups : [ SECTION ] , isPinned : true } ) ,
674+ flatForm ( { groups : [ SECTION ] , isDefault : true } ) ,
645675 {
646676 name : 'lead.contact_us' , object : 'lead' , viewKind : 'form' , label : 'Contact us' ,
647677 config : { type : 'simple' , data : DATA , sharing : SHARING , groups : [ SECTION ] } ,
0 commit comments