agentq-webdriverio 1.0.1 → 1.0.2

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/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export declare const test: (title: string, fn: any) => any;
2
+ export { test as it };
1
3
  export declare function q(userPrompt: string): Promise<void>;
2
4
  export declare function initAgentQ(browser: WebdriverIO.Browser): void;
3
- export declare function handleTestConclusion(testTitle: string, status: 'passed' | 'failed', startTime: number, errorDetails?: string): Promise<void>;
5
+ export { uploadArtifact } from './testResult';
6
+ export declare function handleTestConclusion(testTitle: string, status: 'passed' | 'failed', startTime: number, errorDetails?: string): Promise<any>;
package/dist/index.js CHANGED
@@ -1,14 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uploadArtifact = exports.it = exports.test = void 0;
3
4
  exports.q = q;
4
5
  exports.initAgentQ = initAgentQ;
5
6
  exports.handleTestConclusion = handleTestConclusion;
6
- process.env.DOTENV_CONFIG_QUIET = 'true';
7
7
  const wsClient_1 = require("./wsClient");
8
8
  const pageContext_1 = require("./pageContext");
9
9
  require('dotenv').config({ quiet: true });
10
10
  const testResult_1 = require("./testResult");
11
11
  const testResult_2 = require("./testResult");
12
+ const test = (title, fn) => {
13
+ // @ts-ignore
14
+ return it(title, fn);
15
+ };
16
+ exports.test = test;
17
+ exports.it = exports.test;
12
18
  const stripAnsi = (str) => str.replace(/\x1B\[[0-?]*[ -/]*[@-~]/g, '');
13
19
  async function q(userPrompt) {
14
20
  const browser = pageContext_1.PageContext.getInstance().getBrowser();
@@ -18,6 +24,8 @@ function initAgentQ(browser) {
18
24
  pageContext_1.PageContext.getInstance().setBrowser(browser);
19
25
  }
20
26
  let cachedAccessToken = null;
27
+ var testResult_3 = require("./testResult");
28
+ Object.defineProperty(exports, "uploadArtifact", { enumerable: true, get: function () { return testResult_3.uploadArtifact; } });
21
29
  async function handleTestConclusion(testTitle, status, startTime, errorDetails) {
22
30
  const tcId = parseInt(testTitle.split('-')[0]);
23
31
  if (!isNaN(tcId) && process.env.AGENTQ_TESTRUN_ID) {
@@ -26,13 +34,13 @@ async function handleTestConclusion(testTitle, status, startTime, errorDetails)
26
34
  }
27
35
  const executionTime = (Date.now() - startTime) / 1000;
28
36
  const isPassed = status === 'passed';
29
- await (0, testResult_1.exportTestResult)(tcId.toString(), process.env.AGENTQ_TESTRUN_ID, {
37
+ return await (0, testResult_1.exportTestResult)(tcId.toString(), process.env.AGENTQ_TESTRUN_ID, {
30
38
  status: status,
31
39
  actualResult: isPassed ? `Test "${testTitle}" passed successfully`
32
40
  : `Test failed`,
33
41
  executionTime,
34
42
  notes: isPassed ? 'Test completed without errors' : stripAnsi(errorDetails || 'Test failed')
35
43
  });
36
- // Note: Artifact upload (screenshots/videos) would need to be handled via WebdriverIO attachments if available
37
44
  }
45
+ return null;
38
46
  }
@@ -28,7 +28,7 @@ async function getAccessToken() {
28
28
  return cachedToken;
29
29
  }
30
30
  try {
31
- console.log(`Authenticating with: ${config.apiBaseUrl}${config.authEndpoint}`);
31
+ // console.log(`Authenticating with: ${config.apiBaseUrl}${config.authEndpoint}`);
32
32
  const response = await axios_1.default.post(`${config.apiBaseUrl}${config.authEndpoint}`, config.authData, {
33
33
  headers: {
34
34
  'accept': 'application/json',
@@ -57,7 +57,7 @@ async function exportTestResult(tcId, testRunId, result) {
57
57
  const accessToken = await getAccessToken();
58
58
  const apiUrl = `${config.apiBaseUrl}/projects/${config.projectId}/test-runs/${testRunId}/test-results/tcId/${tcId}`;
59
59
  try {
60
- console.log(`Pushing test result to: ${apiUrl}`);
60
+ // console.log(`Pushing test result to: ${apiUrl}`);
61
61
  const response = await axios_1.default.patch(apiUrl, result, {
62
62
  headers: {
63
63
  'accept': 'application/json',
@@ -65,7 +65,7 @@ async function exportTestResult(tcId, testRunId, result) {
65
65
  'Content-Type': 'application/json'
66
66
  }
67
67
  });
68
- console.log('✅ Test result pushed successfully');
68
+ console.log(`[AgentQ] ✅ Test result pushed: tcId=${tcId}`);
69
69
  return response.data;
70
70
  }
71
71
  catch (error) {
@@ -97,14 +97,14 @@ async function uploadArtifact(testRunId, testResultId, type, filePath) {
97
97
  const mimetype = type === 'screenshot' ? 'image/png' : 'video/webm';
98
98
  const blob = new Blob([fileBuffer], { type: mimetype });
99
99
  formData.append('file', blob, fileName);
100
- console.log(`Uploading ${type} to: ${apiUrl}`);
100
+ // console.log(`Uploading ${type} to: ${apiUrl}`);
101
101
  const response = await axios_1.default.post(apiUrl, formData, {
102
102
  headers: {
103
103
  'Authorization': `Bearer ${accessToken}`,
104
104
  'Content-Type': 'multipart/form-data'
105
105
  }
106
106
  });
107
- console.log(`✅ ${type} uploaded successfully`);
107
+ console.log(`[AgentQ] ${type} uploaded for result ${testResultId}: ${JSON.stringify(response.data)}`);
108
108
  return response.data;
109
109
  }
110
110
  catch (error) {
package/dist/wsClient.js CHANGED
@@ -27,7 +27,14 @@ class WSClient {
27
27
  connect() {
28
28
  if (this.ws)
29
29
  return;
30
- this.ws = new ws_1.default((0, config_1.getServiceUrl)());
30
+ let url = (0, config_1.getServiceUrl)();
31
+ if (url.startsWith('http://')) {
32
+ url = url.replace('http://', 'ws://');
33
+ }
34
+ else if (url.startsWith('https://')) {
35
+ url = url.replace('https://', 'wss://');
36
+ }
37
+ this.ws = new ws_1.default(url);
31
38
  this.setupWebSocket();
32
39
  }
33
40
  setupWebSocket() {
package/package.json CHANGED
@@ -1,8 +1,15 @@
1
1
  {
2
2
  "name": "agentq-webdriverio",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.js"
11
+ }
12
+ },
6
13
  "bin": {
7
14
  "agentq-pull-testcase": "./dist/pull-testcase.js",
8
15
  "agentq-pull-testsuite": "./dist/pull-testcase.js"
@@ -41,4 +48,4 @@
41
48
  "@wdio/globals": "^9.0.0",
42
49
  "typescript": "^5.4.5"
43
50
  }
44
- }
51
+ }