@@ -2136,7 +2136,7 @@ describe('Symbol Serialization', () => {
21362136 expect ( symbolNode . bindings . symbol ) . toBeDefined ( ) ;
21372137
21382138 // Verify symbol binding doesn't contain data anymore
2139- const symbolBinding = JSON . parse ( symbolNode . bindings . symbol . code ) ;
2139+ const symbolBinding = JSON . parse ( symbolNode . bindings . symbol ! . code ) ;
21402140 expect ( symbolBinding . data ) . toBeUndefined ( ) ;
21412141
21422142 expect ( mitosis ) . toMatchSnapshot ( ) ;
@@ -2163,13 +2163,22 @@ describe('Symbol Serialization', () => {
21632163 expect ( mitosis ) . toMatchSnapshot ( ) ;
21642164 } ) ;
21652165
2166- test ( 'Symbol roundtrip: Builder -> Mitosis -> Builder' , ( ) => {
2166+ test ( 'Symbol roundtrip: Builder -> Mitosis -> JSX -> Mitosis -> Builder' , ( ) => {
21672167 const original = JSON . parse ( symbolWithInputs ) as BuilderContent ;
2168+
2169+ // Step 1: Builder JSON -> Mitosis Component
21682170 const mitosisComponent = builderContentToMitosisComponent ( original ) ;
2169- const backToBuilder = componentToBuilder ( ) ( { component : mitosisComponent } ) ;
21702171
2171- // Verify the symbol structure is preserved
2172- const originalSymbol = original . data ?. blocks ?. [ 0 ] ;
2172+ // Step 2: Mitosis Component -> Mitosis JSX string (what AI sees)
2173+ const jsxString = componentToMitosis ( ) ( { component : mitosisComponent } ) ;
2174+
2175+ // Step 3: Mitosis JSX string -> Mitosis Component (after AI edits)
2176+ const parsedComponent = parseJsx ( jsxString ) ;
2177+
2178+ // Step 4: Mitosis Component -> Builder JSON
2179+ const backToBuilder = componentToBuilder ( ) ( { component : parsedComponent } ) ;
2180+
2181+ // Verify the symbol structure is preserved through full roundtrip
21732182 const roundtripSymbol = backToBuilder . data ?. blocks ?. [ 0 ] ;
21742183
21752184 expect ( roundtripSymbol ?. component ?. name ) . toBeDefined ( ) ;
@@ -2183,8 +2192,14 @@ describe('Symbol Serialization', () => {
21832192 const mitosisComponent = builderContentToMitosisComponent ( original ) ;
21842193 expect ( mitosisComponent . children [ 0 ] . name ) . toBe ( 'SymbolButtonComponent' ) ;
21852194
2186- // Step 2: Mitosis -> Builder (should be "Symbol" not "SymbolButtonComponent")
2187- const backToBuilder = componentToBuilder ( ) ( { component : mitosisComponent } ) ;
2195+ // Step 2: Mitosis -> JSX string (what AI sees)
2196+ const jsxString = componentToMitosis ( ) ( { component : mitosisComponent } ) ;
2197+
2198+ // Step 3: JSX string -> Mitosis (after AI edits)
2199+ const parsedComponent = parseJsx ( jsxString ) ;
2200+
2201+ // Step 4: Mitosis -> Builder (should be "Symbol" not "SymbolButtonComponent")
2202+ const backToBuilder = componentToBuilder ( ) ( { component : parsedComponent } ) ;
21882203 const roundtripSymbol = backToBuilder . data ?. blocks ?. [ 0 ] ;
21892204
21902205 // CRITICAL: Builder Editor requires component.name === "Symbol"
@@ -2227,12 +2242,18 @@ describe('Symbol Serialization', () => {
22272242 } ,
22282243 } ;
22292244
2230- // Builder -> Mitosis: should use symbol.name for component name
2245+ // Step 1: Builder -> Mitosis: should use symbol.name for component name
22312246 const mitosisComponent = builderContentToMitosisComponent ( builderWithSymbolName ) ;
22322247 expect ( mitosisComponent . children [ 0 ] . name ) . toBe ( 'SymbolCopyrightReserved' ) ;
22332248
2234- // Mitosis -> Builder: should preserve name and use "Symbol" as component name
2235- const backToBuilder = componentToBuilder ( ) ( { component : mitosisComponent } ) ;
2249+ // Step 2: Mitosis -> JSX string (what AI sees)
2250+ const jsxString = componentToMitosis ( ) ( { component : mitosisComponent } ) ;
2251+
2252+ // Step 3: JSX string -> Mitosis (after AI edits)
2253+ const parsedComponent = parseJsx ( jsxString ) ;
2254+
2255+ // Step 4: Mitosis -> Builder: should preserve name and use "Symbol" as component name
2256+ const backToBuilder = componentToBuilder ( ) ( { component : parsedComponent } ) ;
22362257 const symbol = backToBuilder . data ?. blocks ?. [ 0 ] ;
22372258
22382259 expect ( symbol ?. component ?. name ) . toBe ( 'Symbol' ) ;
0 commit comments