madhushreeag commented on code in PR #41007:
URL: https://github.com/apache/superset/pull/41007#discussion_r3531682499


##########
superset-frontend/src/theme/tests/ThemeController.test.ts:
##########
@@ -2115,3 +2115,98 @@ test('fetchSystemDefaultTheme: second named-theme 
fallback fetch succeeds when f
     mockGet.mockRestore();
   }
 });
+
+// bootstrapDefaultMode tests
+
+test('bootstrapDefaultMode: reads "dark" from bootstrap config and starts in 
DARK mode', () => {
+  mockGetBootstrapData.mockReturnValue(
+    createMockBootstrapData({
+      default: DEFAULT_THEME,
+      dark: DARK_THEME,
+      defaultMode: 'dark',
+    }),
+  );
+  const controller = createController();
+  expect(controller.getCurrentMode()).toBe(ThemeMode.DARK);
+});
+
+test('bootstrapDefaultMode: reads "default" from bootstrap config and starts 
in DEFAULT mode', () => {
+  mockGetBootstrapData.mockReturnValue(
+    createMockBootstrapData({
+      default: DEFAULT_THEME,
+      dark: DARK_THEME,
+      defaultMode: 'default',
+    }),
+  );
+  const controller = createController();
+  expect(controller.getCurrentMode()).toBe(ThemeMode.DEFAULT);
+});
+
+test('bootstrapDefaultMode: reads "system" from bootstrap config and starts in 
SYSTEM mode', () => {
+  mockGetBootstrapData.mockReturnValue(
+    createMockBootstrapData({
+      default: DEFAULT_THEME,
+      dark: DARK_THEME,
+      defaultMode: 'system',
+    }),
+  );
+  const controller = createController();
+  expect(controller.getCurrentMode()).toBe(ThemeMode.SYSTEM);
+});
+
+test('bootstrapDefaultMode: falls back to DEFAULT when defaultMode is missing 
from bootstrap', () => {
+  mockGetBootstrapData.mockReturnValue(
+    createMockBootstrapData({ default: DEFAULT_THEME, dark: DARK_THEME }),
+  );
+  const controller = createController();
+  expect(controller.getCurrentMode()).toBe(ThemeMode.DEFAULT);
+});
+
+test('bootstrapDefaultMode: falls back to DEFAULT when defaultMode is an 
invalid value', () => {
+  mockGetBootstrapData.mockReturnValue(
+    createMockBootstrapData({
+      default: DEFAULT_THEME,
+      dark: DARK_THEME,
+      defaultMode: 'invalid' as any,
+    }),

Review Comment:
   replaced as any with as unknown as string to stay type-safe while still 
passing invalid values:
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to