mirror of
https://github.com/hanzoai/gui.git
synced 2026-10-25 02:31:41 +00:00
The transplant rebuilt the tree on upstream tamagui and carried our own packages forward by hand, which silently lost seven @hanzo_network/* packages and apps/team — 735 files with no other home in the workspace. They are back at the tip of the old lineage's content. pkgs/ai is NOT restored: @hanzo/ai is published from hanzo-js/ai, so a copy here would be the duplicate we are trying to avoid. templates/expo-router is NOT restored: apps/starters/expo-router already declares that exact package name upstream. Also fixes a rebrand defect: the blanket tamagui->hanzogui rule rewrote upstream's GitHub path into github.com/hanzogui/hanzogui, a repo that has never existed, and it shipped in repository.url for every published package. The transform now maps the remote to hanzoai/gui and repairs a tree already branded wrong, so a future sync cannot reintroduce it. Co-authored-by: Hanzo Dev <[email protected]>
101 lines
3.2 KiB
TypeScript
101 lines
3.2 KiB
TypeScript
import { expect, test } from '@playwright/test'
|
|
import { setupPage } from './test-utils'
|
|
|
|
/**
|
|
* tests for onLayout with CSS scale transform.
|
|
*
|
|
* default behavior (no flag):
|
|
* - onLayout reports transformed dimensions (getBoundingClientRect behavior)
|
|
* - a 200x200 element with scale(0.5) reports 100x100
|
|
*
|
|
* with __GUI_ONLAYOUT_PRETRANSFORM = true:
|
|
* - onLayout should report pre-transform dimensions (matching RN behavior)
|
|
* - a 200x200 element with scale(0.5) should report 200x200
|
|
*
|
|
* see: https://github.com/hanzoai/gui/pull/2329
|
|
*/
|
|
|
|
test.describe('onLayout with CSS scale', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await setupPage(page, {
|
|
name: 'OnLayoutScaleCase',
|
|
type: 'useCase',
|
|
waitExtra: true,
|
|
})
|
|
})
|
|
|
|
test('unscaled box always reports correct dimensions (200x200)', async ({ page }) => {
|
|
await page.waitForTimeout(500)
|
|
|
|
const layoutText = await page.getByTestId('layout-no-scale').textContent()
|
|
|
|
expect(layoutText).toContain('200')
|
|
expect(layoutText).toMatch(/200.*200/)
|
|
})
|
|
|
|
test('scaled box reports transformed dimensions by default (100x100)', async ({
|
|
page,
|
|
}) => {
|
|
// ensure flag is OFF
|
|
await page.evaluate(() => {
|
|
;(globalThis as any).__GUI_ONLAYOUT_PRETRANSFORM = false
|
|
})
|
|
|
|
// trigger relayout to pick up the flag change
|
|
await page.getByTestId('trigger-relayout').click()
|
|
await page.waitForTimeout(500)
|
|
|
|
const layoutText = await page.getByTestId('layout-with-scale').textContent()
|
|
|
|
// without flag: 200x200 with scale(0.5) should report 100x100 (transformed)
|
|
expect(layoutText).toContain('100')
|
|
expect(layoutText).toMatch(/100.*100/)
|
|
})
|
|
|
|
test('scaled box reports pre-transform dimensions with flag enabled (200x200)', async ({
|
|
page,
|
|
}) => {
|
|
// enable the flag
|
|
await page.evaluate(() => {
|
|
;(globalThis as any).__GUI_ONLAYOUT_PRETRANSFORM = true
|
|
})
|
|
|
|
// trigger relayout to pick up the flag change
|
|
await page.getByTestId('trigger-relayout').click()
|
|
await page.waitForTimeout(500)
|
|
|
|
const layoutText = await page.getByTestId('layout-with-scale').textContent()
|
|
|
|
// with flag: 200x200 with scale(0.5) should report 200x200 (pre-transform, RN behavior)
|
|
expect(layoutText).toContain('200')
|
|
expect(layoutText).toMatch(/200.*200/)
|
|
})
|
|
|
|
test('both boxes report same dimensions with flag enabled', async ({ page }) => {
|
|
// enable the flag
|
|
await page.evaluate(() => {
|
|
;(globalThis as any).__GUI_ONLAYOUT_PRETRANSFORM = true
|
|
})
|
|
|
|
// trigger relayout
|
|
await page.getByTestId('trigger-relayout').click()
|
|
await page.waitForTimeout(500)
|
|
|
|
const noScaleText = await page.getByTestId('layout-no-scale').textContent()
|
|
const withScaleText = await page.getByTestId('layout-with-scale').textContent()
|
|
|
|
// extract dimensions
|
|
const noScaleMatch = noScaleText?.match(/(\d+)x(\d+)/)
|
|
const withScaleMatch = withScaleText?.match(/(\d+)x(\d+)/)
|
|
|
|
expect(noScaleMatch).toBeTruthy()
|
|
expect(withScaleMatch).toBeTruthy()
|
|
|
|
if (noScaleMatch && withScaleMatch) {
|
|
// with flag enabled, both should report same pre-transform dimensions
|
|
expect(withScaleMatch[1]).toBe(noScaleMatch[1])
|
|
expect(withScaleMatch[2]).toBe(noScaleMatch[2])
|
|
}
|
|
})
|
|
})
|