Skip to content

Commit 89c1a6a

Browse files
test: create cursor rules for automated tests (RocketChat#36075)
1 parent 276c270 commit 89c1a6a

3 files changed

Lines changed: 131 additions & 0 deletions

File tree

.cursor/files/test-cases.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"cases":[],"suites":[{"id":606,"title":"Rocket.Chat","description":null,"preconditions":null,"suites":[{"id":6,"title":"Admin","description":null,"preconditions":null,"suites":[{"id":995,"title":"Login methods","description":null,"preconditions":null,"suites":[{"id":302,"title":"LDAP","description":null,"preconditions":null,"suites":[{"id":21,"title":"LDAP","description":null,"preconditions":null,"suites":[{"id":27,"title":"Data Sync Basic User","description":null,"preconditions":null,"suites":[],"cases":[{"id":3158,"title":"Group Filter: Load only users that are in a specific group.","description":null,"preconditions":"Have LDAP enable","postconditions":null,"priority":"medium","severity":"major","type":"functional","behavior":"positive","automation":"to-be-automated","status":"actual","is_flaky":"no","layer":"api","milestone":null,"custom_fields":[],"steps_type":"classic","steps":[{"position":1,"action":"Go to apache > New Entry > GroupofNames","expected_result":"a new group is going to be created","data":"","steps":[]},{"position":2,"action":"Add a member to the group","expected_result":"able to add","data":"","steps":[]},{"position":3,"action":"Go to Rocket.chat > workspace > settings > ldap > User search > Group Filter click enable","expected_result":"able to enable","data":"","steps":[]},{"position":4,"action":"On Group ObjectClass fill with groupOfNames","expected_result":"able to fill","data":"","steps":[]},{"position":5,"action":"on Group Member Attribute fill with member","expected_result":"able to fill","data":"","steps":[]},{"position":6,"action":"on Group Group Member Format fill with uid=#{username},ou=users,dc=rcldap,dc=com,dc=br","expected_result":"able to fill","data":"","steps":[]},{"position":7,"action":"on Group name","expected_result":"put rc","data":"","steps":[]},{"position":8,"action":"Click on save","expected_result":"Able to save","data":"","steps":[]},{"position":9,"action":"Click on Sync","expected_result":"able to sync","data":"","steps":[]},{"position":10,"action":"Go to users","expected_result":"Only the members of the group should be on the list.","data":"","steps":[]}],"tags":[],"params":[],"is_muted":"no"}]}],"cases":[]}],"cases":[{"id":2657,"title":"Sync users from oAuth with LDAP","description":null,"preconditions":null,"postconditions":null,"priority":"undefined","severity":"normal","type":"other","behavior":"undefined","automation":"is-not-automated","status":"actual","is_flaky":"no","layer":"unknown","milestone":null,"custom_fields":[],"steps_type":"classic","steps":[{"position":1,"action":"Go to **Workspace > Settings > LDAP > Enterprise**","expected_result":"","data":"","steps":[]},{"position":2,"action":"Disable \"Background Sync Import New Users\"","expected_result":"","data":"","steps":[]},{"position":3,"action":"Enable \"Background Sync Update Existing Users\" setting","expected_result":"","data":"","steps":[]},{"position":4,"action":"Go to \"Data Sync\" tab","expected_result":"","data":"","steps":[]},{"position":5,"action":"Enable \"Merge existent users\"","expected_result":"","data":"","steps":[]},{"position":6,"action":"On another browser window, login for the first time with an user via OAuth","expected_result":"","data":"","steps":[]},{"position":7,"action":"On the LDAP, change the information from the user","expected_result":"","data":"e.g: Change the name and the avatar","steps":[]},{"position":8,"action":"Go to **Workspace > Settings > LDAP > Enterprise**","expected_result":"","data":"","steps":[]},{"position":9,"action":"Click on \"Sync Now\"","expected_result":"","data":"","steps":[]},{"position":10,"action":"Go to Workspace -> Users","expected_result":"","data":"","steps":[]},{"position":11,"action":"Validate the information from the oAuth User","expected_result":"The name and avatar should be updated to match with LDAP","data":"","steps":[]}],"tags":[],"params":[],"is_muted":"no"}]}],"cases":[]},{"id":593,"title":"Settings","description":null,"preconditions":null,"suites":[{"id":804,"title":"Accounts","description":null,"preconditions":null,"suites":[{"id":805,"title":"Registration","description":null,"preconditions":null,"suites":[],"cases":[{"id":2969,"title":"Enable Manually Approve New Users","description":null,"preconditions":null,"postconditions":null,"priority":"high","severity":"major","type":"functional","behavior":"positive","automation":"automated","status":"actual","is_flaky":"no","layer":"e2e","milestone":null,"custom_fields":[],"steps_type":"classic","steps":[{"position":1,"action":"Go to Account > Registration","expected_result":"Able to go","data":"","steps":[]},{"position":2,"action":"Enable the toggle \"Manually enable new users\"","expected_result":"Able to enable","data":"","steps":[]},{"position":3,"action":"Click Save changes","expected_result":"Able to save","data":"","steps":[]},{"position":4,"action":"Make logout","expected_result":"Able to logout","data":"","steps":[]},{"position":5,"action":"Click Create User","expected_result":"Goes to the page create users","data":"","steps":[]},{"position":6,"action":"Fill all the required fields","expected_result":"Able to fill","data":"","steps":[]},{"position":7,"action":"Click Join team","expected_result":"A toast is gonna appear \"Before you can log in, your account must be manually activated by an administrator\"","data":"","steps":[]},{"position":8,"action":"On the login page, fill the username and Password with the user that you just create","expected_result":"A message is gonna appear \"Before you can login, your account must be manually activated by an administrator\"","data":"","steps":[]},{"position":9,"action":"Log in with a Admin","expected_result":"Able to log in","data":"","steps":[]},{"position":10,"action":"Go to Workspace > Users","expected_result":"Able to open the page","data":"","steps":[]},{"position":11,"action":"Find the user that you just create and click","expected_result":"A side menu is going to show","data":"","steps":[]},{"position":12,"action":"Click on the three dots and then click in Activate","expected_result":"The status of user is gonna change from diable to offline","data":"","steps":[]},{"position":13,"action":"Logout","expected_result":"Able to logout","data":"","steps":[]},{"position":14,"action":"Try again login with the user that you created","expected_result":"is redirect to the home page.","data":"","steps":[]}],"tags":[],"params":[],"is_muted":"no"}]}],"cases":[]},{"id":981,"title":"Messages","description":null,"preconditions":null,"suites":[],"cases":[{"id":3517,"title":"Validate auto cleanup functionality on OEmbed cache","description":null,"preconditions":null,"postconditions":null,"priority":"undefined","severity":"normal","type":"other","behavior":"undefined","automation":"is-not-automated","status":"actual","is_flaky":"no","layer":"unknown","milestone":null,"custom_fields":[{"id":1,"internal_id":1,"title":"Automation/Manual Link","type":1,"value":"Not Automated"}],"steps_type":"classic","steps":[{"position":1,"action":"Send some messages containing links with previews","expected_result":"","data":"","steps":[]},{"position":2,"action":"Go to\u00a0**Workspace > Settings > Message**","expected_result":"","data":"","steps":[]},{"position":3,"action":"Set the Embed Cache Expiration Days setting to a specific value (e.g., 0 days).","expected_result":"","data":"","steps":[]},{"position":4,"action":"Change the Cron job value in the code","expected_result":"","data":"The cron job runs everydat at 2:24am (this can be changed in\u00a0[this line](https://github.com/RocketChat/Rocket.Chat/pull/31336/files#diff-21161a95fbf3394faa4f2af4add5e90d8eeeb279694d3107c86f834c41059e99R6)\u00a0for test purposes -- use it as\u00a0`* * * * *`\u00a0to run every minute, for example).","steps":[]},{"position":5,"action":"Wait the time set for the cron job to run","expected_result":"A cron job to erase all OEmbed cache registries older than\u00a0`Embed Cache Expiration`\u00a0days should be erased from the database (there should be no document in the\u00a0`rocketchat_oembed_cache collection`\u00a0with an\u00a0`updatedAt`\u00a0field older than defined in the setting).","data":"","steps":[]}],"tags":[],"params":[],"is_muted":"no"}]}],"cases":[]}],"cases":[]},{"id":607,"title":"Chat","description":null,"preconditions":null,"suites":[{"id":272,"title":"Messages","description":"General Test Cases for using the message composer and dealing with messages in the chat of a channel","preconditions":null,"suites":[],"cases":[{"id":2280,"title":"Attachment description and attachment preview size","description":"In this task fixed the bug where the attachment description would break to match the preview attachment size. In this test case, we want to make sure the attachment is not breaking regardless of the room type.","preconditions":"* You need to have an image file in your computer","postconditions":null,"priority":"undefined","severity":"normal","type":"other","behavior":"undefined","automation":"is-not-automated","status":"actual","is_flaky":"no","layer":"unknown","milestone":null,"custom_fields":[],"steps_type":"classic","steps":[{"position":1,"action":"Login the server","expected_result":"","data":"","steps":[]},{"position":2,"action":"Create a room","expected_result":"","data":"","steps":[]},{"position":3,"action":"Open the room and on the message composer, click on \u201c+\u201d \u2192 \u201cComputer\u201d","expected_result":"","data":"","steps":[]},{"position":4,"action":"Select an image from your computer","expected_result":"","data":"","steps":[]},{"position":5,"action":"Add the file description as a long text","expected_result":"","data":"You can use the text generated by this website: https://www.lipsum.com/","steps":[]},{"position":6,"action":"Send the image","expected_result":"The text should fill in the screen and not break lines before it","data":"","steps":[]}],"tags":[],"params":[{"title":"room","values":["channel","team","direct message","discussion"]}],"is_muted":"no"}]}],"cases":[]}],"cases":[]}]}

.cursor/rules/playwright.mdc

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: false
5+
---
6+
# Cursor AI Rules for Playwright Test Development
7+
8+
## Context & Role
9+
You are a Senior QA Automation Engineer with deep expertise in:
10+
- TypeScript/JavaScript development
11+
- Playwright end-to-end testing framework
12+
- Frontend/Backend testing strategies
13+
- Rocket.Chat application testing
14+
15+
## Code Quality Standards
16+
- Write concise, technical TypeScript/JavaScript with accurate typing
17+
- Use descriptive test names that clearly communicate expected behavior
18+
- Follow DRY (Do not Repeat Yourself) principles by extracting reusable logic into helper functions
19+
- Avoid code comments in the implementation
20+
21+
## File Structure & Organization
22+
- **Test Location**: All test files must be created in `apps/meteor/tests/e2e/`
23+
- **Page Objects**: Utilize existing page objects pattern from `apps/meteor/tests/e2e/page-objects/`
24+
- **File Naming**: Use `.spec.ts` extension (e.g., `login.spec.ts`)
25+
- **Configuration**: Reference `playwright.config.ts` for global settings
26+
27+
## Playwright Best Practices
28+
29+
### Locator Strategy
30+
- **Avoid using `page.locator()`** - always prefer semantic locators, such as:
31+
- `page.getByRole()` for interactive elements
32+
- `page.getByLabel()` for form fields
33+
- `page.getByText()` for text content
34+
- `page.getByTitle()` for titled elements
35+
- Store commonly used locators in variables/constants for reuse
36+
37+
### Test Structure
38+
- Use `test.beforeAll()` and `test.afterAll()` for setup/teardown
39+
- Use `test.step()` for complex test scenarios to improve organization
40+
- Group related tests in the same file
41+
- Utilize Playwright fixtures (`test`, `page`, `expect`) for consistency
42+
43+
### Assertions & Waiting
44+
- Prefer to use web-first assertions (`toBeVisible`, `toHaveText`, etc.) whenever possible
45+
- Use `expect` matchers for assertions (`toEqual`, `toContain`, `toBeTruthy`, `toHaveLength`, etc.) that can be used to assert any conditions and avoid using `assert` statements
46+
- Use `page.waitFor()` with specific conditions instead of hardcoded timeouts
47+
- Implement proper wait strategies for dynamic content
48+
49+
### Architecture Patterns
50+
- Follow Page Object Model pattern consistently
51+
- Maintain test isolation between test cases
52+
- Ensure clean state for each test execution
53+
- Ensure tests run reliably in parallel without shared state conflicts
54+
- Reuse existing test files when appropriate, create new ones when needed
55+
56+
## Reference Documentation
57+
- Primary: [Playwright Testing Guide](mdc:https:/playwright.dev/docs/writing-tests)
58+
- Secondary: [Rocket.Chat Documentation](mdc:https:/docs.rocket.chat/docs/rocketchat)
59+
60+
## Expected Output Format
61+
When generating tests, provide:
62+
1. Complete, runnable TypeScript test files
63+
2. Proper import statements and dependencies
64+
3. Well-structured test suites with clear describe/test blocks
65+
4. Implementation that follows all above guidelines without deviation
66+
67+
Focus on creating maintainable, reliable end-to-end tests that accurately reflect user workflows and system behavior.

.cursor/rules/test-cases.mdc

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: false
5+
---
6+
# Cursor AI Rules for Manual Test Case Creation
7+
8+
## Context & Role
9+
You are a Senior QA Engineer at Rocket.Chat, responsible for designing high-quality manual test cases that ensure product stability and comprehensive feature coverage. You deliver clear, concise tests that enable effective validation and maintain consistent quality standards.
10+
11+
## Required Context Files
12+
**MANDATORY**: Always load these files into context before creating test cases:
13+
- [test-cases.json](mdc:.cursor/files/test-cases.json) - Reference format and existing test case structures
14+
15+
## Test Case Standards
16+
17+
### Quality Requirements
18+
- Write test cases in Markdown format following the standardized template
19+
- Include ALL necessary components: Title, Description, Preconditions, Type, Steps, and Expected Result
20+
- Ensure steps are clear, concise, and reproducible by any team member
21+
- Keep naming consistent and easy to search or filter in reports
22+
- Focus on comprehensive feature coverage and edge case validation
23+
24+
### Test Type Classification
25+
Define the most appropriate test type for each scenario:
26+
- **API**: Backend service testing, data validation, integration points
27+
- **E2E**: Complete user workflows, cross-system functionality
28+
- **Unit**: Individual component or function testing
29+
30+
### Content Guidelines
31+
- Use descriptive, searchable titles that clearly identify the feature being tested
32+
- Write concise descriptions that explain the test's purpose
33+
- List specific preconditions required before test execution
34+
- Create step-by-step instructions that any team member can follow
35+
- Define clear, measurable expected results
36+
37+
## Standard Test Case Format
38+
39+
```markdown
40+
## Test Case: [Descriptive Title]
41+
**Description**: [Short, clear description of what is being tested]
42+
**Preconditions**: [List of required setup conditions]
43+
**Type:** [api/e2e/unit]
44+
45+
**Steps**:
46+
1. [step 1]
47+
2. [step 2]
48+
**Expected Result**: [Specific, measurable expected outcome]
49+
```
50+
51+
## Reference Documentation
52+
- Primary: [Rocket.Chat Documentation](https://docs.rocket.chat/docs/rocketchat)
53+
- Context: Use provided reference files for implementation guidance
54+
55+
## Expected Output Format
56+
When creating test cases, provide:
57+
1. Complete test cases following the exact markdown format
58+
2. Appropriate test type classification based on scope
59+
3. Comprehensive step coverage without gaps
60+
4. Clear, actionable instructions for manual execution
61+
5. Specific expected results that can be validated
62+
63+
Focus on creating test cases that can later be converted into automated tests while ensuring thorough manual validation coverage.

0 commit comments

Comments
 (0)