@desplega.ai/qa-use 2.2.2 → 2.2.4
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.
- package/dist/lib/api/browser-types.d.ts +62 -3
- package/dist/lib/api/browser-types.d.ts.map +1 -1
- package/dist/lib/api/browser.d.ts +23 -2
- package/dist/lib/api/browser.d.ts.map +1 -1
- package/dist/lib/api/browser.js +68 -0
- package/dist/lib/api/browser.js.map +1 -1
- package/dist/lib/browser/index.d.ts +10 -0
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +29 -0
- package/dist/lib/browser/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/cli/commands/browser/create.d.ts.map +1 -1
- package/dist/src/cli/commands/browser/create.js +3 -0
- package/dist/src/cli/commands/browser/create.js.map +1 -1
- package/dist/src/cli/commands/browser/generate-test.d.ts +6 -0
- package/dist/src/cli/commands/browser/generate-test.d.ts.map +1 -0
- package/dist/src/cli/commands/browser/generate-test.js +46 -0
- package/dist/src/cli/commands/browser/generate-test.js.map +1 -0
- package/dist/src/cli/commands/browser/index.d.ts.map +1 -1
- package/dist/src/cli/commands/browser/index.js +4 -0
- package/dist/src/cli/commands/browser/index.js.map +1 -1
- package/dist/src/cli/commands/browser/logs.d.ts +6 -0
- package/dist/src/cli/commands/browser/logs.d.ts.map +1 -0
- package/dist/src/cli/commands/browser/logs.js +95 -0
- package/dist/src/cli/commands/browser/logs.js.map +1 -0
- package/dist/src/cli/commands/browser/run.d.ts.map +1 -1
- package/dist/src/cli/commands/browser/run.js +69 -1
- package/dist/src/cli/commands/browser/run.js.map +1 -1
- package/dist/src/cli/commands/browser/status.d.ts.map +1 -1
- package/dist/src/cli/commands/browser/status.js +23 -0
- package/dist/src/cli/commands/browser/status.js.map +1 -1
- package/dist/src/cli/commands/info.d.ts +1 -1
- package/dist/src/cli/commands/info.d.ts.map +1 -1
- package/dist/src/cli/commands/info.js +178 -15
- package/dist/src/cli/commands/info.js.map +1 -1
- package/dist/src/cli/commands/install-deps.d.ts +6 -0
- package/dist/src/cli/commands/install-deps.d.ts.map +1 -0
- package/dist/src/cli/commands/install-deps.js +52 -0
- package/dist/src/cli/commands/install-deps.js.map +1 -0
- package/dist/src/cli/commands/test/run.d.ts.map +1 -1
- package/dist/src/cli/commands/test/run.js +7 -13
- package/dist/src/cli/commands/test/run.js.map +1 -1
- package/dist/src/cli/index.js +2 -0
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/cli/lib/browser.d.ts +5 -0
- package/dist/src/cli/lib/browser.d.ts.map +1 -1
- package/dist/src/cli/lib/browser.js +19 -0
- package/dist/src/cli/lib/browser.js.map +1 -1
- package/dist/src/cli/lib/config.d.ts.map +1 -1
- package/dist/src/cli/lib/config.js +3 -0
- package/dist/src/cli/lib/config.js.map +1 -1
- package/lib/api/browser-types.ts +85 -0
- package/lib/api/browser.test.ts +163 -0
- package/lib/api/browser.ts +89 -0
- package/lib/browser/index.ts +37 -0
- package/package.json +1 -1
package/lib/api/browser.ts
CHANGED
|
@@ -14,6 +14,12 @@ import type {
|
|
|
14
14
|
BlocksResult,
|
|
15
15
|
CreateBrowserSessionOptions,
|
|
16
16
|
BrowserSessionStatus,
|
|
17
|
+
GenerateTestOptions,
|
|
18
|
+
GenerateTestResult,
|
|
19
|
+
ConsoleLogsOptions,
|
|
20
|
+
ConsoleLogsResult,
|
|
21
|
+
NetworkLogsOptions,
|
|
22
|
+
NetworkLogsResult,
|
|
17
23
|
} from './browser-types.js';
|
|
18
24
|
import type { ExtendedStep } from '../../src/types/test-definition.js';
|
|
19
25
|
|
|
@@ -67,6 +73,7 @@ export class BrowserApiClient {
|
|
|
67
73
|
viewport: options.viewport ?? 'desktop',
|
|
68
74
|
timeout: options.timeout ?? 300,
|
|
69
75
|
...(options.ws_url && { ws_url: options.ws_url }),
|
|
76
|
+
...(options.record_blocks !== undefined && { record_blocks: options.record_blocks }),
|
|
70
77
|
});
|
|
71
78
|
|
|
72
79
|
return response.data as BrowserSession;
|
|
@@ -219,6 +226,80 @@ export class BrowserApiClient {
|
|
|
219
226
|
}
|
|
220
227
|
}
|
|
221
228
|
|
|
229
|
+
// ==========================================
|
|
230
|
+
// Test Generation
|
|
231
|
+
// ==========================================
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Generate a test definition from recorded session blocks
|
|
235
|
+
* @param sessionId - The session ID
|
|
236
|
+
* @param options - Test generation options (name, app_config, variables)
|
|
237
|
+
* @returns Generated test YAML and metadata
|
|
238
|
+
*/
|
|
239
|
+
async generateTest(sessionId: string, options: GenerateTestOptions): Promise<GenerateTestResult> {
|
|
240
|
+
try {
|
|
241
|
+
const response = await this.client.post(`/sessions/${sessionId}/generate-test`, options);
|
|
242
|
+
return response.data as GenerateTestResult;
|
|
243
|
+
} catch (error) {
|
|
244
|
+
throw this.handleError(error, 'generate test');
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// ==========================================
|
|
249
|
+
// Logs
|
|
250
|
+
// ==========================================
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Get console logs from a session
|
|
254
|
+
* @param sessionId - The session ID
|
|
255
|
+
* @param options - Filter options (level, limit)
|
|
256
|
+
* @returns Console log entries
|
|
257
|
+
*/
|
|
258
|
+
async getConsoleLogs(
|
|
259
|
+
sessionId: string,
|
|
260
|
+
options: ConsoleLogsOptions = {}
|
|
261
|
+
): Promise<ConsoleLogsResult> {
|
|
262
|
+
try {
|
|
263
|
+
const params = new URLSearchParams();
|
|
264
|
+
if (options.level) params.append('level', options.level);
|
|
265
|
+
if (options.limit !== undefined) params.append('limit', options.limit.toString());
|
|
266
|
+
|
|
267
|
+
const queryString = params.toString();
|
|
268
|
+
const url = `/sessions/${sessionId}/logs/console${queryString ? `?${queryString}` : ''}`;
|
|
269
|
+
|
|
270
|
+
const response = await this.client.get(url);
|
|
271
|
+
return response.data as ConsoleLogsResult;
|
|
272
|
+
} catch (error) {
|
|
273
|
+
throw this.handleError(error, 'get console logs');
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Get network request logs from a session
|
|
279
|
+
* @param sessionId - The session ID
|
|
280
|
+
* @param options - Filter options (status, url_pattern, limit)
|
|
281
|
+
* @returns Network log entries
|
|
282
|
+
*/
|
|
283
|
+
async getNetworkLogs(
|
|
284
|
+
sessionId: string,
|
|
285
|
+
options: NetworkLogsOptions = {}
|
|
286
|
+
): Promise<NetworkLogsResult> {
|
|
287
|
+
try {
|
|
288
|
+
const params = new URLSearchParams();
|
|
289
|
+
if (options.status) params.append('status', options.status);
|
|
290
|
+
if (options.url_pattern) params.append('url_pattern', options.url_pattern);
|
|
291
|
+
if (options.limit !== undefined) params.append('limit', options.limit.toString());
|
|
292
|
+
|
|
293
|
+
const queryString = params.toString();
|
|
294
|
+
const url = `/sessions/${sessionId}/logs/network${queryString ? `?${queryString}` : ''}`;
|
|
295
|
+
|
|
296
|
+
const response = await this.client.get(url);
|
|
297
|
+
return response.data as NetworkLogsResult;
|
|
298
|
+
} catch (error) {
|
|
299
|
+
throw this.handleError(error, 'get network logs');
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
222
303
|
// ==========================================
|
|
223
304
|
// WebSocket Streaming
|
|
224
305
|
// ==========================================
|
|
@@ -276,4 +357,12 @@ export type {
|
|
|
276
357
|
UrlResult,
|
|
277
358
|
CreateBrowserSessionOptions,
|
|
278
359
|
BrowserSessionStatus,
|
|
360
|
+
GenerateTestOptions,
|
|
361
|
+
GenerateTestResult,
|
|
362
|
+
ConsoleLogsOptions,
|
|
363
|
+
ConsoleLogsResult,
|
|
364
|
+
ConsoleLogEntry,
|
|
365
|
+
NetworkLogsOptions,
|
|
366
|
+
NetworkLogsResult,
|
|
367
|
+
NetworkLogEntry,
|
|
279
368
|
} from './browser-types.js';
|
package/lib/browser/index.ts
CHANGED
|
@@ -2,9 +2,16 @@ import { chromium } from 'playwright';
|
|
|
2
2
|
import type { BrowserServer, Browser } from 'playwright';
|
|
3
3
|
import { fork } from 'child_process';
|
|
4
4
|
import path from 'path';
|
|
5
|
+
import fs from 'fs';
|
|
5
6
|
import { createRequire } from 'module';
|
|
6
7
|
import { fileURLToPath } from 'url';
|
|
7
8
|
|
|
9
|
+
export interface BrowserInstallationStatus {
|
|
10
|
+
installed: boolean;
|
|
11
|
+
executablePath: string | null;
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
export interface BrowserSession {
|
|
9
16
|
browserServer: BrowserServer;
|
|
10
17
|
wsEndpoint: string;
|
|
@@ -178,4 +185,34 @@ export class BrowserManager {
|
|
|
178
185
|
}
|
|
179
186
|
});
|
|
180
187
|
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Check if Playwright Chromium browser is installed without launching it.
|
|
191
|
+
* This is a fast, cheap check that verifies the executable file exists.
|
|
192
|
+
*/
|
|
193
|
+
checkBrowsersInstalled(): BrowserInstallationStatus {
|
|
194
|
+
try {
|
|
195
|
+
const executablePath = chromium.executablePath();
|
|
196
|
+
|
|
197
|
+
// Check if the executable file actually exists
|
|
198
|
+
if (fs.existsSync(executablePath)) {
|
|
199
|
+
return {
|
|
200
|
+
installed: true,
|
|
201
|
+
executablePath,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
installed: false,
|
|
207
|
+
executablePath: null,
|
|
208
|
+
error: `Chromium executable not found at expected path: ${executablePath}`,
|
|
209
|
+
};
|
|
210
|
+
} catch (error: any) {
|
|
211
|
+
return {
|
|
212
|
+
installed: false,
|
|
213
|
+
executablePath: null,
|
|
214
|
+
error: error.message,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
}
|
|
181
218
|
}
|