Skip to content

Commit

Permalink
Merge pull request #1148 from girder/lint-client-tests
Browse files Browse the repository at this point in the history
Lint client tests
  • Loading branch information
manthey authored May 4, 2023
2 parents 49809ff + d76b9c2 commit 0fd8877
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 42 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
18dac36d043948cd973d0188abe18504042a49aa
# PR 1129: Use stylus-supremacy for linting and reformating stylus files
497ddf38b1461da47d1d542003172603e2166b5f
# PR 1148: Lint the client tests
23ab7f011abaa71d0a4904a9da599174c38f64c3
4 changes: 2 additions & 2 deletions girder/girder_large_image/web_client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"stylus-supremacy": "^2.17.5"
},
"scripts": {
"lint": "eslint --cache . && pug-lint . && stylus-supremacy format --compare ./**/*.styl --options package.json",
"format": "eslint --cache --fix . && eslint --cache --fix . && stylus-supremacy format ./**/*.styl --replace --options package.json"
"lint": "eslint --cache . && eslint --no-eslintrc -c ./package.json --cache ../../test_girder/web_client_specs && pug-lint . && stylus-supremacy format --compare ./**/*.styl --options package.json",
"format": "eslint --cache --fix . && eslint --no-eslintrc -c ./package.json --cache --fix ../../test_girder/web_client_specs && eslint --cache --fix . && stylus-supremacy format ./**/*.styl --replace --options package.json"
}
}
10 changes: 5 additions & 5 deletions girder/test_girder/web_client_specs/imageViewerSpec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals beforeEach, afterEach, describe, it, expect, _ */
/* globals describe, it, expect, _, girderTest, $, runs, waitsFor */

girderTest.importPlugin('large_image');

Expand Down Expand Up @@ -49,7 +49,7 @@ $(function () {
});
girderTest.waitForLoad();
runs(function () {
girderTest.binaryUpload('${large_image}/../../test/test_files/multi_test_source3.yml');
girderTest.binaryUpload('${large_image}/../../test/test_files/multi_test_source3.yml'); // eslint-disable-line no-template-curly-in-string
});
girderTest.waitForLoad();
});
Expand Down Expand Up @@ -95,7 +95,7 @@ $(function () {
});
girderTest.waitForLoad();
runs(function () {
girderTest.binaryUpload('${large_image}/../../test/test_files/yb10kx5k.png');
girderTest.binaryUpload('${large_image}/../../test/test_files/yb10kx5k.png'); // eslint-disable-line no-template-curly-in-string
});
girderTest.waitForLoad();
});
Expand Down Expand Up @@ -161,7 +161,7 @@ $(function () {
});
girderTest.waitForLoad();
runs(function () {
girderTest.binaryUpload('${large_image}/../../test/test_files/yb10kx5k.png');
girderTest.binaryUpload('${large_image}/../../test/test_files/yb10kx5k.png'); // eslint-disable-line no-template-curly-in-string
});
girderTest.waitForLoad();
}, 30000);
Expand Down Expand Up @@ -219,7 +219,7 @@ $(function () {
});
girderTest.waitForLoad();
runs(function () {
girderTest.binaryUpload('${large_image}/../../test/test_files/.large_image_config.yaml');
girderTest.binaryUpload('${large_image}/../../test/test_files/.large_image_config.yaml'); // eslint-disable-line no-template-curly-in-string
});
girderTest.waitForLoad();
});
Expand Down
4 changes: 2 additions & 2 deletions girder/test_girder/web_client_specs/largeImageSpec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals girder, girderTest, describe, it, expect, waitsFor, runs */
/* globals girder, girderTest, describe, it, expect, waitsFor, runs, $ */

girderTest.importPlugin('jobs', 'worker', 'large_image');

Expand Down Expand Up @@ -74,7 +74,7 @@ describe('Test the large image plugin', function () {
expect(settings['large_image.show_extra_admin']).toBe('{"images": ["label", "macro"]}');
expect(settings['large_image.show_item_extra_public']).toBe('{}');
expect(settings['large_image.show_item_extra']).toBe('{}');
expect(JSON.parse(settings['large_image.show_item_extra_admin'])).toEqual({'metadata': ['tile', 'internal'], 'images': ['label', 'macro', '*']});
expect(JSON.parse(settings['large_image.show_item_extra_admin'])).toEqual({metadata: ['tile', 'internal'], images: ['label', 'macro', '*']});
expect(settings['large_image.icc_correction']).toBe(false);
});
girderTest.waitForLoad();
Expand Down
6 changes: 3 additions & 3 deletions girder/test_girder/web_client_specs/otherFeatures.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals girder, girderTest, describe, it, expect, waitsFor, runs */
/* globals girderTest, describe, it, expect, waitsFor, runs, $, _ */

girderTest.importPlugin('jobs', 'worker', 'large_image');

Expand Down Expand Up @@ -47,7 +47,7 @@ describe('Test features added by the large image plugin but not directly related
});
girderTest.waitForLoad();
runs(function () {
girderTest.binaryUpload('${large_image}/../../test/test_files/multi_test_source3.yml');
girderTest.binaryUpload('${large_image}/../../test/test_files/multi_test_source3.yml'); // eslint-disable-line no-template-curly-in-string
});
girderTest.waitForLoad();
});
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('Test features added by the large image plugin but not directly related
});
girderTest.waitForLoad();
runs(function () {
girderTest.binaryUpload('${large_image}/../../test/test_files/sample.girder.cfg');
girderTest.binaryUpload('${large_image}/../../test/test_files/sample.girder.cfg'); // eslint-disable-line no-template-curly-in-string
});
girderTest.waitForLoad();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"stylus-supremacy": "^2.17.5"
},
"scripts": {
"lint": "eslint --cache . && pug-lint . && stylus-supremacy format --compare ./**/*.styl --options package.json",
"format": "eslint --cache --fix . && eslint --cache --fix . && stylus-supremacy format ./**/*.styl --replace --options package.json"
"lint": "eslint --cache . && eslint --no-eslintrc -c ./package.json --cache ../../test_annotation/web_client_specs && pug-lint . && stylus-supremacy format --compare ./**/*.styl --options package.json",
"format": "eslint --cache --fix . && eslint --no-eslintrc -c ./package.json --cache --fix ../../test_annotation/web_client_specs && eslint --cache --fix . && stylus-supremacy format ./**/*.styl --replace --options package.json"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* globals girderTest, describe, it, expect, beforeEach, waitsFor, $, _, runs */

girderTest.importPlugin('large_image', 'large_image_annotation');
girderTest.startApp();

Expand Down Expand Up @@ -103,7 +105,7 @@ describe('AnnotationListWidget', function () {
});
girderTest.waitForLoad();
runs(function () {
girderTest.binaryUpload('${large_image}/../../test/test_files/yb10kx5k.zstd.tiff');
girderTest.binaryUpload('${large_image}/../../test/test_files/yb10kx5k.zstd.tiff'); // eslint-disable-line no-template-curly-in-string
});
girderTest.waitForLoad();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals girder, girderTest, describe, it, expect, waitsFor, runs */
/* globals girder, girderTest, describe, it, expect, waitsFor, runs, beforeEach */

girderTest.importPlugin('jobs', 'worker', 'large_image', 'large_image_annotation');

Expand Down Expand Up @@ -178,58 +178,59 @@ describe('Annotations', function () {
result: {
min: 0,
max: null,
color: {'0': {r: 0, g: 0, b: 0, a: 0}, '1': {r: 1, g: 1, b: 0, a: 1}}
color: {0: {r: 0, g: 0, b: 0, a: 0}, 1: {r: 1, g: 1, b: 0, a: 1}}
}
}, {
name: 'normalize range, one value',
record: {normalizeRange: true, colorRange: ['red'], rangeValues: [0.5]},
result: {
min: 0,
max: null,
color: {'0': {r: 0, g: 0, b: 0, a: 0}, '1': {r: 1, g: 1, b: 0, a: 1}, '0.5': 'red'}
color: {0: {r: 0, g: 0, b: 0, a: 0}, 1: {r: 1, g: 1, b: 0, a: 1}, 0.5: 'red'}
}
}, {
name: 'normalize range, several values',
record: {
normalizeRange: true,
colorRange: ['blue', 'red', 'green', 'white', 'black'],
rangeValues: [-1, -0.2, 0.5, 1.1, 2]},
rangeValues: [-1, -0.2, 0.5, 1.1, 2]
},
result: {
min: 0,
max: null,
color: {'0': 'red', '0.5': 'green', '1': 'white'}
color: {0: 'red', 0.5: 'green', 1: 'white'}
}
}, {
name: 'no normalize range',
record: {},
result: {
min: 0,
max: null,
color: {'0': {r: 0, g: 0, b: 0, a: 0}, '1': {r: 1, g: 1, b: 0, a: 1}}
color: {0: {r: 0, g: 0, b: 0, a: 0}, 1: {r: 1, g: 1, b: 0, a: 1}}
}
}, {
name: 'set range',
record: {colorRange: ['red', 'blue'], rangeValues: [0, 1]},
result: {
min: 0,
max: 1,
color: {'0': 'red', '1': 'blue'}
color: {0: 'red', 1: 'blue'}
}
}, {
name: 'set range, more values',
record: {colorRange: ['red', 'blue', 'green'], rangeValues: [0, 0.2, 0.8]},
result: {
min: 0,
max: 0.8,
color: {'0': 'red', '0.25': 'blue', '1': 'green'}
color: {0: 'red', 0.25: 'blue', 1: 'green'}
}
}, {
name: 'set range, more range',
record: {colorRange: ['red', 'blue'], rangeValues: [0.8, 0.8]},
result: {
min: 0.8,
max: 0.8,
color: {'0': {r: 0, g: 0, b: 0, a: 0}, '1': 'red'}
color: {0: {r: 0, g: 0, b: 0, a: 0}, 1: 'red'}
}
}];
tests.forEach(function (test) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals girder, girderTest, describe, it, expect, waitsFor, runs */
/* globals girder, girderTest, describe, it, expect, beforeEach */
/* eslint-disable camelcase */

girderTest.importPlugin('large_image', 'large_image_annotation');
Expand Down
35 changes: 18 additions & 17 deletions girder_annotation/test_annotation/web_client_specs/geojsSpec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals beforeEach, afterEach, describe, it, expect, sinon, girder, Backbone, _ */
/* globals beforeEach, afterEach, describe, it, expect, sinon, girder, Backbone, _, girderTest, $, runs, waitsFor */
/* eslint-disable camelcase, no-new */

girderTest.importPlugin('jobs', 'worker', 'large_image', 'large_image_annotation');
Expand Down Expand Up @@ -46,7 +46,7 @@ $(function () {
});
girderTest.waitForLoad();
runs(function () {
girderTest.binaryUpload('${large_image}/../../test/test_files/small_la.tiff');
girderTest.binaryUpload('${large_image}/../../test/test_files/small_la.tiff'); // eslint-disable-line no-template-curly-in-string
});
girderTest.waitForLoad();
runs(function () {
Expand Down Expand Up @@ -97,8 +97,8 @@ $(function () {
girderId: itemId,
opacity: 0.5,
transform: {
'xoffset': 10,
'yoffset': 15
xoffset: 10,
yoffset: 15
}
}]
})
Expand Down Expand Up @@ -187,13 +187,14 @@ $(function () {
});
});

it('draw overlay', function() {
runs(function() {
it('draw overlay', function () {
var projStringSpy;
runs(function () {
overlayAnnotation = new largeImageAnnotation.models.AnnotationModel({
_id: overlayAnnotationId
});
overlayAnnotation.fetch();
})
});
girderTest.waitForLoad();
runs(function () {
projStringSpy = sinon.spy(viewer, '_getOverlayTransformProjString');
Expand All @@ -207,13 +208,13 @@ $(function () {
});
});

it('generates pixelmap layer parameters', function() {
it('generates pixelmap layer parameters', function () {
const overlayMetadata = {
sizeX: 500,
sizeY: 500,
tileWidth: 256,
tileHeight: 256,
levels: viewer.levels,
levels: viewer.levels
};
const overlayId = '012345678901234567890123';
const pixelMapElement = {
Expand All @@ -227,7 +228,7 @@ $(function () {
{fillColor: '#000000'},
{fillColor: '#ffffff'}
]
}
};
const pixelmapLayerParams = viewer._generateOverlayLayerParams(overlayMetadata, overlayId, pixelMapElement);
const expectedUrl = 'api/v1/item/' + overlayId + '/tiles/zxy/{z}/{x}/{y}?encoding=PNG';
expect(pixelmapLayerParams.url).toBe(expectedUrl);
Expand Down Expand Up @@ -323,7 +324,7 @@ $(function () {
});
});

it('fires overlay event', function() {
it('fires overlay event', function () {
const eventType = window.geo.event.feature.mouseclick;
const mockEvent = {
event: eventType,
Expand Down Expand Up @@ -447,7 +448,7 @@ $(function () {
expect(elements.length).toBe(1);
expect(elements[0].type).toBe('point');
closeTo(elements[0].center, [100, 200, 0]);
created = true;;
created = true;
return null;
});
var pt = viewer.viewer.gcsToDisplay({x: 100, y: 200});
Expand Down Expand Up @@ -485,7 +486,7 @@ $(function () {
closeTo(points[0], [100, 200, 0]);
closeTo(points[1], [200, 200, 0]);
closeTo(points[2], [200, 300, 0]);
created = true;;
created = true;
return null;
});

Expand Down Expand Up @@ -561,7 +562,7 @@ $(function () {
closeTo(elements[0].center, [150, 300, 0]);
expect(elements[0].width).toBe(100);
expect(elements[0].height).toBe(200);
created = true;;
created = true;
return null;
});

Expand Down Expand Up @@ -606,7 +607,7 @@ $(function () {
closeTo(elements[0].center, [150, 300, 0]);
expect(elements[0].width).toBe(100);
expect(elements[0].height).toBe(200);
created = true;;
created = true;
return null;
});

Expand Down Expand Up @@ -650,7 +651,7 @@ $(function () {
expect(elements.length).toBe(1);
closeTo(elements[0].center, [200, 200, 0]);
expect(elements[0].radius).toBe(100);
created = true;;
created = true;
return null;
});

Expand Down Expand Up @@ -698,7 +699,7 @@ $(function () {
closeTo(elements[0].points[0], [100, 200, 0]);
closeTo(elements[0].points[1], [200, 200, 0]);
closeTo(elements[0].points[2], [200, 300, 0]);
created = true;;
created = true;
return null;
});

Expand Down

0 comments on commit 0fd8877

Please sign in to comment.