Repository: streamlit/streamlit
File: frontend/app/src/App.test.tsx (TypeScript)

Code before:
        primaryColor: "blue",
        light: {
          backgroundColor: "white",
        },
        dark: {
          backgroundColor: "black",
        },
      })

      sendForwardMessage("newSession", {
        ...NEW_SESSION_JSON,
        customTheme,
      })

      // Should apply Custom Theme Light (from embed_options), not Dark (from cache)
      expect(props.theme.setTheme).toHaveBeenCalled()
      const appliedTheme = vi.mocked(props.theme.setTheme).mock.calls[0][0]
      expect(appliedTheme.name).toBe(CUSTOM_THEME_LIGHT_NAME)
      expect(appliedTheme.emotion.colors.bgColor).toBe("white")
    })

    it("respects embed_options=dark_theme over cached light preference", () => {
      // Set cached theme to light
      const cachedTheme: CachedTheme = {
        name: CUSTOM_THEME_LIGHT_NAME,
      }
      window.localStorage.setItem(
        LocalStore.ACTIVE_THEME,
        JSON.stringify(cachedTheme)
      )

      // Mock query params with dark_theme
      setLocationSearch("?embed=true&embed_options=dark_theme")

      const props = getProps()
      renderApp(props)

      // Send custom theme config with light and dark sections
      const customTheme = new CustomThemeConfig({
        primaryColor: "blue",
        light: {
          backgroundColor: "white",
        },
        dark: {
          backgroundColor: "black",
        },
      })

      sendForwardMessage("newSession", {
        ...NEW_SESSION_JSON,
        customTheme,

Review comment (performance):
**Nit**: same
```javascript
// Set cached theme to light (with required themeInput for custom themes)
const cachedTheme: CachedTheme = {
  name: CUSTOM_THEME_LIGHT_NAME,
  themeInput: { primaryColor: "blue" },
}
```

Code after:

    it("respects embed_options=light_theme over cached dark preference", () => {
      // Set cached theme to dark
      window.localStorage.setItem(
        LocalStore.ACTIVE_THEME,
        JSON.stringify(cachedDarkTheme)
      )

      // Mock query params with light_theme
      setLocationSearch("?embed=true&embed_options=light_theme")

      const props = getProps()
      renderApp(props)

      // Send custom theme config with light and dark sections
      sendForwardMessage("newSession", {
        ...NEW_SESSION_JSON,
        customTheme,
      })

      // Should apply Custom Theme Light (from embed_options), not Dark (from cache)
      expect(props.theme.setTheme).toHaveBeenCalled()
      const appliedTheme = vi.mocked(props.theme.setTheme).mock.calls[0][0]
      expect(appliedTheme.name).toBe(CUSTOM_THEME_LIGHT_NAME)
      expect(appliedTheme.emotion.colors.bgColor).toBe("white")
    })

    it("respects embed_options=dark_theme over cached light preference", () => {
      // Set cached theme to light
      window.localStorage.setItem(
        LocalStore.ACTIVE_THEME,
        JSON.stringify(cachedLightTheme)
      )

      // Mock query params with dark_theme
      setLocationSearch("?embed=true&embed_options=dark_theme")

      const props = getProps()
      renderApp(props)

      // Send custom theme config with light and dark sections
      sendForwardMessage("newSession", {
        ...NEW_SESSION_JSON,
        customTheme,
      })

      // Should apply Custom Theme Dark (from embed_options), not Light (from cache)
      expect(props.theme.setTheme).toHaveBeenCalled()
      const appliedTheme = vi.mocked(props.theme.setTheme).mock.calls[0][0]
      expect(appliedTheme.name).toBe(CUSTOM_THEME_DARK_NAME)
      expect(appliedTheme.emotion.colors.bgColor).toBe("black")