chore: migrate tests from tests-ui/ to colocate with source files (#7811)

## Summary

Migrates all unit tests from `tests-ui/` to colocate with their source
files in `src/`, improving discoverability and maintainability.

## Changes

- **What**: Relocated all unit tests to be adjacent to the code they
test, following the `<source>.test.ts` naming convention
- **Config**: Updated `vitest.config.ts` to remove `tests-ui` include
pattern and `@tests-ui` alias
- **Docs**: Moved testing documentation to `docs/testing/` with updated
paths and patterns

## Review Focus

- Migration patterns documented in
`temp/plans/migrate-tests-ui-to-src.md`
- Tests use `@/` path aliases instead of relative imports
- Shared fixtures placed in `__fixtures__/` directories

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-7811-chore-migrate-tests-from-tests-ui-to-colocate-with-source-files-2da6d73d36508147a4cce85365dee614)
by [Unito](https://www.unito.io)

---------

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Alexander Brown
2026-01-05 16:32:24 -08:00
committed by GitHub
parent 832588c7a9
commit 10feb1fd5b
272 changed files with 483 additions and 1239 deletions

View File

@@ -1,144 +0,0 @@
import { beforeEach, describe, expect, test } from 'vitest'
import { Rectangle } from '@/lib/litegraph/src/litegraph'
describe('Rectangle resize functionality', () => {
let rect: Rectangle
beforeEach(() => {
rect = new Rectangle(100, 200, 300, 400) // x, y, width, height
// So: left=100, top=200, right=400, bottom=600
})
describe('findContainingCorner', () => {
const cornerSize = 15
test('should detect NW (top-left) corner', () => {
expect(rect.findContainingCorner(100, 200, cornerSize)).toBe('NW')
expect(rect.findContainingCorner(110, 210, cornerSize)).toBe('NW')
expect(rect.findContainingCorner(114, 214, cornerSize)).toBe('NW')
})
test('should detect NE (top-right) corner', () => {
// Top-right corner starts at (right - cornerSize, top) = (385, 200)
expect(rect.findContainingCorner(385, 200, cornerSize)).toBe('NE')
expect(rect.findContainingCorner(390, 210, cornerSize)).toBe('NE')
expect(rect.findContainingCorner(399, 214, cornerSize)).toBe('NE')
})
test('should detect SW (bottom-left) corner', () => {
// Bottom-left corner starts at (left, bottom - cornerSize) = (100, 585)
expect(rect.findContainingCorner(100, 585, cornerSize)).toBe('SW')
expect(rect.findContainingCorner(110, 590, cornerSize)).toBe('SW')
expect(rect.findContainingCorner(114, 599, cornerSize)).toBe('SW')
})
test('should detect SE (bottom-right) corner', () => {
// Bottom-right corner starts at (right - cornerSize, bottom - cornerSize) = (385, 585)
expect(rect.findContainingCorner(385, 585, cornerSize)).toBe('SE')
expect(rect.findContainingCorner(390, 590, cornerSize)).toBe('SE')
expect(rect.findContainingCorner(399, 599, cornerSize)).toBe('SE')
})
test('should return undefined when not in any corner', () => {
// Middle of rectangle
expect(rect.findContainingCorner(250, 400, cornerSize)).toBeUndefined()
// On edge but not in corner
expect(rect.findContainingCorner(200, 200, cornerSize)).toBeUndefined()
expect(rect.findContainingCorner(100, 400, cornerSize)).toBeUndefined()
// Outside rectangle
expect(rect.findContainingCorner(50, 150, cornerSize)).toBeUndefined()
})
})
describe('corner detection methods', () => {
const cornerSize = 20
describe('isInTopLeftCorner', () => {
test('should return true when point is in top-left corner', () => {
expect(rect.isInTopLeftCorner(100, 200, cornerSize)).toBe(true)
expect(rect.isInTopLeftCorner(110, 210, cornerSize)).toBe(true)
expect(rect.isInTopLeftCorner(119, 219, cornerSize)).toBe(true)
})
test('should return false when point is outside top-left corner', () => {
expect(rect.isInTopLeftCorner(120, 200, cornerSize)).toBe(false)
expect(rect.isInTopLeftCorner(100, 220, cornerSize)).toBe(false)
expect(rect.isInTopLeftCorner(99, 200, cornerSize)).toBe(false)
expect(rect.isInTopLeftCorner(100, 199, cornerSize)).toBe(false)
})
})
describe('isInTopRightCorner', () => {
test('should return true when point is in top-right corner', () => {
// Top-right corner area is from (right - cornerSize, top) to (right, top + cornerSize)
// That's (380, 200) to (400, 220)
expect(rect.isInTopRightCorner(380, 200, cornerSize)).toBe(true)
expect(rect.isInTopRightCorner(390, 210, cornerSize)).toBe(true)
expect(rect.isInTopRightCorner(399, 219, cornerSize)).toBe(true)
})
test('should return false when point is outside top-right corner', () => {
expect(rect.isInTopRightCorner(379, 200, cornerSize)).toBe(false)
expect(rect.isInTopRightCorner(400, 220, cornerSize)).toBe(false)
expect(rect.isInTopRightCorner(401, 200, cornerSize)).toBe(false)
expect(rect.isInTopRightCorner(400, 199, cornerSize)).toBe(false)
})
})
describe('isInBottomLeftCorner', () => {
test('should return true when point is in bottom-left corner', () => {
// Bottom-left corner area is from (left, bottom - cornerSize) to (left + cornerSize, bottom)
// That's (100, 580) to (120, 600)
expect(rect.isInBottomLeftCorner(100, 580, cornerSize)).toBe(true)
expect(rect.isInBottomLeftCorner(110, 590, cornerSize)).toBe(true)
expect(rect.isInBottomLeftCorner(119, 599, cornerSize)).toBe(true)
})
test('should return false when point is outside bottom-left corner', () => {
expect(rect.isInBottomLeftCorner(120, 600, cornerSize)).toBe(false)
expect(rect.isInBottomLeftCorner(100, 579, cornerSize)).toBe(false)
expect(rect.isInBottomLeftCorner(99, 600, cornerSize)).toBe(false)
expect(rect.isInBottomLeftCorner(100, 601, cornerSize)).toBe(false)
})
})
describe('isInBottomRightCorner', () => {
test('should return true when point is in bottom-right corner', () => {
// Bottom-right corner area is from (right - cornerSize, bottom - cornerSize) to (right, bottom)
// That's (380, 580) to (400, 600)
expect(rect.isInBottomRightCorner(380, 580, cornerSize)).toBe(true)
expect(rect.isInBottomRightCorner(390, 590, cornerSize)).toBe(true)
expect(rect.isInBottomRightCorner(399, 599, cornerSize)).toBe(true)
})
test('should return false when point is outside bottom-right corner', () => {
expect(rect.isInBottomRightCorner(379, 600, cornerSize)).toBe(false)
expect(rect.isInBottomRightCorner(400, 579, cornerSize)).toBe(false)
expect(rect.isInBottomRightCorner(401, 600, cornerSize)).toBe(false)
expect(rect.isInBottomRightCorner(400, 601, cornerSize)).toBe(false)
})
})
})
describe('edge cases', () => {
test('should handle zero-sized corner areas', () => {
expect(rect.findContainingCorner(100, 200, 0)).toBeUndefined()
expect(rect.isInTopLeftCorner(100, 200, 0)).toBe(false)
})
test('should handle rectangles at origin', () => {
const originRect = new Rectangle(0, 0, 100, 100)
expect(originRect.findContainingCorner(0, 0, 10)).toBe('NW')
// Bottom-right corner is at (90, 90) to (100, 100)
expect(originRect.findContainingCorner(90, 90, 10)).toBe('SE')
})
test('should handle negative coordinates', () => {
const negRect = new Rectangle(-50, -50, 100, 100)
expect(negRect.findContainingCorner(-50, -50, 10)).toBe('NW')
// Bottom-right corner is at (40, 40) to (50, 50)
expect(negRect.findContainingCorner(40, 40, 10)).toBe('SE')
})
})
})