@@ -887,4 +887,90 @@ describe("Mirror - State Consistency", () => {
887
887
expect ( doc . frontiers ( ) . length ) . toBe ( 0 ) ;
888
888
expect ( doc . toJSON ( ) ) . toStrictEqual ( mirror . getState ( ) ) ;
889
889
} ) ;
890
+
891
+ it ( "getContainerIds returns all registered container IDs for complex nested structures" , async ( ) => {
892
+ const doc = new LoroDoc ( ) ;
893
+
894
+ const complexSchema = schema ( {
895
+ profile : schema . LoroMap ( {
896
+ name : schema . String ( ) ,
897
+ settings : schema . LoroMap ( {
898
+ theme : schema . String ( ) ,
899
+ preferences : schema . LoroMap ( {
900
+ notifications : schema . Boolean ( ) ,
901
+ } ) ,
902
+ } ) ,
903
+ } ) ,
904
+ todos : schema . LoroList (
905
+ schema . LoroMap ( {
906
+ id : schema . String ( ) ,
907
+ text : schema . String ( ) ,
908
+ completed : schema . Boolean ( ) ,
909
+ } ) ,
910
+ ) ,
911
+ tree : schema . LoroTree (
912
+ schema . LoroMap ( {
913
+ title : schema . String ( ) ,
914
+ metadata : schema . LoroMap ( {
915
+ priority : schema . Number ( ) ,
916
+ } ) ,
917
+ } ) ,
918
+ ) ,
919
+ } ) ;
920
+
921
+ const mirror = new Mirror ( {
922
+ doc,
923
+ schema : complexSchema ,
924
+ } ) ;
925
+
926
+ await mirror . setState ( {
927
+ profile : {
928
+ name : "John" ,
929
+ settings : {
930
+ theme : "dark" ,
931
+ preferences : {
932
+ notifications : true ,
933
+ } ,
934
+ } ,
935
+ } ,
936
+ todos : [
937
+ { id : "1" , text : "Task 1" , completed : false } ,
938
+ { id : "2" , text : "Task 2" , completed : true } ,
939
+ ] ,
940
+ tree : [
941
+ {
942
+ id : "root" ,
943
+ data : {
944
+ title : "Root Node" ,
945
+ metadata : {
946
+ priority : 1 ,
947
+ } ,
948
+ } ,
949
+ children : [
950
+ {
951
+ id : "child1" ,
952
+ data : {
953
+ title : "Child 1" ,
954
+ metadata : {
955
+ priority : 2 ,
956
+ } ,
957
+ } ,
958
+ children : [ ] ,
959
+ } ,
960
+ ] ,
961
+ } ,
962
+ ] ,
963
+ } ) ;
964
+
965
+ await waitForSync ( ) ;
966
+
967
+ const containerIds = mirror . getContainerIds ( ) ;
968
+
969
+ expect ( containerIds . length ) . toBe ( 11 ) ;
970
+
971
+ const uniqueIds = new Set ( containerIds ) ;
972
+ expect ( uniqueIds . size ) . toBe ( containerIds . length ) ;
973
+
974
+ mirror . dispose ( ) ;
975
+ } ) ;
890
976
} ) ;
0 commit comments