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…
In this repository7 other files it gives its agents.
- AGENTS.mdAGENTS.md
- backend-rs/AGENTS.mdAGENTS.md
- frontend/AGENTS.mdAGENTS.md
- wework/AGENTS.mdAGENTS.md
- wework-mobile/AGENTS.mdAGENTS.md
- backend-rs/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
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
- Distinctive: line 50
Do a comprehensive check of all test files
- Distinctive: line 51
If the documentation is missing descriptions for some test cases, add them
- Distinctive: line 52
Keep the documentation organized by feature/module
- Distinctive: line 77
Use descriptive test names: - Test names should clearly describe what is being tested
- Very specific: line 78
Clean up test data: - Use afterEach to clean up created resources
- Distinctive: line 79
Handle onboarding: - Always skip onboarding tour in setup functions
- Distinctive: line 80
Wait for elements: - Use appropriate timeouts and visibility checks
- Very specific: line 81
Handle dynamic content: - Use Promise.race or conditional checks for elements that may or may not appear
- Distinctive: line 82
Document data-testid requirements: - When adding tests that require new data-testid attributes, document them in the PR description
- Distinctive: line 88
When adding new tests:
≈ “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.
Files
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-testidselectors when available - ✅ DO add
data-testidto 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.jsonBest Practices
- Use descriptive test names - Test names should clearly describe what is being tested
- Clean up test data - Use
afterEachto clean up created resources - Handle onboarding - Always skip onboarding tour in setup functions
- Wait for elements - Use appropriate timeouts and visibility checks
- Handle dynamic content - Use
Promise.raceor conditional checks for elements that may or may not appear - 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
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
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.

