Skip to content

Commit b74f11e

Browse files
committed
fix: Tests had a couple of issues runnning
1 parent 2973d67 commit b74f11e

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed

dcm4chee-docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: "3"
21
services:
32
ldap:
43
image: dcm4che/slapd-dcm4chee:2.4.44-13.3

src/api.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class DICOMwebClient {
223223
let requestInstance = request.instance ? request.instance : new XMLHttpRequest();
224224

225225
requestInstance.open(method, url, true);
226-
if ('responseType' in request) {
226+
if (request.responseType) {
227227
requestInstance.responseType = request.responseType;
228228
}
229229

@@ -297,10 +297,8 @@ class DICOMwebClient {
297297
};
298298

299299
// Event triggered while download progresses
300-
if ('progressCallback' in request) {
301-
if (typeof request.progressCallback === 'function') {
302-
requestInstance.onprogress = request.progressCallback;
303-
}
300+
if (typeof request.progressCallback === 'function') {
301+
requestInstance.onprogress = request.progressCallback;
304302
}
305303

306304
if (requestHooks && areValidRequestHooks(requestHooks)) {
@@ -313,13 +311,11 @@ class DICOMwebClient {
313311
}
314312

315313
// Add withCredentials to request if needed
316-
if ('withCredentials' in request) {
317-
if (request.withCredentials) {
318-
requestInstance.withCredentials = true;
319-
}
314+
if (request.withCredentials) {
315+
requestInstance.withCredentials = true;
320316
}
321317

322-
if ('data' in request) {
318+
if (request.data) {
323319
requestInstance.send(request.data);
324320
} else {
325321
requestInstance.send();
@@ -596,6 +592,7 @@ class DICOMwebClient {
596592
'image/gif',
597593
'image/png',
598594
'image/jp2',
595+
'image/*',
599596
];
600597
} else {
601598
supportedMediaTypes = {
@@ -610,6 +607,7 @@ class DICOMwebClient {
610607
'1.2.840.10008.1.2.4.91': ['image/jp2'],
611608
'1.2.840.10008.1.2.4.92': ['image/jpx'],
612609
'1.2.840.10008.1.2.4.93': ['image/jpx'],
610+
'*': ['image/*'],
613611
};
614612

615613
if (byteRange) {
@@ -963,7 +961,7 @@ class DICOMwebClient {
963961
});
964962

965963
if( !fieldValueParts.length ) {
966-
throw new Error(`No acceptable media types found among ${JSON.stringify(mediaTypes)}`);
964+
throw new Error(`No acceptable media types found among ${JSON.stringify(mediaTypes)} testing against ${JSON.stringify(acceptableMediaTypes)}`);
967965
}
968966

969967
return fieldValueParts.join(', ');
@@ -1229,7 +1227,7 @@ class DICOMwebClient {
12291227
debugLog(`retrieve metadata of instance ${options.sopInstanceUID}`);
12301228
const url = `${this.wadoURL}/studies/${options.studyInstanceUID}/series/${options.seriesInstanceUID}/instances/${options.sopInstanceUID}/metadata`;
12311229

1232-
const request = getRequestOptions(options.request)
1230+
const request = getRequestOptions(options.request);
12331231
return this._httpGetApplicationJson(url, {}, request);
12341232
}
12351233

@@ -1278,6 +1276,7 @@ class DICOMwebClient {
12781276
const { mediaTypes } = options;
12791277

12801278
const request = getRequestOptions(options.request)
1279+
request.responseType = 'arraybuffer';
12811280

12821281
if (!mediaTypes) {
12831282
return this._httpGetMultipartApplicationOctetStream(
@@ -1319,7 +1318,6 @@ class DICOMwebClient {
13191318
supportedMediaTypes,
13201319
),
13211320
};
1322-
request.responseType = 'arraybuffer';
13231321
return this._httpGet(url, headers, request);
13241322
}
13251323

src/message.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function addHeaders(destination, headerString) {
209209
}
210210
if (name === 'content-type') {
211211
const endSimpleType = value.indexOf(';');
212-
contentType ||= value.substring(
212+
contentType = value.substring(
213213
0,
214214
endSimpleType === -1 ? value.length : endSimpleType,
215215
);

test/test.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ let dwc = new DICOMwebClient.api.DICOMwebClient({
2424
url: 'http://localhost:8008/dcm4chee-arc/aets/DCM4CHEE/rs',
2525
retrieveRendered: false,
2626
});
27+
2728
describe('dicomweb.api.DICOMwebClient', function() {
2829
//
2930
// Note: you can add the following for debugging tests locally
@@ -124,10 +125,17 @@ describe('dicomweb.api.DICOMwebClient', function() {
124125
sopInstanceUID:
125126
'1.3.6.1.4.1.14519.5.2.1.2744.7002.325971588264730726076978589153',
126127
frameNumbers: '1',
128+
// The next line should work, but the server side is broken
129+
// mediaTypes: [ {mediaType: 'image/*' }],
127130
};
128131

129-
const frames = dwc.retrieveInstance(options);
130-
});
132+
const frames = await dwc.retrieveInstanceFrames(options);
133+
expect(frames instanceof Array).toBe(true);
134+
expect(frames.length).toBe(1);
135+
expect(frames[0].contentType).toBe("application/octet-stream");
136+
// The next line is the correct value for servers supporting image/*
137+
//expect(frames[0].transferSyntaxUID).toBe('1.2.3');
138+
}, 15000);
131139

132140
it('should retrieve a single instance', async function() {
133141
// from sample.dcm
@@ -173,10 +181,9 @@ describe('dicomweb.api.DICOMwebClient', function() {
173181
const options = {
174182
studyInstanceUID: '999.999.3859744',
175183
seriesInstanceUID: '999.999.94827453',
176-
sopInstanceUID: '999.999.133.1996.1.1800.1.6.25',
177184
};
178185

179-
const metadata = await dwc.retrieveInstanceMetadata(options);
186+
const metadata = await dwc.retrieveSeriesMetadata(options);
180187

181188
// TODO: Check why metadata is an array of objects, not just an object
182189
const bulkDataOptions = {

test_ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Clear any previous data from the last test run
2-
rm -rf /tmp/dcm4chee-arc/db
2+
rm -rf ./tmp/dcm4chee-arc/db
33

44
# now start dcm4chee archive and wait for it to startup
55
echo 'Starting dcm4chee Docker container'

0 commit comments

Comments
 (0)