Skip to content

Commit 9c62a28

Browse files
committed
Extend IT to check that unreferenced js files are not validated
1 parent 3889019 commit 9c62a28

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* #%L
3+
* wcm.io
4+
* %%
5+
* Copyright (C) 2016 wcm.io
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
(function (angular, Granite) {
21+
"use strict";
22+
23+
angular.module("io.wcm.caconfig.editor", [
24+
"ngRoute"
25+
])
26+
.run(initRun);
27+
28+
initRun.$inject = ["$rootScope", "$location"];
29+
30+
function initRun($rootScope, $location) {
31+
32+
$rootScope.redirectUrl = null;
33+
34+
$rootScope.go = function (path) {
35+
path = path ? String(path) : "";
36+
if (path.charAt(0) !== "/") {
37+
path = "/" + path;
38+
}
39+
$location.path(path);
40+
};
41+
42+
$rootScope.goToRedirectUrl = function () {
43+
$rootScope.go($rootScope.redirectUrl);
44+
$rootScope.redirectUrl = null;
45+
};
46+
47+
$rootScope.i18n = function (key) {
48+
return Granite.I18n.get("io.wcm.caconfig.editor." + key);
49+
};
50+
51+
$rootScope.$on('$routeChangeStart', function(event, next, current) {
52+
if (isSameRoute(current, next)) {
53+
// avoid reload when route is the same as before
54+
event.preventDefault();
55+
}
56+
});
57+
}
58+
59+
function isSameRoute(current, next) {
60+
const currentController = current?.$$route?.controller;
61+
const currentConfigName = current?.pathParams?.configName;
62+
const nextController = next?.$$route?.controller;
63+
const nextConfigName = next?.pathParams?.configName;
64+
return currentController !== undefined && currentController === nextController && currentConfigName === nextConfigName;
65+
}
66+
67+
}(angular, Granite));

‎src/it/application-package/verify.groovy‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ assert buildLog.contains("""
77
[ERROR] ValidationViolation: [JSC_LANGUAGE_FEATURE] This language feature is only supported for ECMASCRIPT_2020 mode or better: Optional chaining. @ jcr_root${File.separator}apps${File.separator}mytenant${File.separator}clientlibrary1${File.separator}js${File.separator}editor${File.separator}editor.module.js, line 62, column 27, validator: netcentric-clientlibrary-jsprocessor
88
[ERROR] ValidationViolation: [JSC_LANGUAGE_FEATURE] This language feature is only supported for ECMASCRIPT_2020 mode or better: Optional chaining. @ jcr_root${File.separator}apps${File.separator}mytenant${File.separator}clientlibrary1${File.separator}js${File.separator}editor${File.separator}editor.module.js, line 63, column 27, validator: netcentric-clientlibrary-jsprocessor""") : 'application-package'
99

10+
assert buildLog.contains('Found 4 violation(s) (with severity=ERROR)' ) : 'wrong number of violations'
1011
return true

0 commit comments

Comments
 (0)