@@ -138,3 +138,65 @@ describe('buildNarrative — tailored Shadow DOM constraints', () => {
138138 expect ( result ) . toContain ( ':host' ) ;
139139 } ) ;
140140} ) ;
141+
142+ // ---------------------------------------------------------------------------
143+ // buildNarrative — common mistakes section
144+ // ---------------------------------------------------------------------------
145+
146+ describe ( 'buildNarrative — common mistakes' , ( ) => {
147+ it ( 'lists valid part names when component has parts' , ( ) => {
148+ const result = getComponentNarrative ( 'my-button' , FIXTURE_CEM ) ;
149+ expect ( result ) . toContain ( 'Common mistakes' ) ;
150+ expect ( result ) . toContain ( '`base`' ) ;
151+ expect ( result ) . toContain ( 'silently fail' ) ;
152+ } ) ;
153+
154+ it ( 'warns about no CSS parts when component has only properties' , ( ) => {
155+ const meta : ComponentMetadata = {
156+ tagName : 'my-test' ,
157+ description : 'Test' ,
158+ members : [ ] ,
159+ events : [ ] ,
160+ slots : [ ] ,
161+ cssParts : [ ] ,
162+ cssProperties : [ { name : '--test-color' , description : '' } ] ,
163+ } ;
164+ const result = buildNarrative ( meta ) ;
165+ expect ( result ) . toContain ( 'NO CSS parts' ) ;
166+ expect ( result ) . toContain ( '::part()' ) ;
167+ } ) ;
168+
169+ it ( 'warns about no CSS API when component has neither' , ( ) => {
170+ const meta : ComponentMetadata = {
171+ tagName : 'my-bare' ,
172+ description : 'Bare' ,
173+ members : [ ] ,
174+ events : [ ] ,
175+ slots : [ ] ,
176+ cssParts : [ ] ,
177+ cssProperties : [ ] ,
178+ } ;
179+ const result = buildNarrative ( meta ) ;
180+ expect ( result ) . toContain ( 'NO CSS API' ) ;
181+ } ) ;
182+
183+ it ( 'warns about custom events and React onXxx props' , ( ) => {
184+ const meta : ComponentMetadata = {
185+ tagName : 'my-dialog' ,
186+ description : 'Dialog' ,
187+ members : [ ] ,
188+ events : [ { name : 'my-close' , type : 'CustomEvent' , description : '' } ] ,
189+ slots : [ ] ,
190+ cssParts : [ ] ,
191+ cssProperties : [ ] ,
192+ } ;
193+ const result = buildNarrative ( meta ) ;
194+ expect ( result ) . toContain ( 'React' ) ;
195+ expect ( result ) . toContain ( 'addEventListener' ) ;
196+ } ) ;
197+
198+ it ( 'includes styling_preflight reminder' , ( ) => {
199+ const result = getComponentNarrative ( 'my-button' , FIXTURE_CEM ) ;
200+ expect ( result ) . toContain ( 'styling_preflight' ) ;
201+ } ) ;
202+ } ) ;
0 commit comments