agentleFS
wecode-aiwecode-ai/Wegent/tests/CLAUDE.md

Wegent / tests

CLAUDE.md867 starsChanged 3 months agoApache-2.0View on GitHub

This document contains guidelines for writing and maintaining E2E tests for the Wegent project. When locating page elements, prefer using data-testid attributes. When to Add data-testid: - Interactive elements (buttons, inputs, links, selects) - Key UI components that need to be tested - Dynamic content containers - Modal dialogs and their triggers After generating new test cases, update the test case documentation file to describe: - What test cases exist - What functionality each test covers - The test file…

The file

We split this CLAUDE.md into the rules it gives an agent

10 rules. About 0 are common, 8 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do a comprehensive check of all test files

    line 50
  2. Distinctive:

    If the documentation is missing descriptions for some test cases, add them

    line 51
  3. Distinctive:

    Keep the documentation organized by feature/module

    line 52
  4. Distinctive:

    Use descriptive test names: - Test names should clearly describe what is being tested

    line 77
  5. Very specific:

    Clean up test data: - Use afterEach to clean up created resources

    line 78
  6. Distinctive:

    Handle onboarding: - Always skip onboarding tour in setup functions

    line 79
  7. Distinctive:

    Wait for elements: - Use appropriate timeouts and visibility checks

    line 80
  8. Very specific:

    Handle dynamic content: - Use Promise.race or conditional checks for elements that may or may not appear

    line 81
  9. Distinctive:

    Document data-testid requirements: - When adding tests that require new data-testid attributes, document them in the PR description

    line 82
  10. Distinctive:

    When adding new tests:

    line 88

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

Wegent E2E Testing Guidelines

This document contains guidelines for writing and maintaining E2E tests for the Wegent project.


Rules

Rule 1: Use data-testid for Element Selection

When locating page elements, prefer using data-testid attributes.

  • ✅ DO use data-testid selectors when available
  • ✅ DO add data-testid to frontend components when creating new tests
  • ❌ DON'T rely solely on text content or CSS classes for element selection
  • ❌ DON'T use complex XPath or fragile selectors

Examples:

// ✅ CORRECT - Using data-testid
const createButton = page.locator('[data-testid="create-kb-card"]').first()
const submitButton = page.locator('[data-testid="submit-create-kb"]').first()

// ❌ AVOID - Using text content (prone to i18n issues)
const createButton = page.locator('button:has-text("Create")').first()

// ❌ AVOID - Using CSS classes (prone to styling changes)
const submitButton = page.locator('.btn-primary').first()

When to Add data-testid:

  • Interactive elements (buttons, inputs, links, selects)
  • Key UI components that need to be tested
  • Dynamic content containers
  • Modal dialogs and their triggers

Rule 2: Update Test Case Documentation

After generating new test cases, update the test case documentation file to describe:

  • What test cases exist
  • What functionality each test covers
  • The test file location

Documentation File: TEST_CASES.md

When updating:

  • Do a comprehensive check of all test files
  • If the documentation is missing descriptions for some test cases, add them
  • Keep the documentation organized by feature/module
  • Include setup requirements if applicable

Running Tests

# Run all tests
cd tests && sh run-tests.sh

# Run specific test file
TEST_BASE_URL=http://localhost:3000 sh run-tests.sh -t "Knowledge Flow"

# Run in headed mode (with browser UI)
sh run-tests.sh -h -t "Code Flow"

# Update authentication state
npx playwright codegen http://localhost:3000 --save-storage=.auth/user_localhost.json

Best Practices

  1. Use descriptive test names - Test names should clearly describe what is being tested
  2. Clean up test data - Use afterEach to clean up created resources
  3. Handle onboarding - Always skip onboarding tour in setup functions
  4. Wait for elements - Use appropriate timeouts and visibility checks
  5. Handle dynamic content - Use Promise.race or conditional checks for elements that may or may not appear
  6. Document data-testid requirements - When adding tests that require new data-testid attributes, document them in the PR description

Maintenance Checklist

When adding new tests:

  • Use data-testid for element selection (Rule 1)
  • Update TEST_CASES.md file with new test case descriptions (Rule 2)
  • Add setup function if the test requires complex preparation
  • Include cleanup logic in afterEach
  • Test locally before committing
  • Verify all existing tests still pass

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.