wdio-test-ledger-service 9.2.7 → 9.2.9

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +27 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wdio-test-ledger-service",
3
- "version": "9.2.7",
3
+ "version": "9.2.9",
4
4
  "description": "WebdriverIO server to send reporter data to testledger.dev",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -119,14 +119,26 @@ class TestLedgerLauncher {
119
119
  fs.writeFileSync(`${this.options.reporterOutputDir}/trio-readfile-error.txt`, e.message, { encoding : `utf-8` });
120
120
  }
121
121
 
122
- const identifier = file.match(/wdio-(\d+-\d+)-/)[1];
122
+ const match = file.match(/wdio-(\d+-\d+)-/);
123
+ if(!match) {
124
+ continue;
125
+ }
126
+ const identifier = match[1];
123
127
 
124
128
  if(!tmp) {
125
129
  continue;
126
130
  }
127
131
 
128
- const content = JSON.parse(tmp);
129
- const suite_key = btoa(`${identifier}:${content.spec_file}:${content.capabilities}:${content.title}`);
132
+ let content;
133
+ try {
134
+ content = JSON.parse(tmp);
135
+ }
136
+ catch(e) {
137
+ fs.writeFileSync(`${this.options.reporterOutputDir}/trio-json-parse-error.txt`, `Failed to parse ${file}: ${e.message}`, { encoding : `utf-8` });
138
+ continue;
139
+ }
140
+
141
+ const suite_key = Buffer.from(`${identifier}:${content.spec_file}:${content.capabilities}:${content.title}`).toString('base64');
130
142
 
131
143
  if(content.passed && Number(process.env.SKIP_PASSED_UPLOADS) === 1) {
132
144
  continue;
@@ -148,7 +160,7 @@ class TestLedgerLauncher {
148
160
 
149
161
  for(const test of content.tests) {
150
162
  const hook = test.type === `hook`;
151
- const test_key = btoa(`${identifier}:${content.spec_file}:${content.capabilities}:${content.title}:${test.title}`);
163
+ const test_key = Buffer.from(`${identifier}:${content.spec_file}:${content.capabilities}:${content.title}:${test.title}`).toString('base64');
152
164
 
153
165
  if(!all_errors[test_key]) {
154
166
  all_errors[test_key] = [];
@@ -413,7 +425,11 @@ class TestLedgerLauncher {
413
425
  }))
414
426
  };
415
427
 
416
- const response = await fetch(`${this.getApiUrl()}/artifacts/presigned-upload`, {
428
+ const url = `${this.getApiUrl()}/artifacts/presigned-upload`;
429
+
430
+ fs.writeFileSync(`${this.options.reporterOutputDir}/trio-presigned-request.txt`, `URL: ${url}\nPayload: ${JSON.stringify(payload, null, 2)}`, { encoding: 'utf-8' });
431
+
432
+ const response = await fetch(url, {
417
433
  method : 'POST',
418
434
  headers : {
419
435
  'Content-Type' : 'application/json',
@@ -422,6 +438,12 @@ class TestLedgerLauncher {
422
438
  body : JSON.stringify(payload)
423
439
  });
424
440
 
441
+ if (!response.ok) {
442
+ const text = await response.text();
443
+ fs.writeFileSync(`${this.options.reporterOutputDir}/trio-presigned-failed.txt`, `Status: ${response.status} ${response.statusText}\nURL: ${url}\nResponse: ${text.substring(0, 2000)}`, { encoding: 'utf-8' });
444
+ throw new Error(`Presigned URL request failed: HTTP ${response.status}`);
445
+ }
446
+
425
447
  return response.json();
426
448
  }
427
449