@momo-kits/native-kits 0.169.13-beta.4 → 0.169.13-beta.4-debug

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/build.gradle.kts +11 -0
  2. package/compose/build.gradle.kts +202 -0
  3. package/compose/compose.podspec +47 -0
  4. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +154 -0
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
  11. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiActionsTest.kt +647 -0
  12. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiExprTest.kt +1411 -0
  13. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiHostTest.kt +130 -0
  14. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiKitArgsTest.kt +524 -0
  15. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiKitNodesTest.kt +559 -0
  16. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRenderPlanTest.kt +741 -0
  17. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRenderReuseTest.kt +221 -0
  18. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRendererPropsTest.kt +270 -0
  19. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiStylePlanTest.kt +849 -0
  20. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiStyleTest.kt +212 -0
  21. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiTrackingTest.kt +239 -0
  22. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiViewTest.kt +252 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +110 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +61 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1067 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +268 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +354 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +130 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +482 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +224 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +137 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +473 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +113 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +262 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +237 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +228 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +280 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +183 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +342 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +40 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +82 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +39 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +362 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +304 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +88 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +308 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +218 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +456 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +205 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +89 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +542 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +175 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +201 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +498 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +208 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +12 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +291 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +315 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +54 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +397 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +153 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +118 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +206 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +421 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +750 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +152 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +242 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +398 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +103 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +93 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +208 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +167 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +446 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +105 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +400 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +197 -0
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +114 -0
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +7 -0
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +76 -0
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +21 -0
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiActions.kt +154 -0
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiExpr.kt +1038 -0
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiKitNodes.kt +848 -0
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiLog.kt +47 -0
  136. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiModel.kt +39 -0
  137. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiPropsRenderer.kt +463 -0
  138. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiRenderer.kt +1146 -0
  139. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiStyle.kt +667 -0
  140. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiTracking.kt +240 -0
  141. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiValidate.kt +185 -0
  142. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiView.kt +200 -0
  143. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  144. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
  145. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  146. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +117 -0
  147. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
  148. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
  149. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
  150. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
  151. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +65 -0
  152. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
  153. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  154. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +143 -0
  155. package/gradle/libs.versions.toml +69 -0
  156. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  157. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  158. package/gradle.properties +24 -0
  159. package/gradlew +252 -0
  160. package/gradlew.bat +94 -0
  161. package/ios-demo/README.md +120 -0
  162. package/package.json +1 -1
  163. package/scripts/sdui-visual/README.md +64 -0
  164. package/settings.gradle.kts +64 -0
@@ -0,0 +1,212 @@
1
+ // File: compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiStyleTest.kt
2
+ // Created At: 2026-10-27 15:50:00 +07:00
3
+ // Created By: AI
4
+ // AI Agent: Claude Code
5
+ // Model: claude-sonnet-5-5
6
+
7
+ package vn.momo.kits.sdui
8
+
9
+ import androidx.compose.ui.graphics.Color
10
+ import androidx.compose.ui.unit.Dp
11
+ import androidx.compose.ui.unit.dp
12
+ import org.junit.Assert.assertEquals
13
+ import org.junit.Assert.assertFalse
14
+ import org.junit.Assert.assertNotNull
15
+ import org.junit.Assert.assertNull
16
+ import org.junit.Assert.assertTrue
17
+ import org.junit.Test
18
+ import androidx.compose.ui.text.TextStyle
19
+ import vn.momo.kits.const.Colors
20
+ import vn.momo.kits.const.Radius
21
+ import vn.momo.kits.const.Spacing
22
+ import vn.momo.kits.const.Typography
23
+ import vn.momo.kits.const.darkTheme
24
+ import vn.momo.kits.const.defaultTheme
25
+
26
+ // AI-GENERATED START: unit tests for token mapping, style accessors and the negative-margin arithmetic
27
+ class SduiStyleTest {
28
+ private val theme = defaultTheme
29
+
30
+ @Test fun spacingAndRadiusTokensMapToKitValues() {
31
+ assertEquals(Spacing.M, resolveToken("Spacing.M", theme))
32
+ assertEquals(Spacing.Size4XL, resolveToken("Spacing.Size4XL", theme))
33
+ assertEquals(Spacing.XS, resolveToken("Spacing.XS", theme))
34
+ assertEquals(Radius.L, resolveToken("Radius.L", theme))
35
+ assertEquals(Radius.S, resolveToken("Radius.S", theme))
36
+ }
37
+
38
+ @Test fun themeColorTokensMapToTheKitTheme() {
39
+ assertEquals(theme.colors.background.default, resolveToken("theme.colors.background.default", theme))
40
+ assertEquals(theme.colors.background.surface, resolveToken("theme.colors.background.surface", theme))
41
+ assertEquals(theme.colors.text.default, resolveToken("theme.colors.text.default", theme))
42
+ assertEquals(theme.colors.border.default, resolveToken("theme.colors.border.default", theme))
43
+ assertTrue(resolveToken("Colors.black_17", theme) is Color)
44
+ }
45
+
46
+ @Test fun unknownTokensStayAsTheirInput() {
47
+ assertEquals("Spacing.Nope", resolveToken("Spacing.Nope", theme))
48
+ assertEquals("hello", resolveToken("hello", theme))
49
+ assertEquals("theme.colors.nothing", resolveToken("theme.colors.nothing", theme))
50
+ }
51
+
52
+ @Test fun resolveValueHandlesBindingsTokensAndNesting() {
53
+ val sc = SduiScope(mapOf("w" to 40L, "tok" to "Spacing.L"), emptyMap())
54
+ val out = resolveValue(
55
+ mapOf("width" to "{w}", "gap" to "Spacing.XS", "pad" to "{tok}", "n" to listOf("Radius.S", 3L)), sc, theme,
56
+ ).asMap()!!
57
+ assertEquals(40L, out["width"])
58
+ assertEquals(Spacing.XS, out["gap"])
59
+ assertEquals(Spacing.L, out["pad"]) // a bound token string is re-tokenised
60
+ assertEquals(listOf(Radius.S, 3L), out["n"])
61
+ }
62
+
63
+ @Test fun styleAccessors() {
64
+ val sty = Sty(mapOf(
65
+ "paddingHorizontal" to Spacing.M, "paddingTop" to 4L, "marginTop" to -16L, "width" to 32L,
66
+ "aspectRatio" to "375/210", "borderTopLeftRadius" to Radius.L, "flexDirection" to "row", "flex" to 1L,
67
+ ))
68
+ assertEquals(Spacing.M, sty.padStart()); assertEquals(Spacing.M, sty.padEnd())
69
+ assertEquals(4.dp, sty.padTop())
70
+ assertEquals((-16).dp, sty.marTop())
71
+ assertEquals(0.dp, sty.marBottom())
72
+ assertEquals(375f / 210f, sty.aspect!!, 0.0001f)
73
+ assertTrue(sty.isRow); assertTrue(sty.isFlexOne); assertTrue(sty.hasWidth)
74
+ assertNotNull(sty.shape())
75
+ assertNull(Sty(emptyMap()).shape())
76
+ assertEquals(1.75f, parseRatio(1.75)!!, 0.0001f)
77
+ assertEquals(Color.Transparent, parseColor("transparent"))
78
+ assertNull(parseColor("nope"))
79
+ // CSS hex order: alpha is the LAST byte
80
+ assertEquals(Color(0xFFFF0000), parseColor("#f00"))
81
+ assertEquals(Color(0x88FF0000), parseColor("#f008"))
82
+ assertEquals(Color(0xFF00FF00), parseColor("#00FF00"))
83
+ assertEquals(Color(0x80FF0000), parseColor("#FF000080"))
84
+ assertEquals(Color(0x00000000), parseColor("#00000000"))
85
+ assertNull(parseColor("#12345"))
86
+ assertNull(parseColor("#GG0000"))
87
+ assertNull(parseColor("#-12345"))
88
+ assertEquals(12.dp, parseDp(12L)); assertEquals(Spacing.M, parseDp(Spacing.M) as Dp)
89
+ }
90
+
91
+ @Test fun shapeSelectionImageAlwaysClipsViewOnlyWithOverflowHidden() {
92
+ val rounded = Sty(mapOf("borderRadius" to Radius.S))
93
+ assertTrue(rounded.shouldClip(isImage = true)) // Image: bitmap is always rounded
94
+ assertFalse(rounded.shouldClip(isImage = false)) // container: children are not clipped by default
95
+ assertTrue(Sty(mapOf("borderRadius" to Radius.S, "overflow" to "hidden")).shouldClip(isImage = false))
96
+ assertFalse(Sty(emptyMap()).shouldClip(isImage = true)) // no radius: nothing to clip
97
+ val perCorner = Sty(mapOf("borderTopLeftRadius" to Radius.L, "borderTopRightRadius" to Radius.L))
98
+ assertNotNull(perCorner.shape()); assertTrue(perCorner.shouldClip(isImage = true))
99
+ }
100
+
101
+ @Test fun lineHeightsFollowKitTypographyScaledByScreenWidth() {
102
+ assertEquals(34f, specLineHeight("headline_default_bold", 375f)!!, 0.001f) // the kit's value is the source of truth
103
+ assertEquals(18f * 411.4f / 375f, specLineHeight("description_default_regular", 411.4f)!!, 0.01f)
104
+ assertEquals(18f, specLineHeight("description_default_regular", 375f)!!, 0.001f)
105
+ assertEquals(26f, specLineHeight("header_m_bold", 375f)!!, 0.001f)
106
+ assertEquals(20f, specLineHeight(null, 375f)!!, 0.001f) // default body_default_regular
107
+ assertNull(specLineHeight("nope", 375f))
108
+ assertEquals(20f, specLineHeight("body_default_regular_strikethrough", 375f)!!, 0.001f)
109
+ assertEquals(18f * 1.2f, specLineHeight("description_default_regular", 900f)!!, 0.001f) // scale is capped
110
+ }
111
+
112
+ @Test fun everyKitColorResolvesAsColorsToken() {
113
+ assertTrue(Colors.colorList.isNotEmpty())
114
+ Colors.colorList.forEach { (k, c) -> assertEquals(k, c, resolveToken("Colors.$k", defaultTheme)) }
115
+ val codes = mutableListOf<String>()
116
+ val session = object : RenderSession by RenderSession.NOOP {
117
+ override fun nodeError(code: String, reason: String, nodePath: String, nodeType: String?, nodeId: String?) { codes += code }
118
+ }
119
+ val sink = NodeErrorSink { session }
120
+ sink.forNode(emptyMap(), "body") { assertEquals("Colors.nope", resolveToken("Colors.nope", defaultTheme, nodeErrors = sink)) }
121
+ assertEquals(listOf(NODE_ERR_UNKNOWN_TOKEN), codes)
122
+ }
123
+
124
+ @Test fun everyColorsFieldResolvesByName() {
125
+ // reflection over the object itself, not colorList: fails when kits adds a color field colorList does not carry.
126
+ // Color is an inline class: the getter is name-mangled ("getBlack_01-0d7_KjU") and returns the raw ULong as a long
127
+ val getters = Colors.javaClass.declaredMethods.filter {
128
+ it.parameterCount == 0 && it.name.startsWith("get") && it.returnType == java.lang.Long.TYPE
129
+ }
130
+ assertTrue("found ${getters.size}", getters.size >= 150)
131
+ getters.forEach { m ->
132
+ val name = m.name.removePrefix("get").substringBefore('-').replaceFirstChar { it.lowercase() }
133
+ assertEquals(name, Color((m.invoke(Colors) as Long).toULong()), resolveToken("Colors.$name", defaultTheme))
134
+ }
135
+ }
136
+
137
+ @Test fun flatTokensTakeExactlyOneName() {
138
+ for (t in listOf("Colors.black_17.x", "Spacing.M.y", "Radius.S.y", "Spacing.M.")) {
139
+ val codes = mutableListOf<String>()
140
+ val session = object : RenderSession by RenderSession.NOOP {
141
+ override fun nodeError(code: String, reason: String, nodePath: String, nodeType: String?, nodeId: String?) { codes += code }
142
+ }
143
+ val sink = NodeErrorSink { session }
144
+ sink.forNode(emptyMap(), "body") { assertEquals(t, t, resolveToken(t, defaultTheme, nodeErrors = sink)) }
145
+ assertEquals(t, listOf(NODE_ERR_UNKNOWN_TOKEN), codes)
146
+ }
147
+ assertEquals(Spacing.M, resolveToken("Spacing.M", defaultTheme))
148
+ assertEquals(Radius.S, resolveToken("Radius.S", defaultTheme))
149
+ assertEquals("theme.colors.primary.x", resolveToken("theme.colors.primary.x", defaultTheme))
150
+ }
151
+
152
+ /** Every Color field reachable from Theme.colors, as (path, value). Fails when kits adds a color SDUI does not map. */
153
+ private fun colorFields(obj: Any, prefix: String, out: MutableList<Pair<String, Color>>) {
154
+ obj.javaClass.declaredMethods
155
+ .filter { it.parameterCount == 0 && it.name.startsWith("get") && !java.lang.reflect.Modifier.isStatic(it.modifiers) }
156
+ .forEach { m ->
157
+ // Color is an inline class: its getter is name-mangled ("getPrimary-0d7_KjU") and returns the raw ULong
158
+ val name = m.name.removePrefix("get").substringBefore('-').replaceFirstChar { it.lowercase() }
159
+ val v = m.invoke(obj)
160
+ when {
161
+ m.returnType == java.lang.Long.TYPE -> out += "$prefix.$name" to Color((v as Long).toULong())
162
+ v != null && v.javaClass.name.startsWith("vn.momo.kits.const.") -> colorFields(v, "$prefix.$name", out)
163
+ }
164
+ }
165
+ }
166
+
167
+ @Test fun everyThemeColorFieldResolves() {
168
+ for (theme in listOf(defaultTheme, darkTheme)) {
169
+ val found = mutableListOf<Pair<String, Color>>()
170
+ colorFields(theme.colors, "theme.colors", found)
171
+ assertTrue("expected all ColorScheme fields, found ${found.size}", found.size >= 29)
172
+ found.forEach { (path, c) -> assertEquals(path, c, resolveToken(path, theme)) }
173
+ }
174
+ }
175
+
176
+ @Test fun everyTypographyGetterMapsBySnakeCaseName() {
177
+ val snake = Regex("[A-Z]")
178
+ val getters = Typography.javaClass.declaredMethods.filter {
179
+ it.parameterCount == 0 && it.name.startsWith("get") && it.returnType == TextStyle::class.java
180
+ }
181
+ assertTrue("found ${getters.size}", getters.size >= 18)
182
+ getters.forEach { m ->
183
+ val prop = m.name.removePrefix("get").replaceFirstChar { it.lowercase() }
184
+ val name = snake.replace(prop) { "_" + it.value.lowercase() }
185
+ assertEquals(name, m.invoke(Typography) as TextStyle, typographyOf(name))
186
+ assertNotNull(name, specLineHeight(name, 375f))
187
+ }
188
+ assertEquals(Typography.bodyDefaultRegular, typographyOf("nope"))
189
+ }
190
+
191
+
192
+ @Test fun negativeMarginsPullTheNodeAndSiblingsUp() {
193
+ // marginTop = -16dp at density 1 (px == dp). child height 36 -> reports 20 and the child is placed at y = -16.
194
+ assertEquals(20, SpecMargin.outerSize(36, -16, 0))
195
+ // available size GROWS for a negative margin , shrinks for a positive one
196
+ assertEquals(16, SpecMargin.constraintDelta(-16, 0))
197
+ assertEquals(-24, SpecMargin.constraintDelta(12, 12))
198
+ // any side, not only top: left/right -8 widen the child's constraints by 16 and the node reports child - 16
199
+ assertEquals(16, SpecMargin.constraintDelta(-8, -8))
200
+ assertEquals(84, SpecMargin.outerSize(100, -8, -8))
201
+ // never below zero
202
+ assertEquals(0, SpecMargin.outerSize(10, -30, 0))
203
+ // spec chain: banner bottom B, outer View marginTop 40, search wrapper marginTop -16 (+ its own height H)
204
+ val bannerBottom = 210; val outerTop = bannerBottom - 20 + 40 // layoutOffset -20 then marginTop 40
205
+ val searchTop = outerTop + (-16)
206
+ assertEquals(230, outerTop); assertEquals(214, searchTop)
207
+ // the sibling after the search wrapper starts at searchTop + (H - 16 reported) ... i.e. 16 earlier than without the margin
208
+ val h = 36
209
+ assertEquals(outerTop + SpecMargin.outerSize(h, -16, 0), searchTop + h)
210
+ }
211
+ }
212
+ // AI-GENERATED END: unit tests for token mapping, style accessors and the negative-margin arithmetic
@@ -0,0 +1,239 @@
1
+ // File: compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiTrackingTest.kt
2
+ // Created At: 2026-10-27 18:30:00 +07:00
3
+ // Created By: AI
4
+ // AI Agent: Claude Code
5
+ // Model: claude-sonnet-5-5
6
+
7
+ package vn.momo.kits.sdui
8
+
9
+ import org.junit.Assert.assertEquals
10
+ import org.junit.Assert.assertFalse
11
+ import org.junit.Assert.assertNotNull
12
+ import org.junit.Assert.assertNull
13
+ import org.junit.Assert.assertTrue
14
+ import org.junit.Test
15
+ import kotlin.random.Random
16
+
17
+ // AI-GENERATED START: unit tests for SDUI tracking
18
+ class SduiTrackingTest {
19
+ private class FakeSink : TrackSink {
20
+ override val id = "fake"
21
+ val records = mutableListOf<TrackRecord>()
22
+ override fun write(record: TrackRecord) { records += record }
23
+ }
24
+
25
+ private val ctx = SessionCtx("sdui:sdui/home", 1)
26
+ private var now = 1000L
27
+ private fun mk(rate: Double = 1.0, sinks: List<TrackSink>? = null): Pair<FakeSink, Tracker> {
28
+ val sink = FakeSink()
29
+ return sink to Tracker(sinks ?: listOf(sink), "sess-1", "ios", rate) { now }
30
+ }
31
+ private fun names(s: FakeSink) = s.records.map { it.event.step }
32
+
33
+ // ---- envelope -------------------------------------------------------------------------------------------------------
34
+ @Test fun envelopeCarriesCommonFieldsOnEveryEvent() {
35
+ val (sink, tracker) = mk()
36
+ val s = tracker.begin(SessionCtx("sdui:sdui/home", 1))
37
+ s.mark("sdui_parse")
38
+ val e = sink.records[0].envelope
39
+ assertEquals(s.renderId, e["renderId"]); assertEquals("sess-1", e["sessionId"])
40
+ assertEquals("sdui:sdui/home", e["screenId"]); assertEquals(1, e["renderVersion"])
41
+ assertEquals(listOf("renderId", "sessionId", "screenId", "renderVersion", "sduiVersion", "os", "t"), e.keys.toList())
42
+ assertEquals(SduiView.VERSION, e["sduiVersion"]); assertEquals("ios", e["os"]); assertEquals(1000L, e["t"])
43
+ }
44
+
45
+ @Test fun renderIdsAreUniqueAndAtLeast12Chars() {
46
+ val (_, tracker) = mk()
47
+ val ids = (1..50).map { tracker.begin(ctx).renderId }.toSet()
48
+ assertEquals(50, ids.size); ids.forEach { assertTrue(it.length >= 12) }
49
+ assertEquals(1000L.toString(36).length + 12, newRenderId(1000L, Random(1)).length)
50
+ }
51
+
52
+ // ---- events ----------------------------------------------------------------------------------------------------------
53
+ @Test fun everySessionMethodMapsToItsEvent() {
54
+ val (sink, tracker) = mk(); val s = tracker.begin(ctx)
55
+ s.start("sdui_parse"); s.mark("sdui_parse", mapOf("bytesRaw" to 10))
56
+ s.error(SduiError("fetch", "E_X", true), "body.0")
57
+ s.nodeError("unsupported_type", "unsupported_type", "body.1", "Foo", "a")
58
+ assertTrue(sink.records.all { it.event.name == "ops_info_checked" })
59
+ assertEquals(listOf("sdui_parse", "sdui_error", "sdui_node_error"), names(sink))
60
+ assertEquals("sdui_parse", sink.records[0].event.fields["step"]); assertEquals(mapOf("bytesRaw" to 10), sink.records[0].event.fields["extra"])
61
+ assertEquals(
62
+ mapOf("step" to "sdui_node_error", "code" to "unsupported_type", "reason" to "unsupported_type", "nodePath" to "body.1", "nodeId" to "a", "nodeType" to "Foo"),
63
+ sink.records[2].event.fields)
64
+ }
65
+
66
+ @Test fun markMeasuresFromStartAndNeverGoesNegative() {
67
+ val (sink, tracker) = mk(); now = 1000
68
+ val s = tracker.begin(ctx); s.start("sdui_parse"); now = 1250; s.mark("sdui_parse")
69
+ assertEquals(250L, sink.records[0].event.fields["duration"])
70
+ now = 5000; val s2 = tracker.begin(ctx); now = 5040; s2.mark("first_paint") // never started: from session begin
71
+ assertEquals(40L, sink.records[1].event.fields["duration"])
72
+ now = 1000
73
+ }
74
+
75
+ // ---- sampler ---------------------------------------------------------------------------------------------------------
76
+ @Test fun rateZeroDropsRenderStepsButKeepsErrorsNodeErrorsAndDiagnostics() {
77
+ val (sink, tracker) = mk(0.0); val s = tracker.begin(ctx)
78
+ s.mark("sdui_parse"); s.mark("render_done"); s.error(SduiError("fetch", "E", false)); s.nodeError("unknown_token", "unknown_token", "p")
79
+ assertEquals(listOf("sdui_error", "sdui_node_error"), names(sink))
80
+ }
81
+
82
+ @Test fun samplerDecidesOncePerSessionAndIsDeterministic() {
83
+ val sample = createSampler(0.5); val first = sample("abc", "sdui_parse")
84
+ repeat(10) { assertEquals(first, sample("abc", "render_done")) }
85
+ assertEquals(first, createSampler(0.5)("abc", "sdui_parse"))
86
+ assertTrue(createSampler(1.0)("s", "sdui_parse"))
87
+ val s3 = createSampler(0.3); val kept = (0 until 2000).count { s3("session-$it", "sdui_parse") }
88
+ assertTrue(kept / 2000.0 > 0.2 && kept / 2000.0 < 0.4)
89
+ }
90
+
91
+ // ---- sanitizer -------------------------------------------------------------------------------------------------------
92
+ private val env = mapOf("renderId" to "r", "sessionId" to "s", "screenId" to "x", "renderVersion" to 1, "t" to 1L)
93
+
94
+ @Test fun sanitizerDropsUnknownFieldsAndUnknownEvents() {
95
+ val rec = TrackRecord(TrackEvent(mapOf("step" to "sdui_error", "stage" to "fetch", "code" to "E", "retryable" to true, "userName" to "Hung", "data" to mapOf("a" to 1))), env + ("phone" to "09"))
96
+ val out = sanitizeRecord(rec)!!
97
+ assertEquals(TrackEvent(mapOf("step" to "sdui_error", "stage" to "fetch", "code" to "E", "retryable" to true)), out.event)
98
+ assertEquals("ops_info_checked", out.event.name)
99
+ assertFalse(out.envelope.containsKey("phone"))
100
+ assertNull(sanitizeRecord(TrackRecord(TrackEvent(mapOf("step" to "nope")), env)))
101
+ assertNull(sanitizeRecord(TrackRecord(TrackEvent(), env)))
102
+ // fields of another step are not allowed through
103
+ val cross = sanitizeRecord(TrackRecord(TrackEvent(mapOf("step" to "sdui_node_error", "code" to "c", "stage" to "x", "duration" to 3L)), env))!!
104
+ assertEquals(mapOf("step" to "sdui_node_error", "code" to "c"), cross.event.fields)
105
+ }
106
+
107
+ @Test fun sanitizerTruncatesStringsAndDropsNonPrimitives() {
108
+ val long = "x".repeat(500)
109
+ val out = sanitizeRecord(TrackRecord(TrackEvent(mapOf("step" to "sdui_node_error", "code" to "unknown_token", "reason" to "unknown_token", "nodePath" to long, "nodeType" to mapOf("a" to 1), "nodeId" to Double.NaN)), env + ("renderId" to long)))!!
110
+ assertEquals(MAX_STRING, (out.event.fields["nodePath"] as String).length)
111
+ assertFalse(out.event.fields.containsKey("nodeType")); assertFalse(out.event.fields.containsKey("nodeId"))
112
+ assertEquals(MAX_STRING, (out.envelope["renderId"] as String).length)
113
+ }
114
+
115
+ @Test fun extraIsFilteredByKeyAllowlistAndPrimitiveType() {
116
+ val out = sanitizeRecord(TrackRecord(TrackEvent(mapOf("step" to "sdui_parse", "duration" to 5L, "extra" to mapOf("bytesRaw" to 9, "secret" to "x", "ok" to mapOf("a" to 1)))), env))!!
117
+ assertEquals(mapOf("bytesRaw" to 9), out.event.fields["extra"])
118
+ }
119
+
120
+ @Test fun recordsReachSinksAlreadySanitized() {
121
+ val (sink, tracker) = mk(); tracker.begin(ctx).error(SduiError("fetch", "x".repeat(300), true, detail = "user said hi"))
122
+ val ev = sink.records[0].event; assertEquals(MAX_STRING, (ev.fields["code"] as String).length); assertFalse(ev.fields.containsKey("detail"))
123
+ }
124
+
125
+ // ---- isolation -------------------------------------------------------------------------------------
126
+ @Test fun aThrowingSinkDoesNotBreakOthersOrTheCaller() {
127
+ val good = FakeSink()
128
+ val bad = object : TrackSink { override val id = "bad"; override fun write(record: TrackRecord) = error("x") }
129
+ val tracker = Tracker(listOf(bad, good), "s", clock = { now })
130
+ val s = tracker.begin(ctx); s.mark("sdui_parse"); s.end("success")
131
+ assertEquals(1, good.records.size)
132
+ }
133
+
134
+ // ---- sinks -----------------------------------------------------------------------------------------------------------
135
+ private val rec = TrackRecord(TrackEvent(mapOf("step" to "sdui_parse", "duration" to 12L, "extra" to mapOf("bytesRaw" to 3))),
136
+ mapOf("renderId" to "r1", "sessionId" to "s", "screenId" to "sdui:x", "renderVersion" to 1, "os" to null, "t" to 7L))
137
+
138
+ @Test fun trackifySinkFlattensWithoutNulls() {
139
+ var got: Pair<String, Map<String, Any>>? = null
140
+ TrackifySink { n, p -> got = n to p }.write(rec)
141
+ assertEquals("ops_info_checked" to mapOf<String, Any>("renderId" to "r1", "sessionId" to "s", "screenId" to "sdui:x", "renderVersion" to 1, "t" to 7L, "step" to "sdui_parse", "duration" to 12L, "extra_bytesRaw" to 3), got)
142
+ }
143
+
144
+ @Test fun nothingIsReportedAfterTheSessionEnded() {
145
+ val (sink, tracker) = mk()
146
+ val s = tracker.begin(ctx)
147
+ s.error(SduiError("render", "RENDER", false), "body.children.0")
148
+ s.end("success")
149
+ val before = sink.records.size
150
+ // a late callback arrives after the session is over
151
+ s.error(SduiError("render", "RENDER", false), "body.children.0")
152
+ s.mark("render_done")
153
+ assertEquals(before, sink.records.size)
154
+ }
155
+
156
+ // ---- sdui_node_error ------------------------------------------------------------------------------------------------
157
+ private fun nodeErrorEvents(s: FakeSink) = s.records.filter { it.event.step == "sdui_node_error" }
158
+
159
+ @Test fun nodeErrorCarriesItsFieldsAndTheEnvelope() {
160
+ val (sink, tracker) = mk(); val s = tracker.begin(SessionCtx("sdui:view:b"))
161
+ s.nodeError("expr_failed", "expr_failed", "body.children.2", "Text", "title")
162
+ val r = nodeErrorEvents(sink).single()
163
+ assertEquals(mapOf("step" to "sdui_node_error", "code" to "expr_failed", "reason" to "expr_failed", "nodePath" to "body.children.2", "nodeId" to "title", "nodeType" to "Text"), r.event.fields)
164
+ assertEquals(s.renderId, r.envelope["renderId"]); assertEquals("sdui:view:b", r.envelope["screenId"])
165
+ }
166
+
167
+ @Test fun nodeErrorOmitsUnknownIdAndType() {
168
+ val (sink, tracker) = mk(); tracker.begin(ctx).nodeError("invalid_action", "unknown_type", "body.children.0")
169
+ assertEquals(setOf("step", "code", "reason", "nodePath"), nodeErrorEvents(sink).single().event.fields.keys)
170
+ }
171
+
172
+ @Test fun identicalNodeErrorsCountOnceButDifferentOnesDoNot() {
173
+ val (sink, tracker) = mk(); val s = tracker.begin(ctx)
174
+ repeat(5) { s.nodeError("expr_failed", "expr_failed", "body.children.0", "Text", "a") } // repeat copies share a nodePath
175
+ s.nodeError("unknown_token", "unknown_token", "body.children.0", "Text", "a") // other code, same node
176
+ s.nodeError("invalid_action", "missing_type", "body.children.0", "Text", "a")
177
+ s.nodeError("invalid_action", "unknown_type", "body.children.0", "Text", "a") // other reason
178
+ s.nodeError("expr_failed", "expr_failed", "body.children.1", "Text", "b") // other node
179
+ assertEquals(5, nodeErrorEvents(sink).size)
180
+ }
181
+
182
+ @Test fun nodeErrorsAreNotCapped() {
183
+ val (sink, tracker) = mk(); val s = tracker.begin(ctx)
184
+ repeat(150) { s.nodeError("unsupported_type", "unsupported_type", "body.children.$it", "Foo", null) }
185
+ assertEquals(150, nodeErrorEvents(sink).size)
186
+ }
187
+
188
+ @Test fun nodeErrorsSurviveEndWhileRenderStepsDoNot() {
189
+ val (sink, tracker) = mk(); val s = tracker.begin(ctx)
190
+ s.mark("render_done"); s.end("success")
191
+ s.mark("first_paint")
192
+ s.nodeError("unsupported_type", "unsupported_type", "body.children.9", "Foo", "late")
193
+ assertEquals(listOf("render_done", "sdui_node_error"), names(sink))
194
+ val late = nodeErrorEvents(sink).single()
195
+ assertEquals(s.renderId, late.envelope["renderId"])
196
+ }
197
+
198
+ @Test fun nodeErrorIsNeverSampledOut() {
199
+ val (sink, tracker) = mk(0.0); tracker.begin(ctx).nodeError("expr_failed", "expr_failed", "body")
200
+ assertEquals(1, nodeErrorEvents(sink).size)
201
+ }
202
+
203
+ @Test fun renderDoneCarriesNoNodesTotal() {
204
+ val (sink, tracker) = mk(); val s = tracker.begin(ctx)
205
+ s.mark("render_done", mapOf("nodesTotal" to 12, "ok" to true))
206
+ assertEquals(mapOf("ok" to true), sink.records.single().event.fields["extra"])
207
+ }
208
+
209
+ @Test fun sentEventsCarryExactlyTheseFields() {
210
+ val sent = ArrayList<Pair<String, Map<String, Any>>>()
211
+ val tracker = Tracker(listOf(TrackifySink { n, p -> sent += n to p }), "sess-1", os = "ios", clock = { now })
212
+ val s = tracker.begin(ctx)
213
+ s.mark("sdui_parse", mapOf("ok" to true, "bytesRaw" to 10, "secret" to "x"), durationMs = 5L)
214
+ s.nodeError("unsupported_type", "unsupported_type", "body.children.1", "Foo", "a")
215
+ assertEquals(2, sent.size); assertTrue(sent.all { it.first == "ops_info_checked" })
216
+ val envelope = listOf("renderId", "sessionId", "screenId", "renderVersion", "sduiVersion", "os", "t")
217
+ assertEquals(envelope + listOf("step", "duration", "extra_ok", "extra_bytesRaw"), sent[0].second.keys.toList())
218
+ assertEquals(envelope + listOf("step", "code", "reason", "nodePath", "nodeId", "nodeType"), sent[1].second.keys.toList())
219
+ assertEquals(listOf<Any>(s.renderId, "sess-1", "sdui:sdui/home", 1, SduiView.VERSION, "ios", 1000L, "sdui_parse", 5L, true, 10), sent[0].second.values.toList())
220
+ assertEquals(listOf<Any>("unsupported_type", "unsupported_type", "body.children.1", "a", "Foo"), sent[1].second.values.toList().drop(8))
221
+ }
222
+
223
+ @Test fun actionIsNoLongerAStep() {
224
+ assertNull(sanitizeRecord(TrackRecord(TrackEvent(mapOf("step" to "sdui_action", "verb" to "set")), env)))
225
+ assertNull(sanitizeRecord(TrackRecord(TrackEvent(mapOf("step" to "sdui_block_skipped", "reason" to "x")), env)))
226
+ }
227
+
228
+ @Test fun defaultWiringReportsEventsToTrack() {
229
+ val calls = ArrayList<String>()
230
+ val api = fakeMaxApi { name, args -> calls += name + ":" + args.filter { it !is Function<*> }.map { if (it is Array<*>) it.toList() else it } }
231
+ val tracker = SduiTracking.createDefault(SduiMaxApi({ api }))
232
+ val s = tracker.begin(SessionCtx(screenId = "sdui:view:block"))
233
+ s.error(SduiError("render", "RENDER", false), "body")
234
+ assertTrue(calls.any { it.startsWith("track:[") && "sdui_error" in it })
235
+ assertTrue(calls.none { it.startsWith("showToastDebug") })
236
+ assertNotNull(sampleBucket("abc")); assertTrue(sampleBucket("abc") in 0.0..1.0)
237
+ }
238
+ }
239
+ // AI-GENERATED END: unit tests for SDUI tracking