Skip to content

Commit 9d9c475

Browse files
committed
updates for init
1 parent 9b8d1df commit 9d9c475

File tree

17 files changed

+492
-69
lines changed

17 files changed

+492
-69
lines changed

.github/workflows/test-init.yml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Test Init Command
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test-init:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout CLI repository
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
cache: 'npm'
23+
24+
- name: Install CLI dependencies
25+
run: npm ci
26+
27+
- name: Create test directory
28+
run: |
29+
mkdir -p /tmp/test-init-project
30+
cd /tmp/test-init-project
31+
32+
- name: Run init command (skip prompts)
33+
working-directory: /tmp/test-init-project
34+
run: |
35+
# Create .env with API key first to skip the prompt
36+
echo "TD_API_KEY=${{ secrets.TD_API_KEY }}" > .env
37+
38+
# Run init command using the CLI from the repo
39+
node ${{ github.workspace }}/bin/testdriverai.js init
40+
env:
41+
TD_API_KEY: ${{ secrets.TD_API_KEY }}
42+
43+
- name: Verify project structure
44+
working-directory: /tmp/test-init-project
45+
run: |
46+
echo "Checking generated files..."
47+
48+
# Check for package.json
49+
if [ ! -f "package.json" ]; then
50+
echo "❌ package.json not found"
51+
exit 1
52+
fi
53+
echo "✓ package.json exists"
54+
55+
# Check for vitest config
56+
if [ ! -f "vitest.config.js" ]; then
57+
echo "❌ vitest.config.js not found"
58+
exit 1
59+
fi
60+
echo "✓ vitest.config.js exists"
61+
62+
# Check for test file
63+
if [ ! -f "tests/example.test.js" ]; then
64+
echo "❌ tests/example.test.js not found"
65+
exit 1
66+
fi
67+
echo "✓ tests/example.test.js exists"
68+
69+
# Check for .env file
70+
if [ ! -f ".env" ]; then
71+
echo "❌ .env not found"
72+
exit 1
73+
fi
74+
echo "✓ .env exists"
75+
76+
# Check for .gitignore
77+
if [ ! -f ".gitignore" ]; then
78+
echo "❌ .gitignore not found"
79+
exit 1
80+
fi
81+
echo "✓ .gitignore exists"
82+
83+
# Check for GitHub workflow
84+
if [ ! -f ".github/workflows/testdriver.yml" ]; then
85+
echo "❌ .github/workflows/testdriver.yml not found"
86+
exit 1
87+
fi
88+
echo "✓ .github/workflows/testdriver.yml exists"
89+
90+
- name: Verify vitest config contents
91+
working-directory: /tmp/test-init-project
92+
run: |
93+
echo "Checking vitest.config.js contents..."
94+
95+
# Check for TestDriver reporter
96+
if ! grep -q "TestDriver()" vitest.config.js; then
97+
echo "❌ TestDriver reporter not found in vitest.config.js"
98+
cat vitest.config.js
99+
exit 1
100+
fi
101+
echo "✓ TestDriver reporter is configured"
102+
103+
# Check for setupFiles
104+
if ! grep -q "setupFiles.*testdriverai/vitest/setup" vitest.config.js; then
105+
echo "❌ setupFiles not configured correctly"
106+
cat vitest.config.js
107+
exit 1
108+
fi
109+
echo "✓ setupFiles is configured"
110+
111+
- name: Verify test file contents
112+
working-directory: /tmp/test-init-project
113+
run: |
114+
echo "Checking test file contents..."
115+
116+
# Check for .provision usage
117+
if ! grep -q "\.provision\.chrome" tests/example.test.js; then
118+
echo "❌ Test does not use .provision.chrome"
119+
cat tests/example.test.js
120+
exit 1
121+
fi
122+
echo "✓ Test uses .provision.chrome"
123+
124+
# Check for TestDriver import
125+
if ! grep -q "from 'testdriverai/vitest/hooks'" tests/example.test.js; then
126+
echo "❌ Test does not import from testdriverai/vitest/hooks"
127+
cat tests/example.test.js
128+
exit 1
129+
fi
130+
echo "✓ Test imports TestDriver from vitest/hooks"
131+
132+
- name: Run the generated test
133+
working-directory: /tmp/test-init-project
134+
run: npm test
135+
env:
136+
TD_API_KEY: ${{ secrets.TD_API_KEY }}
137+
138+
- name: Upload test results
139+
if: always()
140+
uses: actions/upload-artifact@v4
141+
with:
142+
name: test-init-results
143+
path: /tmp/test-init-project/test-results/
144+
retention-days: 7
145+
if-no-files-found: warn

agent/lib/commander.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ commands:
178178
emitter.emit(events.log.log, generator.jsonToManual(object));
179179
response = await commands["focus-application"](object.name);
180180
break;
181-
case "remember": {
181+
case "extract": {
182182
emitter.emit(events.log.log, generator.jsonToManual(object));
183-
let value = await commands["remember"](object.description);
183+
let value = await commands["extract"](object.description);
184184
emitter.emit(events.log.log, value);
185185
outputsInstance.set(object.output, value);
186186
break;

agent/lib/commands.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,11 +1276,11 @@ const createCommands = (
12761276
return "The application was focused.";
12771277
},
12781278
/**
1279-
* Extract and remember information from the screen using AI
1279+
* Extract information from the screen using AI
12801280
* @param {Object|string} options - Options object or description (for backward compatibility)
1281-
* @param {string} options.description - What to remember
1281+
* @param {string} options.description - What to extract
12821282
*/
1283-
"remember": async (...args) => {
1283+
"extract": async (...args) => {
12841284
const rememberStartTime = Date.now();
12851285
let description;
12861286

docs/v7/_drafts/migration.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,16 @@ await testdriver.focusApplication('Google Chrome');
207207
```
208208
</CodeGroup>
209209

210-
### Remember
210+
### Extract
211211

212212
<CodeGroup>
213213
```yaml YAML
214-
- command: remember
214+
- command: extract
215215
description: the order number
216216
```
217217
218218
```javascript SDK
219-
const orderNumber = await testdriver.remember('the order number');
219+
const orderNumber = await testdriver.extract('the order number');
220220
```
221221
</CodeGroup>
222222

docs/v7/api/act.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,4 @@ describe('E-commerce Flow with AI', () => {
202202

203203
- [`find()`](/v7/api/find) - Locate specific elements
204204
- [`assert()`](/v7/api/assert) - Make assertions
205-
- [`remember()`](/v7/api/remember) - Extract information
205+
- [`extract()`](/v7/api/extract) - Extract information

docs/v7/api/assert.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,6 @@ describe('Assertions', () => {
280280

281281
## Related Methods
282282

283-
- [`remember()`](/v7/api/remember) - Extract information for detailed assertions
283+
- [`extract()`](/v7/api/extract) - Extract information for detailed assertions
284284
- [`find()`](/v7/api/find) - Locate elements to verify
285285
- [`ai()`](/v7/api/ai) - Complex AI-driven tasks

docs/v7/api/assertions.mdx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ await waitForAssertion(testdriver, 'results are displayed', 10000);
7777

7878
## Extracting Information
7979

80-
### remember()
80+
### extract()
8181

82-
Extract and remember information from the screen using AI.
82+
Extract information from the screen using AI.
8383

8484
```javascript
85-
await testdriver.remember(description)
85+
await testdriver.extract(description)
8686
```
8787

8888
**Parameters:**
@@ -94,17 +94,17 @@ await testdriver.remember(description)
9494

9595
```javascript
9696
// Extract text from screen
97-
const password = await testdriver.remember('the password displayed on screen');
98-
const total = await testdriver.remember('the order total amount');
99-
const errorMessage = await testdriver.remember('the error message text');
97+
const password = await testdriver.extract('the password displayed on screen');
98+
const total = await testdriver.extract('the order total amount');
99+
const errorMessage = await testdriver.extract('the error message text');
100100

101101
// Extract structured data
102-
const email = await testdriver.remember('the email address in the confirmation');
103-
const orderId = await testdriver.remember('the order ID number');
104-
const phoneNumber = await testdriver.remember('the phone number');
102+
const email = await testdriver.extract('the email address in the confirmation');
103+
const orderId = await testdriver.extract('the order ID number');
104+
const phoneNumber = await testdriver.extract('the phone number');
105105

106106
// Use extracted data
107-
const password = await testdriver.remember('the password for standard_user');
107+
const password = await testdriver.extract('the password for standard_user');
108108
const passwordField = await testdriver.find('password input');
109109
await passwordField.click();
110110
await testdriver.type(password);
@@ -114,8 +114,8 @@ await testdriver.type(password);
114114

115115
**Dynamic Content:**
116116
```javascript
117-
// Remember generated values
118-
const confirmationCode = await testdriver.remember('the 6-digit confirmation code');
117+
// Extract generated values
118+
const confirmationCode = await testdriver.extract('the 6-digit confirmation code');
119119
console.log('Code:', confirmationCode);
120120

121121
// Use it later in the test
@@ -125,7 +125,7 @@ await testdriver.type(confirmationCode);
125125
**Verification:**
126126
```javascript
127127
// Extract and verify
128-
const displayedTotal = await testdriver.remember('the cart total');
128+
const displayedTotal = await testdriver.extract('the cart total');
129129
const expectedTotal = '$99.99';
130130

131131
expect(displayedTotal).toBe(expectedTotal);
@@ -134,7 +134,7 @@ expect(displayedTotal).toBe(expectedTotal);
134134
**Conditional Logic:**
135135
```javascript
136136
// Extract state and make decisions
137-
const status = await testdriver.remember('the order status');
137+
const status = await testdriver.extract('the order status');
138138

139139
if (status.includes('Pending')) {
140140
// Wait for processing

docs/v7/overview/readme.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ v7/
7575
- Basic assertions
7676
- Negative assertions (invert parameter)
7777
- Async assertions
78-
- `remember()` - Extract information from screen
78+
- `extract()` - Extract information from screen
7979
- Testing patterns:
8080
- Polling assertions
8181
- Multi-step validation

0 commit comments

Comments
 (0)