mirror of
https://github.com/hanzoai/gui.git
synced 2026-10-25 02:31:41 +00:00
This repo could never sync. There was NO merge-base with tamagui — 372 commits
here against 15,791 there, unrelated histories — because it began as a
copy-paste rebrand with a flattened layout. Every "sync" since was a hand
re-application that drifted, which is why the tree sat on 7.3.1 while upstream
shipped fixes we then rediscovered by hand.
This commit's PARENT IS TAMAGUI. A future sync is `git merge tama/main` then
`node scripts/rebrand.mjs` — a real merge, because the history is now shared.
174 packages: 166 upstream, our 8 restored (chrome, shell, telemetry, recipes,
get, font-geist-{sans,mono}, @hanzo/booker), bento-get gained. 170/170 build.
Our patches to files UPSTREAM ALSO OWNS are carried, which the package-level
delta missed and which was where the value actually was:
- useMedia's server snapshot (`initState ?? getMedia()`). Upstream still
returns undefined there, so every Tamagui Dialog kills a prerender — the
exact crash hanzo.app spent a day on.
- data-slot on web host nodes, absent upstream entirely.
Both applied ONTO upstream's newer files (it rewrote useMedia +150/-63 and
createComponent +160/-55), marked `PATCH (ours, carried across the transplant)`.
Seven traps are encoded in scripts/rebrand.mjs, each found by a gate:
skip itself and lockfiles; special-case the double-branded names in BOTH scoped
and bare form; map path strings, not just paths; drop a level for the flattened
group; check disk rather than a stale index.
Rust build artifacts are NOT committed. An earlier draft of this commit swept
apps/desktop/src-tauri/target/debug in via `git add -A` — 3,859 files including
a 272MB .a, over GitHub's 100MB cap, so the push could never have landed. They
are gitignored now.
Co-Authored-By: Hanzo Dev <[email protected]>
133 lines
4.4 KiB
TypeScript
133 lines
4.4 KiB
TypeScript
/**
|
|
* Basic theme change test - verifies Theme component correctly updates children
|
|
* when theme name changes (no animations involved).
|
|
*
|
|
* This tests the core theme switching functionality that was broken
|
|
* with react-native and reanimated animation drivers.
|
|
*/
|
|
|
|
import * as assert from 'assert'
|
|
import { by, device, element, expect, waitFor } from 'detox'
|
|
import { safeLaunchApp } from './utils/detox'
|
|
import { remountDirectUseCase } from './utils/navigation'
|
|
import { getDominantColor, isBlueish, isReddish, formatRGB } from './utils/colors'
|
|
|
|
// Launch model: launch the native app ONCE with directUseCase, then remount the
|
|
// case in-app per test (deep link, no relaunch). The case's theme is local
|
|
// useState('red'), so a remount restores the initial red state each test.
|
|
describe('ThemeChangeBasic', () => {
|
|
beforeAll(async () => {
|
|
await safeLaunchApp({
|
|
newInstance: true,
|
|
launchArgs: { directUseCase: 'ThemeChangeBasic' },
|
|
})
|
|
await waitFor(element(by.id('theme-change-basic-root')))
|
|
.toExist()
|
|
.withTimeout(180000)
|
|
})
|
|
|
|
beforeEach(async () => {
|
|
await remountDirectUseCase('theme-change-basic-root')
|
|
})
|
|
|
|
it('should show initial red theme', async () => {
|
|
await expect(element(by.id('theme-change-basic-label'))).toHaveText(
|
|
'Current theme: red'
|
|
)
|
|
await expect(element(by.id('theme-change-basic-square'))).toBeVisible()
|
|
})
|
|
|
|
it('should change theme color when toggle is pressed', async () => {
|
|
// verify initial red state
|
|
await expect(element(by.id('theme-change-basic-label'))).toHaveText(
|
|
'Current theme: red'
|
|
)
|
|
|
|
// take screenshot of red state
|
|
const redScreenshot = await element(
|
|
by.id('theme-change-basic-square')
|
|
).takeScreenshot('theme-red')
|
|
const redColor = getDominantColor(redScreenshot)
|
|
console.log(`Red theme color: ${formatRGB(redColor)}`)
|
|
|
|
// tap to change to blue
|
|
await element(by.id('theme-change-basic-toggle')).tap()
|
|
|
|
// wait for theme to update
|
|
await waitFor(element(by.id('theme-change-basic-label')))
|
|
.toHaveText('Current theme: blue')
|
|
.withTimeout(5000)
|
|
|
|
// small delay for any potential visual updates
|
|
await new Promise((r) => setTimeout(r, 300))
|
|
|
|
// take screenshot of blue state
|
|
const blueScreenshot = await element(
|
|
by.id('theme-change-basic-square')
|
|
).takeScreenshot('theme-blue')
|
|
const blueColor = getDominantColor(blueScreenshot)
|
|
console.log(`Blue theme color: ${formatRGB(blueColor)}`)
|
|
|
|
// verify colors changed
|
|
// red theme $color4 should be reddish
|
|
assert.ok(
|
|
isReddish(redColor),
|
|
`Expected red color to be reddish, got ${formatRGB(redColor)}`
|
|
)
|
|
// blue theme $color4 should be blueish
|
|
assert.ok(
|
|
isBlueish(blueColor),
|
|
`Expected blue color to be blueish, got ${formatRGB(blueColor)}`
|
|
)
|
|
|
|
// extra verification: the colors should be different
|
|
const colorsDiffer =
|
|
Math.abs(redColor.r - blueColor.r) > 30 || Math.abs(redColor.b - blueColor.b) > 30
|
|
assert.ok(
|
|
colorsDiffer,
|
|
`Expected colors to be different: red=${formatRGB(redColor)}, blue=${formatRGB(blueColor)}`
|
|
)
|
|
})
|
|
|
|
it('should toggle theme multiple times', async () => {
|
|
// start at red
|
|
await expect(element(by.id('theme-change-basic-label'))).toHaveText(
|
|
'Current theme: red'
|
|
)
|
|
|
|
// toggle to blue
|
|
await element(by.id('theme-change-basic-toggle')).tap()
|
|
await waitFor(element(by.id('theme-change-basic-label')))
|
|
.toHaveText('Current theme: blue')
|
|
.withTimeout(5000)
|
|
|
|
// verify blue color
|
|
await new Promise((r) => setTimeout(r, 300))
|
|
const blueScreenshot = await element(
|
|
by.id('theme-change-basic-square')
|
|
).takeScreenshot('theme-blue-toggle')
|
|
const blueColor = getDominantColor(blueScreenshot)
|
|
assert.ok(
|
|
isBlueish(blueColor),
|
|
`Expected blue color to be blueish, got ${formatRGB(blueColor)}`
|
|
)
|
|
|
|
// toggle back to red
|
|
await element(by.id('theme-change-basic-toggle')).tap()
|
|
await waitFor(element(by.id('theme-change-basic-label')))
|
|
.toHaveText('Current theme: red')
|
|
.withTimeout(5000)
|
|
|
|
// verify red color
|
|
await new Promise((r) => setTimeout(r, 300))
|
|
const redScreenshot = await element(
|
|
by.id('theme-change-basic-square')
|
|
).takeScreenshot('theme-red-toggle')
|
|
const redColor = getDominantColor(redScreenshot)
|
|
assert.ok(
|
|
isReddish(redColor),
|
|
`Expected red color to be reddish, got ${formatRGB(redColor)}`
|
|
)
|
|
})
|
|
})
|