From 23ab7f011abaa71d0a4904a9da599174c38f64c3 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Thu, 4 May 2023 13:06:12 -0400 Subject: [PATCH 1/2] Lint the client tests. --- .../web_client/package.json | 4 +-- .../web_client_specs/imageViewerSpec.js | 10 +++--- .../web_client_specs/largeImageSpec.js | 4 +-- .../web_client_specs/otherFeatures.js | 6 ++-- .../web_client/package.json | 4 +-- .../web_client_specs/annotationListSpec.js | 4 ++- .../web_client_specs/annotationSpec.js | 19 +++++----- .../web_client_specs/geojsAnnotationSpec.js | 2 +- .../web_client_specs/geojsSpec.js | 35 ++++++++++--------- 9 files changed, 46 insertions(+), 42 deletions(-) diff --git a/girder/girder_large_image/web_client/package.json b/girder/girder_large_image/web_client/package.json index 618adc3a9..04de14806 100644 --- a/girder/girder_large_image/web_client/package.json +++ b/girder/girder_large_image/web_client/package.json @@ -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" } } diff --git a/girder/test_girder/web_client_specs/imageViewerSpec.js b/girder/test_girder/web_client_specs/imageViewerSpec.js index 3b3d883bb..3463fa303 100644 --- a/girder/test_girder/web_client_specs/imageViewerSpec.js +++ b/girder/test_girder/web_client_specs/imageViewerSpec.js @@ -1,4 +1,4 @@ -/* globals beforeEach, afterEach, describe, it, expect, _ */ +/* globals describe, it, expect, _, girderTest, $, runs, waitsFor */ girderTest.importPlugin('large_image'); @@ -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(); }); @@ -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(); }); @@ -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); @@ -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(); }); diff --git a/girder/test_girder/web_client_specs/largeImageSpec.js b/girder/test_girder/web_client_specs/largeImageSpec.js index 138fcf51d..4c765c34d 100644 --- a/girder/test_girder/web_client_specs/largeImageSpec.js +++ b/girder/test_girder/web_client_specs/largeImageSpec.js @@ -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'); @@ -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(); diff --git a/girder/test_girder/web_client_specs/otherFeatures.js b/girder/test_girder/web_client_specs/otherFeatures.js index ef0f4f8d2..9756fa020 100644 --- a/girder/test_girder/web_client_specs/otherFeatures.js +++ b/girder/test_girder/web_client_specs/otherFeatures.js @@ -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'); @@ -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(); }); @@ -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(); }); diff --git a/girder_annotation/girder_large_image_annotation/web_client/package.json b/girder_annotation/girder_large_image_annotation/web_client/package.json index dedbbef9e..77dbf8598 100644 --- a/girder_annotation/girder_large_image_annotation/web_client/package.json +++ b/girder_annotation/girder_large_image_annotation/web_client/package.json @@ -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" } } diff --git a/girder_annotation/test_annotation/web_client_specs/annotationListSpec.js b/girder_annotation/test_annotation/web_client_specs/annotationListSpec.js index 179726a7c..3c93d8825 100644 --- a/girder_annotation/test_annotation/web_client_specs/annotationListSpec.js +++ b/girder_annotation/test_annotation/web_client_specs/annotationListSpec.js @@ -1,3 +1,5 @@ +/* globals girderTest, describe, it, expect, beforeEach, waitsFor, $, _, runs */ + girderTest.importPlugin('large_image', 'large_image_annotation'); girderTest.startApp(); @@ -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(); }); diff --git a/girder_annotation/test_annotation/web_client_specs/annotationSpec.js b/girder_annotation/test_annotation/web_client_specs/annotationSpec.js index 5c989646b..914a09940 100644 --- a/girder_annotation/test_annotation/web_client_specs/annotationSpec.js +++ b/girder_annotation/test_annotation/web_client_specs/annotationSpec.js @@ -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'); @@ -178,7 +178,7 @@ 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', @@ -186,18 +186,19 @@ 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}, '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', @@ -205,7 +206,7 @@ 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: 'set range', @@ -213,7 +214,7 @@ describe('Annotations', function () { result: { min: 0, max: 1, - color: {'0': 'red', '1': 'blue'} + color: {0: 'red', 1: 'blue'} } }, { name: 'set range, more values', @@ -221,7 +222,7 @@ describe('Annotations', function () { 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', @@ -229,7 +230,7 @@ describe('Annotations', function () { 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) { diff --git a/girder_annotation/test_annotation/web_client_specs/geojsAnnotationSpec.js b/girder_annotation/test_annotation/web_client_specs/geojsAnnotationSpec.js index 80896a9aa..cf17045f4 100644 --- a/girder_annotation/test_annotation/web_client_specs/geojsAnnotationSpec.js +++ b/girder_annotation/test_annotation/web_client_specs/geojsAnnotationSpec.js @@ -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'); diff --git a/girder_annotation/test_annotation/web_client_specs/geojsSpec.js b/girder_annotation/test_annotation/web_client_specs/geojsSpec.js index e325996cf..59441555e 100644 --- a/girder_annotation/test_annotation/web_client_specs/geojsSpec.js +++ b/girder_annotation/test_annotation/web_client_specs/geojsSpec.js @@ -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'); @@ -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 () { @@ -97,8 +97,8 @@ $(function () { girderId: itemId, opacity: 0.5, transform: { - 'xoffset': 10, - 'yoffset': 15 + xoffset: 10, + yoffset: 15 } }] }) @@ -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'); @@ -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 = { @@ -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); @@ -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, @@ -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}); @@ -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; }); @@ -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; }); @@ -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; }); @@ -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; }); @@ -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; }); From d76b9c28fe93ebb0e85da355104718b9b441233b Mon Sep 17 00:00:00 2001 From: David Manthey Date: Thu, 4 May 2023 13:07:12 -0400 Subject: [PATCH 2/2] Ignore the linting changes. --- .git-blame-ignore-revs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index c569bc38f..e0eb6df50 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -9,3 +9,5 @@ 18dac36d043948cd973d0188abe18504042a49aa # PR 1129: Use stylus-supremacy for linting and reformating stylus files 497ddf38b1461da47d1d542003172603e2166b5f +# PR 1148: Lint the client tests +23ab7f011abaa71d0a4904a9da599174c38f64c3