testdriverai 7.9.29-test → 7.9.31-test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -56,9 +56,10 @@ function buildAgentConfig({ sandboxId, apiRoot, apiKey, sentryDsn, sentryEnviron
|
|
|
56
56
|
* @param {string} opts.configJson - JSON.stringify'd agent config
|
|
57
57
|
* @param {string} opts.sandboxId - For logging
|
|
58
58
|
* @param {string} [opts.s3DownloadUrl] - S3 pre-signed URL for dev/test (omit for npm install)
|
|
59
|
+
* @param {string} [opts.imageVersion] - Version baked into the AMI (skip npm install when it matches)
|
|
59
60
|
* @returns {string[]} Array of PowerShell command strings
|
|
60
61
|
*/
|
|
61
|
-
function windowsProvisionCommands({ channel, configJson, sandboxId, s3DownloadUrl }) {
|
|
62
|
+
function windowsProvisionCommands({ channel, configJson, sandboxId, s3DownloadUrl, imageVersion }) {
|
|
62
63
|
var useS3 = (channel === 'dev' || channel === 'test') && s3DownloadUrl;
|
|
63
64
|
var commands = [];
|
|
64
65
|
|
|
@@ -94,11 +95,36 @@ function windowsProvisionCommands({ channel, configJson, sandboxId, s3DownloadUr
|
|
|
94
95
|
// Canary/stable (or dev/test without S3 URL): npm install by dist-tag
|
|
95
96
|
agentScript = 'node_modules/@testdriverai/runner/sandbox-agent.js';
|
|
96
97
|
var runnerTag = channel === 'stable' ? 'latest' : channel;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
|
|
99
|
+
// If we know the image version, check whether the baked-in runner already
|
|
100
|
+
// matches — skip npm install entirely when it does (saves 5-15s per launch).
|
|
101
|
+
// Emits a structured RUNNER_VERSION_CHECK line so SSM output / runner logs
|
|
102
|
+
// capture the outcome for monitoring.
|
|
103
|
+
if (imageVersion) {
|
|
104
|
+
commands.push(
|
|
105
|
+
"Write-Host 'Checking installed runner version...'",
|
|
106
|
+
"$installedVersion = ''",
|
|
107
|
+
"try { $pkg = Get-Content 'node_modules/@testdriverai/runner/package.json' -Raw | ConvertFrom-Json; $installedVersion = $pkg.version } catch {}",
|
|
108
|
+
"if ($installedVersion -eq '" + imageVersion + "') {",
|
|
109
|
+
" Write-Host 'Runner already at v" + imageVersion + ", skipping update'",
|
|
110
|
+
" Write-Host (\"RUNNER_VERSION_CHECK:\" + (ConvertTo-Json -Compress @{ action='skipped'; installedVersion=$installedVersion; expectedVersion='" + imageVersion + "'; channel='" + channel + "'; sandboxId='" + sandboxId + "' }))",
|
|
111
|
+
"} else {",
|
|
112
|
+
" Write-Host \"Installed: $installedVersion, expected: " + imageVersion + " — updating...\"",
|
|
113
|
+
" Write-Host 'Installing @testdriverai/runner@" + runnerTag + "...'",
|
|
114
|
+
' npm install @testdriverai/runner@' + runnerTag + ' --omit=dev 2>&1 | Write-Host',
|
|
115
|
+
" $newVersion = ''",
|
|
116
|
+
" try { $newPkg = Get-Content 'node_modules/@testdriverai/runner/package.json' -Raw | ConvertFrom-Json; $newVersion = $newPkg.version } catch {}",
|
|
117
|
+
" Write-Host (\"RUNNER_VERSION_CHECK:\" + (ConvertTo-Json -Compress @{ action='updated'; previousVersion=$installedVersion; expectedVersion='" + imageVersion + "'; newVersion=$newVersion; channel='" + channel + "'; sandboxId='" + sandboxId + "' }))",
|
|
118
|
+
" Write-Host 'Runner install complete'",
|
|
119
|
+
"}"
|
|
120
|
+
);
|
|
121
|
+
} else {
|
|
122
|
+
commands.push(
|
|
123
|
+
"Write-Host 'Installing @testdriverai/runner@" + runnerTag + "...'",
|
|
124
|
+
'npm install @testdriverai/runner@' + runnerTag + ' --omit=dev 2>&1 | Write-Host',
|
|
125
|
+
"Write-Host 'Runner install complete'"
|
|
126
|
+
);
|
|
127
|
+
}
|
|
102
128
|
}
|
|
103
129
|
|
|
104
130
|
// ── 3. Regenerate run_testdriver.ps1 ──────────────────────────────
|
|
@@ -140,16 +166,23 @@ function windowsProvisionCommands({ channel, configJson, sandboxId, s3DownloadUr
|
|
|
140
166
|
/**
|
|
141
167
|
* Generate the bash command to install/update the runner on Linux (E2B).
|
|
142
168
|
*
|
|
169
|
+
* When `imageVersion` is provided with the non-S3 (npm) path, the generated
|
|
170
|
+
* command checks the installed version first and skips the install when it
|
|
171
|
+
* matches — mirroring the Windows version-check behaviour.
|
|
172
|
+
*
|
|
143
173
|
* @param {Object} opts
|
|
144
|
-
* @param {string} opts.channel
|
|
145
|
-
* @param {string} [opts.s3DownloadUrl]
|
|
146
|
-
* @param {string} [opts.runnerPath]
|
|
174
|
+
* @param {string} opts.channel - Release channel
|
|
175
|
+
* @param {string} [opts.s3DownloadUrl] - S3 pre-signed URL for dev/test
|
|
176
|
+
* @param {string} [opts.runnerPath] - Default '/opt/testdriver-runner'
|
|
177
|
+
* @param {string} [opts.imageVersion] - Version baked into the E2B template (skip install when it matches)
|
|
178
|
+
* @param {string} [opts.sandboxId] - For structured logging
|
|
147
179
|
* @returns {string} Single bash command (steps joined with &&)
|
|
148
180
|
*/
|
|
149
|
-
function linuxRunnerInstallCommand({ channel, s3DownloadUrl, runnerPath }) {
|
|
181
|
+
function linuxRunnerInstallCommand({ channel, s3DownloadUrl, runnerPath, imageVersion, sandboxId }) {
|
|
150
182
|
var rp = runnerPath || '/opt/testdriver-runner';
|
|
151
183
|
var useS3 = (channel === 'dev' || channel === 'test') && s3DownloadUrl;
|
|
152
184
|
var runnerTag = channel === 'stable' ? 'latest' : channel;
|
|
185
|
+
var sid = sandboxId || 'unknown';
|
|
153
186
|
|
|
154
187
|
if (useS3) {
|
|
155
188
|
return [
|
|
@@ -164,6 +197,25 @@ function linuxRunnerInstallCommand({ channel, s3DownloadUrl, runnerPath }) {
|
|
|
164
197
|
].join(' && ');
|
|
165
198
|
}
|
|
166
199
|
|
|
200
|
+
// If we know the image version, wrap the install in a version check
|
|
201
|
+
if (imageVersion) {
|
|
202
|
+
return [
|
|
203
|
+
'INSTALLED_VERSION=$(node -p "try{require(\'' + rp + '/package.json\').version}catch(e){\'\'}" 2>/dev/null || echo "")',
|
|
204
|
+
'if [ "$INSTALLED_VERSION" = "' + imageVersion + '" ]; then',
|
|
205
|
+
' echo "RUNNER_VERSION_CHECK:{\\"action\\":\\"skipped\\",\\"installedVersion\\":\\"$INSTALLED_VERSION\\",\\"expectedVersion\\":\\"' + imageVersion + '\\",\\"channel\\":\\"' + channel + '\\",\\"sandboxId\\":\\"' + sid + '\\"}"',
|
|
206
|
+
' echo "Runner already at v' + imageVersion + ', skipping update"',
|
|
207
|
+
'else',
|
|
208
|
+
' echo "Installed: $INSTALLED_VERSION, expected: ' + imageVersion + ' — updating..."',
|
|
209
|
+
' sudo npm install -g @testdriverai/runner@' + runnerTag + ' --omit=dev --no-audit --no-fund --loglevel=error',
|
|
210
|
+
' sudo rm -rf ' + rp,
|
|
211
|
+
' sudo ln -sf $(npm root -g)/@testdriverai/runner ' + rp,
|
|
212
|
+
' NEW_VERSION=$(node -p "try{require(\'' + rp + '/package.json\').version}catch(e){\'\'}" 2>/dev/null || echo "")',
|
|
213
|
+
' echo "RUNNER_VERSION_CHECK:{\\"action\\":\\"updated\\",\\"previousVersion\\":\\"$INSTALLED_VERSION\\",\\"expectedVersion\\":\\"' + imageVersion + '\\",\\"newVersion\\":\\"$NEW_VERSION\\",\\"channel\\":\\"' + channel + '\\",\\"sandboxId\\":\\"' + sid + '\\"}"',
|
|
214
|
+
' echo "Runner install complete"',
|
|
215
|
+
'fi',
|
|
216
|
+
].join(' && ');
|
|
217
|
+
}
|
|
218
|
+
|
|
167
219
|
return [
|
|
168
220
|
'sudo npm install -g @testdriverai/runner@' + runnerTag + ' --omit=dev --no-audit --no-fund --loglevel=error',
|
|
169
221
|
'sudo rm -rf ' + rp,
|
package/package.json
CHANGED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TestDriver SDK - Web Logs Test (Vitest)
|
|
3
|
-
* Opens Notion, adds web logs via dashcam, then navigates to several URLs.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { describe, expect, it } from "vitest";
|
|
7
|
-
import { TestDriver } from "../lib/vitest/hooks.mjs";
|
|
8
|
-
import { getDefaults } from "./config.mjs";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Navigate Chrome to a new URL using Ctrl+L
|
|
12
|
-
* @param {import('../../sdk.js').default} client - TestDriver client instance
|
|
13
|
-
* @param {string} url - URL to navigate to
|
|
14
|
-
*/
|
|
15
|
-
async function navigateTo(client, url) {
|
|
16
|
-
await client.pressKeys(["ctrl", "l"]);
|
|
17
|
-
await client.type(url);
|
|
18
|
-
await client.pressKeys(["enter"]);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
describe("Web Logs Test", () => {
|
|
22
|
-
it("should open Notion, add web logs, and navigate to multiple URLs", async (context) => {
|
|
23
|
-
const testdriver = TestDriver(context, { ...getDefaults(context) });
|
|
24
|
-
|
|
25
|
-
// Add web logs for all domains
|
|
26
|
-
await testdriver.dashcam.addWebLog("http*://*github.com*");
|
|
27
|
-
|
|
28
|
-
// Launch Chrome to notion.so
|
|
29
|
-
await testdriver.provision.chrome({
|
|
30
|
-
url: "https://www.notion.so",
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// Navigate to GitHub
|
|
34
|
-
await navigateTo(testdriver, "https://github.com");
|
|
35
|
-
const githubLoaded = await testdriver.assert("the GitHub homepage is visible");
|
|
36
|
-
expect(githubLoaded).toBeTruthy();
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
});
|