blob: 82052f6b7d03eb3acfe45f8763632c0c85c73a36 [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",
48 "lib/layer/forcesvg/forcesvg.component.spec.ts",
Sean Condonf9ff66a2020-03-23 08:40:55 +000049 "lib/layer/forcesvg/visuals/hostnodesvg/hostnodesvg.component.spec.ts",
Sean Condona3ad7792020-01-04 19:26:34 +000050 ],
51 ),
52 tsconfig = "//web/gui2:tsconfig-test",
53 deps = [
54 ":gui2-topo-lib",
55 "//web/gui2-fw-lib",
56 "@npm//@angular/common",
57 "@npm//@angular/core",
58 "@npm//@angular/forms",
Sean Condona3ad7792020-01-04 19:26:34 +000059 "@npm//@angular/platform-browser",
60 "@npm//@angular/router",
61 "@npm//@types/jasmine",
62 "@npm//rxjs",
63 ],
64)
65
66# Convert topojson-client to an AMD module so it can be loaded in the RequireJS test environment.
67genrule(
68 name = "topojson-client_requirejs",
69 srcs = [
70 "@npm//:node_modules/topojson-client/dist/topojson-client.js",
71 ],
72 outs = [
73 "topojson-client.js",
74 ],
75 cmd = """echo "define('topojson-client', function(require, exports, module) {" > $@ \
76 && cat $< >> $@ \
77 && echo '});' >> $@""",
78)
79
80# Convert d3-force to an AMD module so it can be loaded in the RequireJS test environment.
81genrule(
82 name = "d3-force_requirejs",
83 srcs = [
84 "@npm//:node_modules/d3-force/dist/d3-force.js",
85 ],
86 outs = [
87 "d3-force.js",
88 ],
89 cmd = """echo "define('d3-force', function(require, exports, module) {" > $@ \
90 && cat $< >> $@ \
91 && echo '});' >> $@""",
92)
93
94# Convert d3-quadtree to an AMD module so it can be loaded in the RequireJS test environment.
95genrule(
96 name = "d3-quadtree_requirejs",
97 srcs = [
98 "@npm//:node_modules/d3-quadtree/dist/d3-quadtree.js",
99 ],
100 outs = [
101 "d3-quadtree.js",
102 ],
103 cmd = """echo "define('d3-quadtree', function(require, exports, module) {" > $@ \
104 && cat $< >> $@ \
105 && echo '});' >> $@""",
106)
107
108# Convert d3-collection to an AMD module so it can be loaded in the RequireJS test environment.
109genrule(
110 name = "d3-collection_requirejs",
111 srcs = [
112 "@npm//:node_modules/d3-collection/dist/d3-collection.js",
113 ],
114 outs = [
115 "d3-collection.js",
116 ],
117 cmd = """echo "define('d3-collection', function(require, exports, module) {" > $@ \
118 && cat $< >> $@ \
119 && echo '});' >> $@""",
120)
121
122# Convert d3-dispatch to an AMD module so it can be loaded in the RequireJS test environment.
123genrule(
124 name = "d3-dispatch_requirejs",
125 srcs = [
126 "@npm//:node_modules/d3-dispatch/dist/d3-dispatch.js",
127 ],
128 outs = [
129 "d3-dispatch.js",
130 ],
131 cmd = """echo "define('d3-dispatch', function(require, exports, module) {" > $@ \
132 && cat $< >> $@ \
133 && echo '});' >> $@""",
134)
135
136# Convert d3-timer to an AMD module so it can be loaded in the RequireJS test environment.
137genrule(
138 name = "d3-timer_requirejs",
139 srcs = [
140 "@npm//:node_modules/d3-timer/dist/d3-timer.js",
141 ],
142 outs = [
143 "d3-timer.js",
144 ],
145 cmd = """echo "define('d3-timer', function(require, exports, module) {" > $@ \
146 && cat $< >> $@ \
147 && echo '});' >> $@""",
148)
149
Sean Condone4e8f6a2020-04-13 10:30:35 +0100150karma_web_test(
Sean Condonf86cfc92020-04-14 15:10:03 +0100151 name = "test-not-coverage", # coverage is to avoid being picked up by 'ot' alias
Sean Condona3ad7792020-01-04 19:26:34 +0000152 srcs = [
153 ],
154 # do not sort
155 bootstrap = [
156 "@npm//:node_modules/zone.js/dist/zone-testing-bundle.js",
157 "@npm//:node_modules/reflect-metadata/Reflect.js",
158 ],
Sean Condonf86cfc92020-04-14 15:10:03 +0100159 config_file = "//web/gui2/src/main/webapp:karma.conf.js",
Sean Condona3ad7792020-01-04 19:26:34 +0000160 tags = ["native"],
161 runtime_deps = [
162 "//web/gui2/src/main/webapp:initialize_testbed",
163 ],
164 deps = [
165 ":d3-collection_requirejs",
166 ":d3-dispatch_requirejs",
167 ":d3-force_requirejs",
168 ":d3-quadtree_requirejs",
169 ":d3-timer_requirejs",
170 ":test_lib",
171 ":topojson-client_requirejs",
172 "//web/gui:src/main/webapp/data",
173 "//web/gui2/src/main/webapp:d3_requirejs",
174 "//web/gui2/src/main/webapp:rxjs_umd_modules",
Sean Condonf86cfc92020-04-14 15:10:03 +0100175 "@npm//@angular-devkit/build-angular",
176 "@npm//karma-coverage-istanbul-reporter",
177 "@npm//karma-jasmine-html-reporter",
Sean Condona3ad7792020-01-04 19:26:34 +0000178 ],
179)