AgentSkillsCN

test-helper

协助运行、调试并编写金融引擎与应用程序的测试用例。当您需要运行测试、排查测试失败原因,或为各类计算逻辑创建新的测试用例时,可使用此技能。

SKILL.md
--- frontmatter
name: test-helper
description: Helps run, debug, and write tests for the financial engine and application. Use when running tests, debugging test failures, or creating new test cases for calculations.

Test Helper Skill

Instructions

When working with tests in this project:

  1. Running Tests

    • Unit tests: pnpm test:run (Vitest)
    • Watch mode: pnpm test
    • Coverage: pnpm test:coverage
    • E2E tests: pnpm test:e2e (requires dev server running)
  2. Test File Locations

    • Unit tests: Colocated with source files (*.test.ts)
    • E2E tests: tests/e2e/
    • Security tests: tests/security/
  3. Financial Engine Tests

    • Located in src/lib/engine/
    • Target 100% coverage for engine code
    • Use golden models in validation/golden-models/ for regression testing
  4. Writing New Tests

    • Always use Decimal.js for financial assertions
    • Compare Decimals with .equals() or .toNumber() for approximate comparisons
    • Include edge cases for all three rent models
    • Test all three periods (historical, transition, dynamic)
  5. Debugging Failures

    • Check for floating-point precision issues (use Decimal.js)
    • Verify test data matches expected period calculations
    • Review golden model files for expected outputs
  6. Negotiation Tests (v2.2)

    • Test negotiation CRUD operations at /api/negotiations
    • Verify counter-offer creation and linking
    • Test status transitions (ACTIVE → ACCEPTED/REJECTED/CLOSED)
    • Validate timeline reordering logic
    • Ensure developer + property uniqueness constraint

Common Test Patterns

typescript
import Decimal from 'decimal.js';
import { describe, it, expect } from 'vitest';

describe('Financial Calculation', () => {
  it('should calculate rent correctly', () => {
    const result = calculateRent(input);
    expect(result.rent.equals(new Decimal('1000000'))).toBe(true);
  });
});

Examples

  • "Run the financial engine tests"
  • "Debug why this test is failing"
  • "Write tests for the new rent calculation"
  • "Test the negotiation workflow" (v2.2)
  • "Verify counter-offer creation" (v2.2)