blob: d104636270a942d1b9a3a7e545868047594b8de1 [file] [log] [blame]
Sean Condon436c60a2021-01-01 14:23:29 +00001load("@npm//@bazel/typescript:index.bzl", "ts_library")
2load("@npm//@bazel/karma:index.bzl", "karma_web_test")
Sean Condon98b6ddb2019-12-24 08:07:40 +00003
4package(default_visibility = ["//:__subpackages__"])
5
6# We don't import from these, but the generated ngfactory code will
7NG_FACTORY_ADDED_IMPORTS = [
8 "@npm//@angular/animations",
9 "@npm//@angular/forms",
10]
11
Sean Condon436c60a2021-01-01 14:23:29 +000012ts_library(
Sean Condon98b6ddb2019-12-24 08:07:40 +000013 name = "gui2-topo-lib",
14 srcs = glob(
15 include = ["**/*.ts"],
16 exclude = [
17 "**/*.spec.ts",
Sean Condon98b6ddb2019-12-24 08:07:40 +000018 ],
19 ),
Sean Condon436c60a2021-01-01 14:23:29 +000020 angular_assets = [
21 "//web/gui2-fw-lib:extra_css",
22 ] + glob([
Sean Condon98b6ddb2019-12-24 08:07:40 +000023 "**/*.css",
24 "**/*.html",
25 ]),
Sean Condona3ad7792020-01-04 19:26:34 +000026 tsconfig = "//web/gui2:tsconfig.json",
Sean Condon436c60a2021-01-01 14:23:29 +000027 use_angular_plugin = True,
Sean Condon98b6ddb2019-12-24 08:07:40 +000028 deps = NG_FACTORY_ADDED_IMPORTS + [
29 "//web/gui2-fw-lib",
30 "@npm//@angular/core",
Sean Condon436c60a2021-01-01 14:23:29 +000031 "@npm//@angular/common",
Sean Condon98b6ddb2019-12-24 08:07:40 +000032 "@npm//@angular/router",
33 "@npm//@angular/platform-browser",
34 "@npm//rxjs",
35 "@npm//@types",
36 "@npm//topojson-client",
37 ],
38)
Sean Condona3ad7792020-01-04 19:26:34 +000039
40ts_library(
41 name = "test_lib",
42 testonly = 1,
43 srcs = glob(
44 include = ["**/*.spec.ts"],
45 # TODO re-enable this test
46 exclude = [
47 "lib/layer/backgroundsvg/backgroundsvg.component.spec.ts",
Sean Condonf9ff66a2020-03-23 08:40:55 +000048 "lib/layer/forcesvg/visuals/hostnodesvg/hostnodesvg.component.spec.ts",
Sean Condona3ad7792020-01-04 19:26:34 +000049 ],
50 ),
51 tsconfig = "//web/gui2:tsconfig-test",
52 deps = [
53 ":gui2-topo-lib",
54 "//web/gui2-fw-lib",
55 "@npm//@angular/common",
56 "@npm//@angular/core",
57 "@npm//@angular/forms",
Sean Condona3ad7792020-01-04 19:26:34 +000058 "@npm//@angular/platform-browser",
59 "@npm//@angular/router",
60 "@npm//@types/jasmine",
61 "@npm//rxjs",
62 ],
63)
64
65# Convert topojson-client to an AMD module so it can be loaded in the RequireJS test environment.
66genrule(
67 name = "topojson-client_requirejs",
68 srcs = [
69 "@npm//:node_modules/topojson-client/dist/topojson-client.js",
70 ],
71 outs = [
72 "topojson-client.js",
73 ],
74 cmd = """echo "define('topojson-client', function(require, exports, module) {" > $@ \
75 && cat $< >> $@ \
76 && echo '});' >> $@""",
77)
78
79# Convert d3-force to an AMD module so it can be loaded in the RequireJS test environment.
80genrule(
81 name = "d3-force_requirejs",
82 srcs = [
83 "@npm//:node_modules/d3-force/dist/d3-force.js",
84 ],
85 outs = [
86 "d3-force.js",
87 ],
88 cmd = """echo "define('d3-force', function(require, exports, module) {" > $@ \
89 && cat $< >> $@ \
90 && echo '});' >> $@""",
91)
92
93# Convert d3-quadtree to an AMD module so it can be loaded in the RequireJS test environment.
94genrule(
95 name = "d3-quadtree_requirejs",
96 srcs = [
97 "@npm//:node_modules/d3-quadtree/dist/d3-quadtree.js",
98 ],
99 outs = [
100 "d3-quadtree.js",
101 ],
102 cmd = """echo "define('d3-quadtree', function(require, exports, module) {" > $@ \
103 && cat $< >> $@ \
104 && echo '});' >> $@""",
105)
106
107# Convert d3-collection to an AMD module so it can be loaded in the RequireJS test environment.
108genrule(
109 name = "d3-collection_requirejs",
110 srcs = [
111 "@npm//:node_modules/d3-collection/dist/d3-collection.js",
112 ],
113 outs = [
114 "d3-collection.js",
115 ],
116 cmd = """echo "define('d3-collection', function(require, exports, module) {" > $@ \
117 && cat $< >> $@ \
118 && echo '});' >> $@""",
119)
120
121# Convert d3-dispatch to an AMD module so it can be loaded in the RequireJS test environment.
122genrule(
123 name = "d3-dispatch_requirejs",
124 srcs = [
125 "@npm//:node_modules/d3-dispatch/dist/d3-dispatch.js",
126 ],
127 outs = [
128 "d3-dispatch.js",
129 ],
130 cmd = """echo "define('d3-dispatch', function(require, exports, module) {" > $@ \
131 && cat $< >> $@ \
132 && echo '});' >> $@""",
133)
134
135# Convert d3-timer to an AMD module so it can be loaded in the RequireJS test environment.
136genrule(
137 name = "d3-timer_requirejs",
138 srcs = [
139 "@npm//:node_modules/d3-timer/dist/d3-timer.js",
140 ],
141 outs = [
142 "d3-timer.js",
143 ],
144 cmd = """echo "define('d3-timer', function(require, exports, module) {" > $@ \
145 && cat $< >> $@ \
146 && echo '});' >> $@""",
147)
148
Sean Condon4ceeae72021-10-21 15:37:11 +0100149# These tests are not run as part of CI because they require a browser to be installed
150# Run them locally on your system if you are making a change to any of the TypeScript files
151# bazel test //web/gui2-topo-lib:test-not-coverage
Sean Condone4e8f6a2020-04-13 10:30:35 +0100152karma_web_test(
Sean Condonf86cfc92020-04-14 15:10:03 +0100153 name = "test-not-coverage", # coverage is to avoid being picked up by 'ot' alias
Sean Condona3ad7792020-01-04 19:26:34 +0000154 srcs = [
155 ],
156 # do not sort
157 bootstrap = [
158 "@npm//:node_modules/zone.js/dist/zone-testing-bundle.js",
159 "@npm//:node_modules/reflect-metadata/Reflect.js",
160 ],
Sean Condon4ceeae72021-10-21 15:37:11 +0100161 config_file = "//web/gui2/src/main/webapp:karma.conf.js", # Edit this file to set the Browsers needed
Sean Condona3ad7792020-01-04 19:26:34 +0000162 tags = ["native"],
163 runtime_deps = [
164 "//web/gui2/src/main/webapp:initialize_testbed",
165 ],
166 deps = [
167 ":d3-collection_requirejs",
168 ":d3-dispatch_requirejs",
169 ":d3-force_requirejs",
170 ":d3-quadtree_requirejs",
171 ":d3-timer_requirejs",
172 ":test_lib",
173 ":topojson-client_requirejs",
174 "//web/gui:src/main/webapp/data",
175 "//web/gui2/src/main/webapp:d3_requirejs",
176 "//web/gui2/src/main/webapp:rxjs_umd_modules",
Sean Condonf86cfc92020-04-14 15:10:03 +0100177 "@npm//@angular-devkit/build-angular",
178 "@npm//karma-coverage-istanbul-reporter",
179 "@npm//karma-jasmine-html-reporter",
Sean Condona3ad7792020-01-04 19:26:34 +0000180 ],
181)