fix: harden unicode safety checks

This commit is contained in:
Affaan Mustafa
2026-03-29 08:59:06 -04:00
parent 527c79350c
commit 1e0de43ef2
239 changed files with 3780 additions and 3962 deletions

View File

@@ -335,28 +335,28 @@ npm run test:coverage
## 应避免的常见测试错误
### 错误:测试实现细节
### FAIL: 错误:测试实现细节
```typescript
// Don't test internal state
expect(component.state.count).toBe(5)
```
### 正确:测试用户可见的行为
### PASS: 正确:测试用户可见的行为
```typescript
// Test what users see
expect(screen.getByText('Count: 5')).toBeInTheDocument()
```
### 错误:脆弱的定位器
### FAIL: 错误:脆弱的定位器
```typescript
// Breaks easily
await page.click('.css-class-xyz')
```
### 正确:语义化定位器
### PASS: 正确:语义化定位器
```typescript
// Resilient to changes
@@ -364,7 +364,7 @@ await page.click('button:has-text("Submit")')
await page.click('[data-testid="submit-button"]')
```
### 错误:没有测试隔离
### FAIL: 错误:没有测试隔离
```typescript
// Tests depend on each other
@@ -372,7 +372,7 @@ test('creates user', () => { /* ... */ })
test('updates same user', () => { /* depends on previous test */ })
```
### 正确:独立的测试
### PASS: 正确:独立的测试
```typescript
// Each test sets up its own data