@@ -7,6 +7,7 @@ import { flowNodeValueTemplateRefusals } from '../automation/flow-value-slot-tem
77import { ObjectSchema } from '../data/object.zod.js' ;
88import { MIGRATIONS_BY_MAJOR } from '../migrations/registry.js' ;
99import { ComponentPropsMap } from '../ui/component.zod.js' ;
10+ import { DashboardSchema } from '../ui/dashboard.zod.js' ;
1011import { PageSchema } from '../ui/page.zod.js' ;
1112import { ViewDataSchema } from '../ui/view.zod.js' ;
1213import { applyConversions , applyConversionsToFlow } from './apply.js' ;
@@ -71,6 +72,7 @@ describe('the refused-shape list — registered against the migration chain', ()
7172 'object-external-binding-managed-datasource-refused' ,
7273 'visibility-predicate-has-argument-refused' ,
7374 'object-duplicate-action-name-refused' ,
75+ 'ui-dashboard-global-filter-duplicate-name-refused' ,
7476 ] ) ;
7577 } ) ;
7678
@@ -792,3 +794,62 @@ describe('#26725 — a stored object that declares one action name twice is list
792794 expect ( dupActionIssue ( row ) ) . toBeUndefined ( ) ;
793795 } ) ;
794796} ) ;
797+
798+ // ── #29212 (the #29023 refusal) ───────────────────────────────────────────
799+
800+ const dupBoard = ( globalFilters : unknown [ ] ) => ( { name : 'crm_kpi' , label : 'KPI' , widgets : [ ] , globalFilters } ) ;
801+ /** The dashboard parse's duplicate-key issue, or undefined. */
802+ const dupFilterIssue = ( row : unknown ) => {
803+ const parsed = DashboardSchema . safeParse ( row ) ;
804+ return parsed . success
805+ ? undefined
806+ : parsed . error . issues . find ( ( i ) => i . path [ 0 ] === 'globalFilters' && / d e c l a r e s t h e g l o b a l f i l t e r / . test ( i . message ) ) ;
807+ } ;
808+
809+ describe ( '#29212 — a stored dashboard that declares one global filter key twice is listed by dashboard' , ( ) => {
810+ it ( 'one TODO at the second declaration\'s name, naming the key and both indexes; the row is not rewritten' , ( ) => {
811+ const row = dupBoard ( [
812+ { name : 'r' , field : 'region' , type : 'text' } ,
813+ { name : 'r' , field : 'status' , type : 'text' } ,
814+ ] ) ;
815+ const { item, todos } = storedTodos ( 'dashboard' , row ) ;
816+ expect ( item ) . toEqual ( row ) ;
817+ expect ( todos ) . toHaveLength ( 1 ) ;
818+ const todo = todos [ 0 ] ! ;
819+ expect ( todo . conversionId ) . toBe ( 'ui-dashboard-global-filter-duplicate-name-refused' ) ;
820+ expect ( todo . path ) . toBe ( 'dashboards[0].globalFilters[1].name' ) ;
821+ expect ( todo . reason ) . toMatch ( / ^ N o l o s s l e s s r e w r i t e : w h i c h d e f i n i t i o n k e e p s t h e k e y / ) ;
822+ expect ( todo . reason ) . toContain (
823+ "This dashboard declares the global filter 'r' twice in globalFilters: globalFilters[0] and globalFilters[1]." ,
824+ ) ;
825+ expect ( todo . reason ) . not . toMatch ( / # \d { 3 , } / ) ;
826+ expect ( JSON . parse ( todo . from ) ) . toEqual ( { name : 'r' , indexes : [ 0 , 1 ] } ) ;
827+ // The listing and the parse refuse ONE set: the stored row still fails the parse, at the same site.
828+ expect ( dupFilterIssue ( item ) ?. path ) . toEqual ( [ 'globalFilters' , 1 , 'name' ] ) ;
829+ } ) ;
830+
831+ it ( 'a key that falls back to `field` is listed at that field, as the parse locates it' , ( ) => {
832+ const row = dupBoard ( [
833+ { field : 'region' , type : 'text' } ,
834+ { field : 'region' , type : 'select' , options : [ { value : 'north' , label : 'North' } ] } ,
835+ { name : 'region' , field : 'sales_region' , type : 'text' } ,
836+ ] ) ;
837+ const { todos } = storedTodos ( 'dashboard' , row ) ;
838+ expect ( todos ) . toHaveLength ( 1 ) ;
839+ expect ( todos [ 0 ] ! . path ) . toBe ( 'dashboards[0].globalFilters[1].field' ) ;
840+ expect ( JSON . parse ( todos [ 0 ] ! . from ) ) . toEqual ( { name : 'region' , indexes : [ 0 , 1 , 2 ] } ) ;
841+ expect ( todos [ 0 ] ! . reason ) . toContain ( "the global filter 'region' 3 times" ) ;
842+ expect ( dupFilterIssue ( row ) ?. path ) . toEqual ( [ 'globalFilters' , 1 , 'field' ] ) ;
843+ } ) ;
844+
845+ it ( 'distinct keys, and distinct names over one field, are not listed — and the parse accepts them' , ( ) => {
846+ for ( const filters of [
847+ [ { name : 'r' , field : 'region' , type : 'text' } , { name : 's' , field : 'status' , type : 'text' } ] ,
848+ [ { name : 'region_a' , field : 'region' , type : 'text' } , { name : 'region_b' , field : 'region' , type : 'text' } ] ,
849+ ] ) {
850+ const row = dupBoard ( filters ) ;
851+ expect ( storedTodos ( 'dashboard' , row ) . todos ) . toEqual ( [ ] ) ;
852+ expect ( DashboardSchema . safeParse ( row ) . success ) . toBe ( true ) ;
853+ }
854+ } ) ;
855+ } ) ;
0 commit comments