testdriverai 7.11.224-test → 7.11.225-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.
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+ // Prints the replay links for a blog demo run, as JSON.
3
+ //
4
+ // Usage (from sdk/, after running the demo):
5
+ // node blog-demos/replay-info.mjs test-tauri-app
6
+ //
7
+ // Reads the result files the TestDriver vitest plugin writes to
8
+ // .testdriver/results/blog-demos/<slug>.test.mjs/*.json and picks the newest passing one.
9
+ import fs from "node:fs";
10
+ import path from "node:path";
11
+
12
+ const slug = process.argv[2];
13
+ if (!slug) {
14
+ console.error("Usage: node blog-demos/replay-info.mjs <slug>");
15
+ process.exit(1);
16
+ }
17
+
18
+ const dir = path.join(process.cwd(), ".testdriver", "results", "blog-demos", `${slug}.test.mjs`);
19
+ if (!fs.existsSync(dir)) {
20
+ console.error(`No results found in ${dir}. Run the demo first.`);
21
+ process.exit(1);
22
+ }
23
+
24
+ const results = fs
25
+ .readdirSync(dir)
26
+ .filter((f) => f.endsWith(".json"))
27
+ .map((f) => {
28
+ const file = path.join(dir, f);
29
+ return { file, mtime: fs.statSync(file).mtimeMs, data: JSON.parse(fs.readFileSync(file, "utf-8")) };
30
+ })
31
+ .sort((a, b) => b.mtime - a.mtime);
32
+
33
+ const passed = results.find((r) => r.data.test?.passed === true) || null;
34
+ const pick = passed || results[0];
35
+ if (!pick) {
36
+ console.error(`No result files in ${dir}.`);
37
+ process.exit(1);
38
+ }
39
+
40
+ const d = pick.data;
41
+ console.log(
42
+ JSON.stringify(
43
+ {
44
+ passed: Boolean(passed),
45
+ error: d.test?.error || null,
46
+ replayUrl: d.replay?.url || d.replayUrl || null,
47
+ embedUrl: d.replay?.embedUrl || null,
48
+ gifUrl: d.replay?.gifUrl || null,
49
+ testRunUrl: d.urls?.testRun || d.testRunLink || null,
50
+ resultFile: pick.file,
51
+ },
52
+ null,
53
+ 2,
54
+ ),
55
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "7.11.224-test",
3
+ "version": "7.11.225-test",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "sdk.js",
6
6
  "types": "sdk.d.ts",
@@ -0,0 +1,41 @@
1
+ // Runs the blog demo tests in blog-demos/ only.
2
+ // They live outside examples/ so the CI jobs that run every example don't pick them up.
3
+ //
4
+ // Usage (from sdk/):
5
+ // TD_CHANNEL=stable npx vitest run --config vitest.blog.config.mjs --project stable blog-demos/<slug>.test.mjs
6
+ //
7
+ // API key: the base config always uses the test-account key from shared/fixtures.
8
+ // To run with a different key (e.g. a team key for public stable replays), set
9
+ // TD_BLOG_API_KEY in the environment or put `TD_BLOG_API_KEY=...` in ~/.testdriver/blog.env.
10
+ import fs from "node:fs";
11
+ import os from "node:os";
12
+ import path from "node:path";
13
+ import base from "./vitest.config.mjs";
14
+
15
+ function readBlogKey() {
16
+ if (process.env.TD_BLOG_API_KEY) return process.env.TD_BLOG_API_KEY;
17
+ const file = path.join(os.homedir(), ".testdriver", "blog.env");
18
+ if (!fs.existsSync(file)) return null;
19
+ const line = fs
20
+ .readFileSync(file, "utf-8")
21
+ .split("\n")
22
+ .find((l) => l.trim().startsWith("TD_BLOG_API_KEY="));
23
+ return line ? line.split("=").slice(1).join("=").trim().replace(/^["']|["']$/g, "") : null;
24
+ }
25
+
26
+ const blogKey = readBlogKey();
27
+ const withKey = (env) => (blogKey ? { ...env, TD_API_KEY: blogKey } : env);
28
+ if (blogKey) process.env.TD_API_KEY = blogKey;
29
+
30
+ export default {
31
+ ...base,
32
+ test: {
33
+ ...base.test,
34
+ include: ["blog-demos/**/*.test.mjs"],
35
+ env: withKey(base.test.env),
36
+ projects: base.test.projects.map((p) => ({
37
+ ...p,
38
+ test: { ...p.test, env: withKey(p.test.env) },
39
+ })),
40
+ },
41
+ };