testdriverai 7.2.55 → 7.2.56
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.
|
@@ -14,9 +14,7 @@ import { TestDriver } from "../lib/vitest/hooks.mjs";
|
|
|
14
14
|
async function performLogin(client, username = "standard_user") {
|
|
15
15
|
await client.focusApplication("Google Chrome");
|
|
16
16
|
const password = await client.extract("the password");
|
|
17
|
-
const usernameField = await client.find(
|
|
18
|
-
"username input",
|
|
19
|
-
);
|
|
17
|
+
const usernameField = await client.find("username input");
|
|
20
18
|
await usernameField.click();
|
|
21
19
|
await client.type(username);
|
|
22
20
|
await client.pressKeys(["tab"]);
|
|
@@ -27,8 +25,13 @@ async function performLogin(client, username = "standard_user") {
|
|
|
27
25
|
|
|
28
26
|
describe("Hover Text With Description Test", () => {
|
|
29
27
|
it("should add TestDriver Hat to cart and verify", async (context) => {
|
|
30
|
-
const testdriver = TestDriver(context, {
|
|
31
|
-
|
|
28
|
+
const testdriver = TestDriver(context, {
|
|
29
|
+
ip: context.ip || process.env.TD_IP,
|
|
30
|
+
headless: true,
|
|
31
|
+
});
|
|
32
|
+
await testdriver.provision.chrome({
|
|
33
|
+
url: "http://testdriver-sandbox.vercel.app/login",
|
|
34
|
+
});
|
|
32
35
|
|
|
33
36
|
//
|
|
34
37
|
// Perform login first
|
|
@@ -47,7 +50,7 @@ describe("Hover Text With Description Test", () => {
|
|
|
47
50
|
await cartButton.click();
|
|
48
51
|
|
|
49
52
|
// Assert the TestDriver Hat is in the cart
|
|
50
|
-
const result = await testdriver.assert("
|
|
53
|
+
const result = await testdriver.assert("There is an item in the cart");
|
|
51
54
|
expect(result).toBeTruthy();
|
|
52
55
|
});
|
|
53
56
|
});
|
|
@@ -37,16 +37,22 @@ class InitCommand extends BaseCommand {
|
|
|
37
37
|
if (fs.existsSync(envPath)) {
|
|
38
38
|
const envContent = fs.readFileSync(envPath, "utf8");
|
|
39
39
|
if (envContent.includes("TD_API_KEY=")) {
|
|
40
|
-
console.log(
|
|
40
|
+
console.log(
|
|
41
|
+
chalk.gray("\n API key already configured in .env, skipping...\n"),
|
|
42
|
+
);
|
|
41
43
|
return;
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
console.log(chalk.cyan(" Setting up your TestDriver API key...\n"));
|
|
46
|
-
console.log(
|
|
48
|
+
console.log(
|
|
49
|
+
chalk.gray(" Get your API key from: https://console.testdriver.ai/team"),
|
|
50
|
+
);
|
|
47
51
|
|
|
48
52
|
// Ask if user wants to open the browser
|
|
49
|
-
const shouldOpen = await this.askYesNo(
|
|
53
|
+
const shouldOpen = await this.askYesNo(
|
|
54
|
+
" Open API keys page in browser? (Y/n): ",
|
|
55
|
+
);
|
|
50
56
|
if (shouldOpen) {
|
|
51
57
|
try {
|
|
52
58
|
// Dynamic import for ES module
|
|
@@ -54,12 +60,16 @@ class InitCommand extends BaseCommand {
|
|
|
54
60
|
await open("https://console.testdriver.ai/team");
|
|
55
61
|
console.log(chalk.gray(" Opening browser...\n"));
|
|
56
62
|
} catch (error) {
|
|
57
|
-
console.log(
|
|
63
|
+
console.log(
|
|
64
|
+
chalk.yellow(" ⚠️ Could not open browser automatically\n"),
|
|
65
|
+
);
|
|
58
66
|
}
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
// Prompt for API key with hidden input
|
|
62
|
-
const apiKey = await this.promptHidden(
|
|
70
|
+
const apiKey = await this.promptHidden(
|
|
71
|
+
" Enter your API key (input will be hidden): ",
|
|
72
|
+
);
|
|
63
73
|
|
|
64
74
|
if (apiKey && apiKey.trim()) {
|
|
65
75
|
// Save to .env
|
|
@@ -70,7 +80,11 @@ class InitCommand extends BaseCommand {
|
|
|
70
80
|
fs.writeFileSync(envPath, envContent + `TD_API_KEY=${apiKey.trim()}\n`);
|
|
71
81
|
console.log(chalk.green("\n ✓ API key saved to .env\n"));
|
|
72
82
|
} else {
|
|
73
|
-
console.log(
|
|
83
|
+
console.log(
|
|
84
|
+
chalk.yellow(
|
|
85
|
+
"\n ⚠️ No API key entered. You can add it later to .env:\n",
|
|
86
|
+
),
|
|
87
|
+
);
|
|
74
88
|
console.log(chalk.gray(" TD_API_KEY=your_api_key\n"));
|
|
75
89
|
}
|
|
76
90
|
}
|
|
@@ -81,7 +95,7 @@ class InitCommand extends BaseCommand {
|
|
|
81
95
|
async promptHidden(question) {
|
|
82
96
|
return new Promise((resolve) => {
|
|
83
97
|
process.stdout.write(question);
|
|
84
|
-
|
|
98
|
+
|
|
85
99
|
const stdin = process.stdin;
|
|
86
100
|
const wasRaw = stdin.isRaw;
|
|
87
101
|
stdin.setRawMode(true);
|
|
@@ -131,7 +145,9 @@ class InitCommand extends BaseCommand {
|
|
|
131
145
|
rl.question(question, (answer) => {
|
|
132
146
|
rl.close();
|
|
133
147
|
const normalized = answer.toLowerCase().trim();
|
|
134
|
-
resolve(
|
|
148
|
+
resolve(
|
|
149
|
+
normalized === "" || normalized === "y" || normalized === "yes",
|
|
150
|
+
);
|
|
135
151
|
});
|
|
136
152
|
});
|
|
137
153
|
}
|
|
@@ -153,17 +169,20 @@ class InitCommand extends BaseCommand {
|
|
|
153
169
|
scripts: {
|
|
154
170
|
test: "vitest run",
|
|
155
171
|
"test:watch": "vitest",
|
|
156
|
-
"test:ui": "vitest --ui"
|
|
172
|
+
"test:ui": "vitest --ui",
|
|
157
173
|
},
|
|
158
174
|
keywords: ["testdriver", "testing", "e2e"],
|
|
159
175
|
author: "",
|
|
160
176
|
license: "ISC",
|
|
161
177
|
engines: {
|
|
162
|
-
node: ">=20.19.0"
|
|
163
|
-
}
|
|
178
|
+
node: ">=20.19.0",
|
|
179
|
+
},
|
|
164
180
|
};
|
|
165
181
|
|
|
166
|
-
fs.writeFileSync(
|
|
182
|
+
fs.writeFileSync(
|
|
183
|
+
packageJsonPath,
|
|
184
|
+
JSON.stringify(packageJson, null, 2) + "\n",
|
|
185
|
+
);
|
|
167
186
|
console.log(chalk.green(` Created package.json`));
|
|
168
187
|
} else {
|
|
169
188
|
console.log(chalk.gray(" package.json already exists, skipping..."));
|
|
@@ -249,7 +268,7 @@ test('should login and add item to cart', async (context) => {
|
|
|
249
268
|
await cartButton.click();
|
|
250
269
|
|
|
251
270
|
// Verify item in cart
|
|
252
|
-
const result = await testdriver.assert('
|
|
271
|
+
const result = await testdriver.assert('There is an item in the cart');
|
|
253
272
|
expect(result).toBeTruthy();
|
|
254
273
|
|
|
255
274
|
});
|
|
@@ -283,7 +302,6 @@ export default defineConfig({
|
|
|
283
302
|
fs.writeFileSync(configFile, configContent);
|
|
284
303
|
console.log(chalk.green(` Created config file: ${configFile}`));
|
|
285
304
|
}
|
|
286
|
-
|
|
287
305
|
}
|
|
288
306
|
|
|
289
307
|
/**
|
|
@@ -387,10 +405,13 @@ jobs:
|
|
|
387
405
|
console.log(chalk.cyan("\n Installing dependencies...\n"));
|
|
388
406
|
|
|
389
407
|
try {
|
|
390
|
-
execSync(
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
408
|
+
execSync(
|
|
409
|
+
"npm install -D vitest testdriverai@beta && npm install dotenv",
|
|
410
|
+
{
|
|
411
|
+
cwd: process.cwd(),
|
|
412
|
+
stdio: "inherit",
|
|
413
|
+
},
|
|
414
|
+
);
|
|
394
415
|
console.log(chalk.green("\n Dependencies installed successfully!"));
|
|
395
416
|
} catch (error) {
|
|
396
417
|
console.log(
|
|
@@ -410,10 +431,16 @@ jobs:
|
|
|
410
431
|
console.log(chalk.cyan("Next steps:\n"));
|
|
411
432
|
console.log(" 1. Run your tests:");
|
|
412
433
|
console.log(chalk.gray(" npx vitest run\n"));
|
|
413
|
-
console.log(" 2. For CI/CD, add TD_API_KEY to your GitHub repository secrets");
|
|
414
|
-
console.log(chalk.gray(" Settings → Secrets → Actions → New repository secret\n"));
|
|
415
434
|
console.log(
|
|
416
|
-
|
|
435
|
+
" 2. For CI/CD, add TD_API_KEY to your GitHub repository secrets",
|
|
436
|
+
);
|
|
437
|
+
console.log(
|
|
438
|
+
chalk.gray(" Settings → Secrets → Actions → New repository secret\n"),
|
|
439
|
+
);
|
|
440
|
+
console.log(
|
|
441
|
+
chalk.cyan(
|
|
442
|
+
"Learn more at https://docs.testdriver.ai/v7/getting-started/\n",
|
|
443
|
+
),
|
|
417
444
|
);
|
|
418
445
|
}
|
|
419
446
|
}
|