Skip to content

Commit aff707d

Browse files
committed
changes to test plan and test doc
1 parent 1184b0c commit aff707d

File tree

2 files changed

+140
-1
lines changed

2 files changed

+140
-1
lines changed

docs/TESTPLAN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The test suite has the following categories of tests:
4141
- E2E Tests: **slow** tests
4242
- Live in `src/testE2E`
4343
- These tests are heavier than Integration tests.
44-
- Some E2E tests have a more complicated architecture, described in [TEST_E2E](./TEST_E2E.md)
44+
- Some E2E tests have a more complicated architecture, described in [UI_E2E_Test](./UI_E2E_Test.md)
4545
- Performance Tests: **slow** tests
4646
- Live in `src/testInteg/perf`.
4747
- A subset of integration tests focused on catching performance regressions.

docs/UI_E2E_Test.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
## UI Testing
2+
3+
UI tests use [vscode-extension-tester](https://github.com/redhat-developer/vscode-extension-tester) to test the Amazon Q extension in a real VS Code environment.
4+
5+
### Quick Start
6+
7+
```bash
8+
# Run complete UI test suite
9+
npm run test:ui
10+
```
11+
12+
### Individual Commands
13+
14+
#### `test:ui:prepare`
15+
16+
Downloads VS Code and ChromeDriver to `~/.vscode-test-resources`
17+
18+
```bash
19+
npm run test:ui:prepare
20+
```
21+
22+
#### `test:ui:install`
23+
24+
Packages the Amazon Q extension and installs it for testing
25+
26+
```bash
27+
npm run test:ui:install
28+
```
29+
30+
- Runs `npm run package` in amazonq directory
31+
- Extracts version from build output
32+
- Installs VSIX using `extest install-vsix`
33+
- Sets up extension in test environment
34+
35+
#### `test:ui:run`
36+
37+
Compiles TypeScript and runs UI tests
38+
39+
```bash
40+
npm run test:ui:run
41+
```
42+
43+
- Compiles test files with `npm run testCompile`
44+
- Runs tests matching `packages/amazonq/dist/test/e2e_new/amazonq/tests/*.js`
45+
46+
### E2E New Test Suite
47+
48+
Modern UI testing framework located at `packages/amazonq/test/e2e_new/amazonq/`
49+
50+
#### Directory Structure
51+
52+
```
53+
packages/amazonq/test/e2e_new/amazonq/
54+
├── tests/ # Test files
55+
│ ├── chat.test.ts
56+
│ ├── pinContext.test.ts
57+
│ ├── quickActions.test.ts
58+
│ └── switchModel.test.ts
59+
├── helpers/ # Test helpers
60+
│ ├── pinContextHelper.ts
61+
│ ├── quickActionsHelper.ts
62+
│ └── switchModelHelper.ts
63+
├── utils/ # Testing utilities
64+
│ ├── authUtils.ts
65+
│ ├── cleanupUtils.ts
66+
│ ├── generalUtils.ts
67+
│ ├── setup.ts
68+
│ └── testContext.ts
69+
└── resources/ # Extension config
70+
└── extensions.json
71+
```
72+
73+
#### Test Categories
74+
75+
- **Chat** - Amazon Q chat functionality
76+
- **Pin Context** - Context pinning features
77+
- **Quick Actions** - Quick action commands
78+
- **Switch Model** - Model switching functionality
79+
80+
### Writing New Tests
81+
82+
1. Create test files in `packages/amazonq/test/e2e_new/amazonq/tests/`
83+
2. Import utilities from `../utils/`
84+
3. Use helpers from `../helpers/`
85+
4. Follow existing patterns for setup/cleanup
86+
87+
#### Example Test Structure
88+
89+
```typescript
90+
import { describe, it, before, after } from 'mocha'
91+
import { setupTestContext, cleanupTestContext } from '../utils/setup'
92+
93+
describe('Feature Tests', () => {
94+
before(async () => {
95+
await setupTestContext()
96+
})
97+
98+
after(async () => {
99+
await cleanupTestContext()
100+
})
101+
102+
it('should test functionality', async () => {
103+
// Test implementation
104+
})
105+
})
106+
```
107+
108+
### Prerequisites
109+
110+
- Node.js and npm
111+
- VS Code extension development environment
112+
- Chrome/Chromium browser
113+
114+
### Troubleshooting
115+
116+
#### Common Issues
117+
118+
- **VS Code download fails**: Check internet connection, retry `test:ui:prepare`
119+
- **Extension install fails**: Ensure packaging succeeds
120+
- **Tests won't start**: Verify ChromeDriver/Chrome compatibility
121+
- **Permission errors**: Check `~/.vscode-test-resources` permissions
122+
123+
#### Debug and Reset
124+
125+
```bash
126+
# Debug mode
127+
DEBUG=true npm run test:ui:run
128+
129+
# Reset test environment
130+
rm -rf ~/.vscode-test-resources
131+
npm run test:ui:prepare
132+
```
133+
134+
### Test Development Tips
135+
136+
- Tests should be independent and run in any order
137+
- Use existing utilities for common operations
138+
- Clean up resources in `after` hooks
139+
- Follow naming conventions from existing tests

0 commit comments

Comments
 (0)