Migrate //scouting:scouting_test to Protractor

This framework automatically takes care of the webdriver/selenium
setup. It just lets us focus on writing tests.

This patch migrates the scouting test to use Protractor. It validates
that the application loads correctly and displays the only message
that exists so far.

I can confirm that that test uses a sandboxed version of the chromium
browser:

    $ bazel cquery 'somepath(//scouting:scouting_test, @org_chromium_chromium_linux_x64//:metadata)' 2>/dev/null
    //scouting:scouting_test (cdf6808)
    //scouting:scouting_test_chromium-local (cdf6808)
    @io_bazel_rules_webtesting//browsers:chromium-local (3ee7ec9)
    @io_bazel_rules_webtesting//third_party/chromium:chromium (3ee7ec9)
    @org_chromium_chromium_linux_x64//:metadata (3ee7ec9)

I based the test itself on the upstream example code:
https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular/e2e/src

Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I8d24e82077af3c104d676168e52ecec89fda8004
diff --git a/tools/build_rules/js.bzl b/tools/build_rules/js.bzl
index be6826c..eeb5594 100644
--- a/tools/build_rules/js.bzl
+++ b/tools/build_rules/js.bzl
@@ -1,6 +1,9 @@
 load("@build_bazel_rules_nodejs//:providers.bzl", "JSModuleInfo")
 load("@npm//@bazel/rollup:index.bzl", upstream_rollup_bundle = "rollup_bundle")
 load("@npm//@bazel/terser:index.bzl", "terser_minified")
+load("@bazel_skylib//lib:paths.bzl", "paths")
+load("@npm//@bazel/protractor:index.bzl", "protractor_web_test_suite")
+load("@npm//@bazel/typescript:index.bzl", "ts_project")
 
 def rollup_bundle(name, deps, visibility = None, **kwargs):
     """Calls the upstream rollup_bundle() and exposes a .min.js file.
@@ -78,3 +81,36 @@
         ),
     },
 )
+
+def protractor_ts_test(name, srcs, deps = None, **kwargs):
+    """Wraps upstream protractor_web_test_suite() to reduce boilerplate.
+
+    This is largely based on the upstream protractor example:
+    https://github.com/bazelbuild/rules_nodejs/blob/stable/examples/angular/e2e/BUILD.bazel
+
+    See the documentation for more information:
+    https://bazelbuild.github.io/rules_nodejs/Protractor.html#protractor_web_test_suite
+    """
+    ts_project(
+        name = name + "__lib",
+        srcs = srcs,
+        testonly = 1,
+        deps = (deps or []) + [
+            # Implicit deps that are necessary to get tests of this kind to
+            # work.
+            "@npm//@types/jasmine",
+            "@npm//jasmine",
+            "@npm//protractor",
+            "@npm//@types/node",
+        ],
+        tsconfig = {},
+        declaration = True,
+        declaration_map = True,
+    )
+
+    protractor_web_test_suite(
+        name = name,
+        srcs = [paths.replace_extension(src, ".js") for src in srcs],
+        deps = [":%s__lib" % name],
+        **kwargs
+    )