@@ -4039,6 +4039,40 @@ describe('validateTranslationReferences — keyed children of an action entry (#
40394039 } ) ;
40404040 } ) ;
40414041
4042+ describe ( 'cancelText — the dismiss button of either pre-run dialog (#28519)' , ( ) => {
4043+ // `actionStack` declares no `confirmText` anywhere, so the confirm
4044+ // dialog's host is added here: a param-less action that asks first.
4045+ const withConfirmHost = ( bundle : Record < string , unknown > ) => {
4046+ const stack = actionStack ( bundle ) ;
4047+ ( stack . actions as Array < Record < string , unknown > > ) . push ( {
4048+ name : 'retire_env' ,
4049+ label : 'Retire' ,
4050+ objectName : 'crm_env' ,
4051+ type : 'script' ,
4052+ target : 'retireEnv' ,
4053+ confirmText : 'Retire this environment?' ,
4054+ } ) ;
4055+ return stack ;
4056+ } ;
4057+
4058+ it ( 'errors on a `cancelText` under an action that declares neither confirmText nor params, at both addresses' , ( ) => {
4059+ const findings = validateTranslationReferences (
4060+ withConfirmHost ( { ...onEnv ( { plain_env : { cancelText : '保留' } } ) , globalActions : { mint_token : { cancelText : '保留' } } } ) ,
4061+ ) ;
4062+ expect ( findings . map ( ( f ) => [ f . rule , f . severity , f . path ] ) ) . toEqual ( [
4063+ [ TRANSLATION_TARGET_UNKNOWN , 'error' , `${ ENV } .plain_env.cancelText` ] ,
4064+ [ TRANSLATION_TARGET_UNKNOWN , 'error' , `${ GLOBAL } .mint_token.cancelText` ] ,
4065+ ] ) ;
4066+ expect ( findings [ 0 ] . message ) . toMatch ( / ^ T r a n s l a t i o n s c a r r y a d i a l o g ` c a n c e l T e x t ` , b u t a c t i o n " p l a i n _ e n v " d e c l a r e s n e i t h e r ` c o n f i r m T e x t ` n o r ` p a r a m s ` / ) ;
4067+ } ) ;
4068+
4069+ it ( 'accepts it under the confirm dialog\'s host and under the param dialog\'s host (the controls)' , ( ) => {
4070+ expect (
4071+ validateTranslationReferences ( withConfirmHost ( onEnv ( { retire_env : { cancelText : '保留' } , archive_env : { cancelText : '不归档' } } ) ) ) ,
4072+ ) . toEqual ( [ ] ) ;
4073+ } ) ;
4074+ } ) ;
4075+
40424076 describe ( 'params.<name>.options.<value>' , ( ) => {
40434077 it ( 'warns on an option key a declared param does not declare, as the field `options` leg does' , ( ) => {
40444078 const findings = validateTranslationReferences (
@@ -4115,7 +4149,7 @@ describe('validateTranslationReferences — keyed children of an action entry (#
41154149 } ;
41164150
41174151 type Address = 'bound' | 'global' ;
4118- type Host = 'outcome' | 'dialog' | 'noDialog' | 'noParams' ;
4152+ type Host = 'outcome' | 'dialog' | 'noDialog' | 'noParams' | 'noPreRunDialog' ;
41194153 /**
41204154 * Which declared action a ghost is written under, per address. `noDialog`
41214155 * names an action that declares no `resultDialog`: the dialog's leaves
@@ -4129,6 +4163,9 @@ describe('validateTranslationReferences — keyed children of an action entry (#
41294163 // `submitText` has no button to land on (`coverageStack` gives
41304164 // `check_updates` params, so the global host is `mint_token`).
41314165 noParams : { bound : 'plain_env' , global : 'mint_token' } ,
4166+ // [#28519] An action with neither `confirmText` nor `params` opens no
4167+ // dialog before it runs, so its `cancelText` has no button to land on.
4168+ noPreRunDialog : { bound : 'plain_env' , global : 'mint_token' } ,
41324169 } ;
41334170 type Coverage =
41344171 | { kind : 'reference-checked' ; host : Host ; ghost : Record < string , unknown > ; suffix : string ; rule : string }
@@ -4147,6 +4184,13 @@ describe('validateTranslationReferences — keyed children of an action entry (#
41474184 suffix : '.submitText' ,
41484185 rule : TRANSLATION_TARGET_UNKNOWN ,
41494186 } ,
4187+ cancelText : {
4188+ kind : 'reference-checked' ,
4189+ host : 'noPreRunDialog' ,
4190+ ghost : { cancelText : 'x' } ,
4191+ suffix : '.cancelText' ,
4192+ rule : TRANSLATION_TARGET_UNKNOWN ,
4193+ } ,
41504194 outcomeMessages : {
41514195 kind : 'reference-checked' ,
41524196 host : 'outcome' ,
@@ -4250,6 +4294,7 @@ describe('validateTranslationReferences — keyed children of an action entry (#
42504294 confirmText : 'x' ,
42514295 successMessage : 'x' ,
42524296 submitText : 'x' ,
4297+ cancelText : 'x' ,
42534298 outcomeMessages : address === 'bound' ? { archived : 'x' } : { up_to_date : 'x' } ,
42544299 params : { mode : { label : 'x' , helpText : 'x' , placeholder : 'x' , options : { soft : 'x' } } } ,
42554300 } ,
0 commit comments