@@ -98,9 +98,8 @@ test("Schema and Settings Key Synchronization", async t => {
9898 boxes
9999 . flatMap ( box => {
100100 return box . fields . flatMap ( field => {
101- return field . type === "table"
102- ? field . nestedBoxes . flatMap ( b => b . fields . map ( f => `${ field . key } .${ f . key } ` ) )
103- : field . key
101+ const nested = field . nestedBoxes ?? field . subSchema
102+ return nested ?. flatMap ( b => b . fields . map ( f => `${ field . key } .${ f . key } ` ) ) ?? field . key
104103 } )
105104 } )
106105 . map ( e => e . replace ( / \. \d + / g, "" ) )
@@ -121,6 +120,7 @@ test("all schemas keys should be translated", async t => {
121120
122121 const baseProps = [ "label" , "tooltip" , "placeholder" , "hintHeader" , "hintDetail" , "unit" ]
123122 const specialProps = [ "options" , "thMap" ]
123+ const nestedFieldProps = [ "nestedBoxes" , "subSchema" ]
124124 const checkTranslated = ( newBox , isTranslated ) => {
125125 if ( newBox . title ) {
126126 isTranslated ( newBox . title , { property : "title" , boxTitle : newBox . title } )
@@ -139,9 +139,9 @@ test("all schemas keys should be translated", async t => {
139139 } )
140140 }
141141 } )
142- if ( newField . nestedBoxes != null ) {
143- newField . nestedBoxes . forEach ( box => checkTranslated ( box , isTranslated ) )
144- }
142+ nestedFieldProps . forEach ( prop => {
143+ newField [ prop ] ? .forEach ( box => checkTranslated ( box , isTranslated ) )
144+ } )
145145 } )
146146 }
147147
@@ -179,9 +179,12 @@ test("all i18n keys starting with $ should be used in schemas", async t => {
179179 }
180180
181181 const filterUsedKeys = ( allI18NKeys , schemas ) => {
182- const baseProps = [ "label" , "tooltip" , "placeholder" , "hintHeader" , "hintDetail" , "unit" ]
183- const specialProps = [ "options" , "thMap" ]
182+ const boxProps = [ "title" , "tooltip" ]
183+ const baseFieldProps = [ "label" , "tooltip" , "placeholder" , "hintHeader" , "hintDetail" , "unit" ]
184+ const specialFieldProps = [ "options" , "thMap" ]
185+ const nestedFieldProps = [ "nestedBoxes" , "subSchema" ]
184186 const _filterUsedKeys = ( fixedName , key ) => {
187+ if ( key == null ) return
185188 if ( allI18NKeys [ fixedName ] . has ( key ) ) {
186189 allI18NKeys [ fixedName ] . delete ( key )
187190 } else if ( allI18NKeys . settings . has ( key ) ) {
@@ -190,25 +193,25 @@ test("all i18n keys starting with $ should be used in schemas", async t => {
190193 }
191194 for ( const [ fixedName , boxes ] of Object . entries ( schemas ) ) {
192195 for ( const box of boxes ) {
193- if ( box . title ) {
194- _filterUsedKeys ( fixedName , box . title )
196+ for ( const prop of boxProps ) {
197+ _filterUsedKeys ( fixedName , box [ prop ] )
195198 }
196199 for ( const field of box . fields || [ ] ) {
197- for ( const prop of baseProps ) {
198- if ( field [ prop ] != null ) {
199- _filterUsedKeys ( fixedName , field [ prop ] )
200- }
200+ for ( const prop of baseFieldProps ) {
201+ _filterUsedKeys ( fixedName , field [ prop ] )
201202 }
202- for ( const prop of specialProps ) {
203+ for ( const prop of specialFieldProps ) {
203204 const propVal = field [ prop ]
204205 if ( propVal && typeof propVal === "object" ) {
205206 for ( const v of Object . values ( propVal ) ) {
206207 _filterUsedKeys ( fixedName , v )
207208 }
208209 }
209210 }
210- if ( field . nestedBoxes ) {
211- filterUsedKeys ( allI18NKeys , { [ fixedName ] : field . nestedBoxes } )
211+ for ( const prop of nestedFieldProps ) {
212+ if ( field [ prop ] ) {
213+ filterUsedKeys ( allI18NKeys , { [ fixedName ] : field [ prop ] } )
214+ }
212215 }
213216 }
214217 }
0 commit comments