Skip to content

Commit a468d78

Browse files
committed
chore: let Webpack to manage CatalogUtils.js
This makes possible to use Jest for JavaScript unit tests. The public URL of DateUtils.js has been changed from /public/js/$VERSION/CatalogUtils.min.js to /public/js/$VERSION/utils/CatalogUtils.min.js and technically old cached code might search by the old location but as this file wasn't available to anonymous users, the chances are extremely low. Part of #1484
1 parent ba1e775 commit a468d78

File tree

6 files changed

+8
-3
lines changed

6 files changed

+8
-3
lines changed

src/main/javascript/CatalogUtils.js renamed to src/main/frontend/src/utils/CatalogUtils.js

+2
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,5 @@ var CatalogUtils = {
7575
}
7676

7777
}
78+
79+
window.CatalogUtils = CatalogUtils;

src/test/javascript/CatalogUtilsSpec.js renamed to src/main/frontend/src/utils/CatalogUtils.test.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './CatalogUtils.js'
2+
13
describe("CatalogUtils.expandNumbers()", function() {
24

35
it("should return empty string for empty string", function() {

src/main/frontend/webpack.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const webpack = require('webpack');
55
module.exports = {
66
mode: 'production',
77
entry: {
8+
'utils/CatalogUtils': './src/utils/CatalogUtils.js',
89
'utils/DateUtils': './src/utils/DateUtils.js',
910

1011
'components/AddCatalogNumbersForm': './src/components/AddCatalogNumbersForm.js',

src/main/java/ru/mystamps/web/feature/site/ResourceUrl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public final class ResourceUrl {
3535
public static final String RESOURCES_VERSION = "v0.4.6.0";
3636

3737
// CheckStyle: ignore LineLength for next 17 lines
38-
private static final String CATALOG_UTILS_JS = "/public/js/" + RESOURCES_VERSION + "/CatalogUtils.min.js";
38+
private static final String CATALOG_UTILS_JS = "/public/js/" + RESOURCES_VERSION + "/utils/CatalogUtils.min.js";
3939
private static final String COLLECTION_INFO_JS = "/public/js/" + RESOURCES_VERSION + "/collection/info.min.js";
4040
private static final String DATE_UTILS_JS = "/public/js/" + RESOURCES_VERSION + "/utils/DateUtils.min.js";
4141
private static final String MAIN_CSS = "/static/" + RESOURCES_VERSION + "/styles/main.min.css";

src/main/webapp/WEB-INF/views/series/add.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ <h3 th:text="${#strings.capitalize(add_series)}">
528528
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" th:src="${BOOTSTRAP_JS}"></script>
529529
<script src="http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.5/js/standalone/selectize.min.js" th:src="${SELECTIZE_JS}"></script>
530530

531-
<script src="../../../../javascript/CatalogUtils.js" th:src="${CATALOG_UTILS_JS}"></script>
531+
<script src="../../../../../../target/classes/js/utils/CatalogUtils.min.js" th:src="${CATALOG_UTILS_JS}"></script>
532532
<script src="../../../../javascript/series/add.js" th:src="${SERIES_ADD_JS}"></script>
533533
</body>
534534
</html>

src/main/webapp/WEB-INF/views/series/info.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ <h5 th:text="#{t_add_info_who_selling_series}">Add info about selling/buying thi
12901290
<!--/*/
12911291
<th:block sec:authorize="hasAuthority('MARK_SIMILAR_SERIES')">
12921292
/*/-->
1293-
<script src="../../../../javascript/CatalogUtils.js" th:src="${CATALOG_UTILS_JS}"></script>
1293+
<script src="../../../../../../target/classes/js/utils/CatalogUtils.min.js" th:src="${CATALOG_UTILS_JS}"></script>
12941294
<script src="../../../../../../target/classes/js/components/SimilarSeriesForm.min.js" th:src="${SIMILAR_SERIES_FORM_JS}"></script>
12951295
<script th:inline="javascript">
12961296
/*[+

0 commit comments

Comments
 (0)