Files
gui/apps/kitchen-sink/tests/StyledMediaQueryMerge.test.tsx
zeekayandHanzo Dev 69c6e860d7 transplant onto tamagui v2.6.0, brand as a re-runnable transform
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]>
2026-07-30 18:25:06 -07:00

67 lines
2.6 KiB
TypeScript

import { expect, test } from '@playwright/test'
import { setupPage } from './test-utils'
import { getStyles, getHoverStyle } from './utils'
test.beforeEach(async ({ page }) => {
await setupPage(page, { name: 'StyledMediaQueryMerge', type: 'useCase' })
await page.setViewportSize({ width: 700, height: 600 })
})
test(`styled component media query merge works correctly`, async ({ page }) => {
// Test 1: $sm media query merge
const test1 = page.locator('#test1')
const styles1 = await getStyles(test1)
// Test 2: $md media query merge
const test2 = page.locator('#test2')
const styles2 = await getStyles(test2)
// Test 3: Both media queries
const test3 = page.locator('#test3')
const styles3 = await getStyles(test3)
// Test 4: Pseudo selector merge
const test4 = page.locator('#test4')
const styles4 = await getStyles(test4)
// Test 5: Direct component
const test5 = page.locator('#test5')
const styles5 = await getStyles(test5)
// Test 1: $sm should have styled definition + runtime override
expect(styles1.paddingTop).toBe('100px')
expect(styles1.marginLeft).toBe('100px')
expect(styles1.marginRight).toBe('100px')
expect(styles1.height).toBe('100px')
expect(styles1.width).toBe('100px')
expect(styles1.backgroundColor).toBe('rgb(0, 0, 255)') // blue (runtime override)
// Test 2: $sm should have styled definition + runtime override
expect(styles2.paddingTop).toBe('100px')
expect(styles2.marginLeft).toBe('100px')
expect(styles2.marginRight).toBe('100px')
expect(styles2.height).toBe('100px')
expect(styles2.width).toBe('100px')
expect(styles2.backgroundColor).toBe('rgb(128, 0, 128)') // purple (runtime override)
// Test 3: $sm media query should be merged with runtime override
expect(styles3.paddingTop).toBe('100px') // from $sm
expect(styles3.marginLeft).toBe('100px') // from $sm
expect(styles3.marginRight).toBe('100px') // from $sm
expect(styles3.height).toBe('100px') // from $sm
expect(styles3.width).toBe('100px') // from $sm
expect(styles3.backgroundColor).toBe('rgb(0, 0, 255)') // blue (from $sm runtime override)
// Test 4: Pseudo selectors should be merged (runtime override)
// Test hover state - runtime override should take precedence
const hoverStyles4 = await getHoverStyle(test4)
expect(hoverStyles4.backgroundColor).toBe('rgb(0, 255, 255)') // cyan (runtime override)
// Test 5: Direct component should work as expected
expect(styles5.paddingTop).toBe('50px')
expect(styles5.marginLeft).toBe('50px')
expect(styles5.marginRight).toBe('50px')
expect(styles5.backgroundColor).toBe('rgb(165, 42, 42)') // brown
})