@smartbear/one-report-publisher
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -81,6 +81,8 @@ "use strict"; | ||
var lstat = (0, util_1.promisify)(fs_1.default.lstat); | ||
var extensions = ['.xml', '.json']; | ||
var extensions = ['.xml', '.json', '.ndjson', '.zip']; | ||
var contentTypes = { | ||
'.xml': 'text/xml', | ||
'.json': 'application/json', | ||
'.ndjson': 'application/x-ndjson', | ||
'.zip': 'application/zip', | ||
}; | ||
@@ -87,0 +89,0 @@ /** |
@@ -98,6 +98,6 @@ "use strict"; | ||
it('publishes files from glob', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var organizationId, fakeEnv, responseBodies, expectedServerRequests, _a, _b, _c, _d, _e, sortedServerRequests, expectedResponseBodies; | ||
var _f, _g, _h, _j; | ||
return __generator(this, function (_k) { | ||
switch (_k.label) { | ||
var organizationId, fakeEnv, responseBodies, expectedServerRequests, _a, _b, _c, _d, _e, _f, _g, _h, _j, sortByContentType, sortedServerRequests, sortedExpectedServerRequests, expectedResponseBodies; | ||
var _k, _l, _m, _o, _p, _q, _r, _s; | ||
return __generator(this, function (_t) { | ||
switch (_t.label) { | ||
case 0: | ||
@@ -112,9 +112,9 @@ organizationId = '32C46057-0AB6-44E8-8944-0246E0BEA96F'; | ||
}; | ||
return [4 /*yield*/, (0, index_js_1.publish)(['test/fixtures/*.{xml,json}'], organizationId, "http://localhost:".concat(port), fakeEnv, function () { return Promise.resolve({}); })]; | ||
return [4 /*yield*/, (0, index_js_1.publish)(['test/fixtures/*.{xml,json,ndjson,zip}'], organizationId, "http://localhost:".concat(port), fakeEnv, function () { return Promise.resolve({}); })]; | ||
case 1: | ||
responseBodies = _k.sent(); | ||
_f = { | ||
responseBodies = _t.sent(); | ||
_k = { | ||
url: "/api/organization/".concat(organizationId, "/execution") | ||
}; | ||
_g = { | ||
_l = { | ||
'content-type': 'application/json' | ||
@@ -126,19 +126,19 @@ }; | ||
case 2: | ||
_f.headers = (_g[_a] = _b.apply(void 0, [(_k.sent()).size]), | ||
_g.connection = 'close', | ||
_g.host = "localhost:".concat(port), | ||
_g['onereport-sourcecontrol'] = 'https://github.com/SmartBear/one-report-publisher.git', | ||
_g['onereport-revision'] = 'f7d967d6d4f7adc1d6657bda88f4e976c879d74c', | ||
_g['onereport-branch'] = 'main', | ||
_g); | ||
_k.headers = (_l[_a] = _b.apply(void 0, [(_t.sent()).size]), | ||
_l.connection = 'close', | ||
_l.host = "localhost:".concat(port), | ||
_l['onereport-sourcecontrol'] = 'https://github.com/SmartBear/one-report-publisher.git', | ||
_l['onereport-revision'] = 'f7d967d6d4f7adc1d6657bda88f4e976c879d74c', | ||
_l['onereport-branch'] = 'main', | ||
_l); | ||
return [4 /*yield*/, readFile('test/fixtures/cucumber.json')]; | ||
case 3: | ||
_c = [ | ||
(_f.body = _k.sent(), | ||
_f) | ||
(_k.body = _t.sent(), | ||
_k) | ||
]; | ||
_h = { | ||
_m = { | ||
url: "/api/organization/".concat(organizationId, "/execution") | ||
}; | ||
_j = { | ||
_o = { | ||
'content-type': 'text/xml' | ||
@@ -150,19 +150,67 @@ }; | ||
case 4: | ||
_h.headers = (_j[_d] = _e.apply(void 0, [(_k.sent()).size]), | ||
_j.connection = 'close', | ||
_j.host = "localhost:".concat(port), | ||
_j['onereport-sourcecontrol'] = 'https://github.com/SmartBear/one-report-publisher.git', | ||
_j['onereport-revision'] = 'f7d967d6d4f7adc1d6657bda88f4e976c879d74c', | ||
_j['onereport-branch'] = 'main', | ||
_j); | ||
_m.headers = (_o[_d] = _e.apply(void 0, [(_t.sent()).size]), | ||
_o.connection = 'close', | ||
_o.host = "localhost:".concat(port), | ||
_o['onereport-sourcecontrol'] = 'https://github.com/SmartBear/one-report-publisher.git', | ||
_o['onereport-revision'] = 'f7d967d6d4f7adc1d6657bda88f4e976c879d74c', | ||
_o['onereport-branch'] = 'main', | ||
_o); | ||
return [4 /*yield*/, readFile('test/fixtures/junit.xml')]; | ||
case 5: | ||
_c = _c.concat([ | ||
(_m.body = _t.sent(), | ||
_m) | ||
]); | ||
_p = { | ||
url: "/api/organization/".concat(organizationId, "/execution") | ||
}; | ||
_q = { | ||
'content-type': 'application/x-ndjson' | ||
}; | ||
_f = 'content-length'; | ||
_g = String; | ||
return [4 /*yield*/, lstat('test/fixtures/cucumber.ndjson')]; | ||
case 6: | ||
_p.headers = (_q[_f] = _g.apply(void 0, [(_t.sent()).size]), | ||
_q.connection = 'close', | ||
_q.host = "localhost:".concat(port), | ||
_q['onereport-sourcecontrol'] = 'https://github.com/SmartBear/one-report-publisher.git', | ||
_q['onereport-revision'] = 'f7d967d6d4f7adc1d6657bda88f4e976c879d74c', | ||
_q['onereport-branch'] = 'main', | ||
_q); | ||
return [4 /*yield*/, readFile('test/fixtures/cucumber.ndjson')]; | ||
case 7: | ||
_c = _c.concat([ | ||
(_p.body = _t.sent(), | ||
_p) | ||
]); | ||
_r = { | ||
url: "/api/organization/".concat(organizationId, "/execution") | ||
}; | ||
_s = { | ||
'content-type': 'application/zip' | ||
}; | ||
_h = 'content-length'; | ||
_j = String; | ||
return [4 /*yield*/, lstat('test/fixtures/bundled.zip')]; | ||
case 8: | ||
_r.headers = (_s[_h] = _j.apply(void 0, [(_t.sent()).size]), | ||
_s.connection = 'close', | ||
_s.host = "localhost:".concat(port), | ||
_s['onereport-sourcecontrol'] = 'https://github.com/SmartBear/one-report-publisher.git', | ||
_s['onereport-revision'] = 'f7d967d6d4f7adc1d6657bda88f4e976c879d74c', | ||
_s['onereport-branch'] = 'main', | ||
_s); | ||
return [4 /*yield*/, readFile('test/fixtures/bundled.zip')]; | ||
case 9: | ||
expectedServerRequests = _c.concat([ | ||
(_h.body = _k.sent(), | ||
_h) | ||
(_r.body = _t.sent(), | ||
_r) | ||
]); | ||
sortedServerRequests = serverRequests[0].headers['content-type'] === 'application/json' | ||
? serverRequests | ||
: serverRequests.reverse(); | ||
assert_1.default.deepStrictEqual(sortedServerRequests, expectedServerRequests); | ||
sortByContentType = function (a, b) { | ||
return a.headers['content-type'].localeCompare(b.headers['content-type']); | ||
}; | ||
sortedServerRequests = serverRequests.sort(sortByContentType); | ||
sortedExpectedServerRequests = expectedServerRequests.sort(sortByContentType); | ||
assert_1.default.deepStrictEqual(sortedServerRequests, sortedExpectedServerRequests); | ||
expectedResponseBodies = [ | ||
@@ -175,2 +223,8 @@ { | ||
}, | ||
{ | ||
hello: 'world', | ||
}, | ||
{ | ||
hello: 'world', | ||
}, | ||
]; | ||
@@ -177,0 +231,0 @@ assert_1.default.deepStrictEqual(responseBodies, expectedResponseBodies); |
@@ -21,6 +21,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const lstat = promisify(fs.lstat); | ||
const extensions = ['.xml', '.json']; | ||
const extensions = ['.xml', '.json', '.ndjson', '.zip']; | ||
const contentTypes = { | ||
'.xml': 'text/xml', | ||
'.json': 'application/json', | ||
'.ndjson': 'application/x-ndjson', | ||
'.zip': 'application/zip', | ||
}; | ||
@@ -27,0 +29,0 @@ /** |
@@ -65,3 +65,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
const responseBodies = yield publish(['test/fixtures/*.{xml,json}'], organizationId, `http://localhost:${port}`, fakeEnv, () => Promise.resolve({})); | ||
const responseBodies = yield publish(['test/fixtures/*.{xml,json,ndjson,zip}'], organizationId, `http://localhost:${port}`, fakeEnv, () => Promise.resolve({})); | ||
const expectedServerRequests = [ | ||
@@ -94,8 +94,34 @@ { | ||
}, | ||
{ | ||
url: `/api/organization/${organizationId}/execution`, | ||
headers: { | ||
'content-type': 'application/x-ndjson', | ||
'content-length': String((yield lstat('test/fixtures/cucumber.ndjson')).size), | ||
connection: 'close', | ||
host: `localhost:${port}`, | ||
'onereport-sourcecontrol': 'https://github.com/SmartBear/one-report-publisher.git', | ||
'onereport-revision': 'f7d967d6d4f7adc1d6657bda88f4e976c879d74c', | ||
'onereport-branch': 'main', | ||
}, | ||
body: yield readFile('test/fixtures/cucumber.ndjson'), | ||
}, | ||
{ | ||
url: `/api/organization/${organizationId}/execution`, | ||
headers: { | ||
'content-type': 'application/zip', | ||
'content-length': String((yield lstat('test/fixtures/bundled.zip')).size), | ||
connection: 'close', | ||
host: `localhost:${port}`, | ||
'onereport-sourcecontrol': 'https://github.com/SmartBear/one-report-publisher.git', | ||
'onereport-revision': 'f7d967d6d4f7adc1d6657bda88f4e976c879d74c', | ||
'onereport-branch': 'main', | ||
}, | ||
body: yield readFile('test/fixtures/bundled.zip'), | ||
}, | ||
]; | ||
// Requests are sent in parallel, so we don't know what request hit the server first. | ||
const sortedServerRequests = serverRequests[0].headers['content-type'] === 'application/json' | ||
? serverRequests | ||
: serverRequests.reverse(); | ||
assert.deepStrictEqual(sortedServerRequests, expectedServerRequests); | ||
const sortByContentType = (a, b) => a.headers['content-type'].localeCompare(b.headers['content-type']); | ||
const sortedServerRequests = serverRequests.sort(sortByContentType); | ||
const sortedExpectedServerRequests = expectedServerRequests.sort(sortByContentType); | ||
assert.deepStrictEqual(sortedServerRequests, sortedExpectedServerRequests); | ||
const expectedResponseBodies = [ | ||
@@ -108,2 +134,8 @@ { | ||
}, | ||
{ | ||
hello: 'world', | ||
}, | ||
{ | ||
hello: 'world', | ||
}, | ||
]; | ||
@@ -110,0 +142,0 @@ assert.deepStrictEqual(responseBodies, expectedResponseBodies); |
{ | ||
"name": "@smartbear/one-report-publisher", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Publish Test Results to SmartBear OneReport", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
145903
1310