sprint10-testing-patterns

Testing procedures for finding five known failure types from Sprint 10, including hydration errors. Hydration is the process of connecting browser behavior to HTML first produced on the server.

In plain words
What is it for?
Use them to test production builds, start the production server, check both themes, inspect browser errors, and test that React components render consistently on the server and browser.
Why use it?
They catch build and browser-rendering problems before code is committed, especially mismatches between server output and what the browser expects.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/rm2thaddeus/pixel_detective/sprint10-testing-patterns
Clone the repo
git clone --depth 1 https://github.com/rm2thaddeus/Pixel_Detective

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,352 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02352
Opus 5 $0.00000 $0.01176
Sonnet 5 $0.00000 $0.00470
Haiku 4.5 $0.00000 $0.00235

Measured 2d ago against content hash 21ae359837b3, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

sprint10-testing-patterns scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

curl -f http://localhost:3025/health > /dev/null 2>&1
.cursor/rules/sprint10-testing-patterns.mdc · 322 lines

How it starts

The opening of the file, as written. The whole thing — 322 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Sprint 10 Testing Patterns - Prevention Through Testing

🎯 GOAL: Catch Sprint 10 Issues Before They Become Problems

These testing patterns specifically target the 5 critical failure modes identified in Sprint 10.

🔥 HYDRATION ERROR TESTING

Pre-Commit Hydration Testing
# MANDATORY before any theme/client-side commits
#!/bin/bash
echo "🧪 Testing for hydration issues..."

# 1. Production build test (catches 90% of hydration issues)
npm run build
if [ $? -ne 0 ]; then
  echo "❌ Build failed - fix before committing"
  exit 1
fi

# 2. Start production server and test both themes
npm start &
SERVER_PID=$!
sleep 5

# 3. Check for hydration errors in browser console
# Use Browser Tools MCP if available
mcp_browser-tools_takeScreenshot || echo "⚠️ MCP not available, manual test required"

kill $SERVER_PID
echo "✅ Hydration test complete"
Component-Level Hydration Testing
// Test file: __tests__/hydration.test.tsx
import { renderToString } from 'react-dom/server';
import { render } from '@testing-library/react';

describe('Hydration Safety', () => {
  test('Theme Provider renders consistently', () => {
    const ThemeWrapper = ({ children }) => (
      <ChakraProvider theme={theme}>{children}</ChakraProvider>
    );
    
    // Server render
    const serverHTML = renderToString(<ThemeWrapper><App /></ThemeWrapper>);
    
    // Client render
    const { container } = render(<ThemeWrapper><App /></ThemeWrapper>);
    
    // Should match (simplified check)
    expect(container.innerHTML).toContain('expected-theme-class');
  });
  
  test('No browser APIs in initial render', () => {
    // Mock browser APIs to undefined
    Object.defineProperty(window, 'localStorage', { value: undefined });
    Object.defineProperty(window, 'innerWidth', { value: undefined });
    
    // Should not throw during render
    expect(() => {
      render(<App />);
    }).not.toThrow();
  });
});

🔥 CIRCULAR IMPORT TESTING

Backend Import Validation
# backend/tests/test_imports.py
import ast
import os
from pathlib import Path

def test_no_main_imports_in_routers():
    """Ensure routers never import from main.py"""
    router_dir = Path("backend/routers")
    violations = []
    
    for py_file in router_dir.glob("*.py"):
        with open(py_file, 'r') as f:
            content = f.read()
            
        # Parse AST to find imports
        tree = ast.parse(content)
        for node in ast.walk(tree):
            if isinstance(node, ast.ImportFrom):
                if node.module and "main" in node.module:
                    violations.append(f"{py_file}: {ast.unparse(node)}")
    
    assert not violations, f"Found main.py imports in routers: {violations}"

def test_dependency_injection_usage():
    """Ensure routers use Depends() pattern"""
    router_dir = Path("backend/routers")
    
    for py_file in router_dir.glob("*.py"):
        if py_file.name == "__init__.py":
            continue
            
        with open(py_file, 'r') as f:
            content = f.read()
            
        # Should use Depends() for shared resources
        assert "Depends(" in content, f"{py_file} should use dependency injection"
        assert "from ..dependencies import" in content, f"{py_file} should import from dependencies"

Read the full file on GitHub · 322 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 322 lines · 0 tokens per session scan A 21ae359837b3

Subscribe to this mod's changes

sprint10-testing-patterns is a cursor rule published in the GitHub repository rm2thaddeus/Pixel_Detective (21 stars, last pushed 7mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,352 tokens. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.