Added back in Bazel tests for gui2-fw-lib and gui2-topo-lib
Also used a named path in typescript for gui2-fw-lib
Change-Id: I7233565e53b9b86e1766228ecc96b21ea6f7499d
diff --git a/web/gui2-fw-lib/.gitignore b/web/gui2-fw-lib/.gitignore
deleted file mode 100644
index 143aa64..0000000
--- a/web/gui2-fw-lib/.gitignore
+++ /dev/null
@@ -1,45 +0,0 @@
-# See http://help.github.com/ignore-files/ for more about ignoring files.
-
-# compiled output
-/dist
-/tmp
-/out-tsc
-/gui2-fw-lib-*.tgz
-
-# dependencies
-/node_modules
-
-# IDEs and editors
-/.idea
-.project
-.classpath
-.c9/
-*.launch
-.settings/
-*.sublime-workspace
-
-# IDE - VSCode
-.vscode/*
-!.vscode/settings.json
-!.vscode/tasks.json
-!.vscode/launch.json
-!.vscode/extensions.json
-
-# misc
-/.sass-cache
-/connect.lock
-/coverage
-/libpeerconnection.log
-npm-debug.log
-yarn-error.log
-testem.log
-/typings
-
-# System Files
-.DS_Store
-Thumbs.db
-
-projects/gui2-fw-lib/src/assets
-
-.pki/
-.cache/
diff --git a/web/gui2-fw-lib/BUILD.bazel b/web/gui2-fw-lib/BUILD.bazel
index edf04f4..b333909 100644
--- a/web/gui2-fw-lib/BUILD.bazel
+++ b/web/gui2-fw-lib/BUILD.bazel
@@ -16,6 +16,7 @@
load("@npm_angular_bazel//:index.bzl", "ng_module")
load("@npm_bazel_typescript//:index.bzl", "ts_library")
+load("@npm_bazel_karma//:index.bzl", "karma_web_test_suite")
package(default_visibility = ["//:__subpackages__"])
@@ -36,7 +37,6 @@
],
exclude = [
"**/*.spec.ts",
- "test.ts",
],
),
assets = glob([
@@ -48,6 +48,7 @@
# tsconfig = "tsconfig.json",
generate_ve_shims = True,
module_name = "gui2-fw-lib",
+ tsconfig = "//web/gui2:tsconfig.json",
deps = [
"@npm//@angular/animations",
"@npm//@angular/common",
@@ -58,128 +59,53 @@
],
)
-#filegroup(
-# name = "rxjs_umd_modules",
-# srcs = [
-# # do not sort
-# "@npm//:node_modules/rxjs/bundles/rxjs.umd.js",
-# ":rxjs_shims.js",
-# ],
-#)
-#
-#ts_library(
-# name = "test_lib",
-# testonly = 1,
-# srcs = glob(["**/*.spec.ts"]),
-# deps = [
-# ":gui2-fw-lib",
-# "@npm//@angular/common",
-# "@npm//@angular/core",
-# "@npm//@angular/platform-browser",
-# "@npm//@angular/router",
-# "@npm//@types",
-# "@npm//rxjs",
-# ],
-#)
-#
-#ts_library(
-# name = "initialize_testbed",
-# testonly = 1,
-# srcs = [
-# "initialize_testbed.ts",
-# ],
-# deps = [
-# "@npm//@angular/core",
-# "@npm//@angular/platform-browser-dynamic",
-# "@npm//@types",
-# ],
-#)
-#
-#ng_package(
-# name = "gui2-fw-lib-pkg",
-# srcs = [
-# "package.json",
-# ],
-# data = glob(
-# include = [
-# "src/assets/**",
-# ],
-# exclude = [
-# "**/*.spec.ts",
-# ],
-# ),
-# entry_point = ":src/public-api.ts", # In reality this is ignored and index.ts is used
-# # include_devmode_srcs = False,
-# readme_md = "README.md",
-# deps = [
-# ":gui2-fw-lib",
-# "@npm//@angular/animations",
-# "@npm//@angular/common",
-# "@npm//@angular/core",
-# "@npm//@angular/platform-browser-dynamic",
-# "@npm//@angular/router",
-# "@npm//@types",
-# "@npm//d3",
-# "@npm//rxjs",
-# ],
-#)
-#
-#genrule(
-# name = "onos-gui2-fw-ng-build",
-# srcs = [
-# ":gui2-fw-lib-pkg",
-# ],
-# outs = [
-# "gui2-fw-ng-build-prod.log",
-# "gui2-fw-lib-ver.tgz",
-# ],
-# cmd = "ROOT=`pwd` &&" +
-# " mkdir -p package &&" +
-# " cp -r bazel-out/k8-fastbuild/bin/web/gui2-fw-lib/projects/gui2-fw-lib/gui2-fw-lib-pkg/* package &&" +
-# " tar -czhf $$ROOT/$(location gui2-fw-lib-ver.tgz) package &&" +
-# " touch $$ROOT/$(location gui2-fw-ng-build-prod.log)", # to get the log always as the 2nd file
-# message = "GUI FW Lib build",
-# visibility = ["//visibility:public"],
-#)
-#
-#ts_web_test_suite(
-# name = "gui2-fw-lib-test",
-# srcs = [
-# "@npm//:node_modules/tslib/tslib.js",
-# ],
-# # do not sort
-# bootstrap = [
-# "@npm//:node_modules/zone.js/dist/zone-testing-bundle.js",
-# "@npm//:node_modules/reflect-metadata/Reflect.js",
-# ],
-# browsers = [
-# "@io_bazel_rules_webtesting//browsers:chromium-local",
-# ],
-# runtime_deps = [
-# ":initialize_testbed",
-# ],
-# deps = [
-# ":rxjs_umd_modules",
-# ":test_lib",
-# "@npm//karma-jasmine",
-# ],
-#)
-#
-#jdk_genrule(
-# name = "gui2_fw_lib_ext_css",
-# srcs = glob(
-# [
-# "src/lib/widget/panel.css",
-# "src/lib/widget/panel-theme.css",
-# "src/lib/widget/table.css",
-# "src/lib/widget/table.theme.css",
-# "src/lib/widget/table.theme.css",
-# "src/lib/layer/loading.service.css",
-# ],
-# ),
-# outs = ["gui2_fw_lib_css.jar"],
-# cmd = " ROOT=`pwd` &&" +
-# " cd web/gui2-fw-lib/projects/gui2-fw-lib/src/lib &&" +
-# " jar Mcf $$ROOT/$@ .",
-# visibility = ["//visibility:public"],
-#)
+ts_library(
+ name = "test_lib",
+ testonly = 1,
+ srcs = glob(
+ include = ["**/*.spec.ts"],
+ # TODO re-enable this test
+ exclude = ["lib/nav/nav.service.spec.ts"],
+ ),
+ tsconfig = "//web/gui2:tsconfig-test",
+ deps = [
+ ":gui2-fw-lib",
+ "@npm//@angular/common",
+ "@npm//@angular/core",
+ "@npm//@angular/forms",
+ "@npm//@angular/http",
+ "@npm//@angular/platform-browser",
+ "@npm//@angular/router",
+ "@npm//@types/jasmine",
+ "@npm//rxjs",
+ ],
+)
+
+karma_web_test_suite(
+ name = "test",
+ srcs = [
+ # We are manaully adding the bazel generated named-UMD d3 bundle here as
+ # named-UMD bundles for non-APF npm packages are not yet automatically added.
+ # This file is generated by the npm_umd_bundle @npm//d3
+ # rule that is setup by yarn_install.
+ ],
+ # do not sort
+ bootstrap = [
+ "@npm//:node_modules/zone.js/dist/zone-testing-bundle.js",
+ "@npm//:node_modules/reflect-metadata/Reflect.js",
+ ],
+ browsers = [
+ # "@io_bazel_rules_webtesting//browsers:chromium-local",
+ "@io_bazel_rules_webtesting//browsers:firefox-local",
+ ],
+ tags = ["native"],
+ runtime_deps = [
+ "//web/gui2/src/main/webapp:initialize_testbed",
+ ],
+ deps = [
+ ":test_lib",
+ "//web/gui:src/main/webapp/data",
+ "//web/gui2/src/main/webapp:d3_requirejs",
+ "//web/gui2/src/main/webapp:rxjs_umd_modules",
+ ],
+)
diff --git a/web/gui2-fw-lib/lib/util/fn.service.ts b/web/gui2-fw-lib/lib/util/fn.service.ts
index 6694182..60d4950 100644
--- a/web/gui2-fw-lib/lib/util/fn.service.ts
+++ b/web/gui2-fw-lib/lib/util/fn.service.ts
@@ -139,55 +139,55 @@
* properties to get these - and even then we have to filter
* out the constructor and any member variables
*/
- // areFunctions(api: Object, fnNames: string[]): boolean {
- // const fnLookup: Map<string, boolean> = new Map();
- // let extraFound: boolean = false;
- //
- // if (!this.isA(fnNames)) {
- // return false;
- // }
- //
- // const n: number = fnNames.length;
- // let i: number;
- // let name: string;
- //
- // for (i = 0; i < n; i++) {
- // name = fnNames[i];
- // if (!this.isF(api[name])) {
- // return false;
- // }
- // fnLookup.set(name, true);
- // }
- //
- // // check for properties on the API that are not listed in the array,
- // const keys = Object.getOwnPropertyNames(api);
- // if (keys.length === 0) {
- // return true;
- // }
- // // If the api is a class it will have a name,
- // // else it will just be called 'Object'
- // const apiObjectName: string = api.constructor.name;
- // if (apiObjectName === 'Object') {
- // Object.keys(api).forEach((key) => {
- // if (!fnLookup.get(key)) {
- // extraFound = true;
- // }
- // });
- // } else { // It is a class, so its functions will be in the child (prototype)
- // const pObj: Object = Object.getPrototypeOf(api);
- // for ( const key in Object.getOwnPropertyDescriptors(pObj) ) {
- // if (key === 'constructor') { // Filter out constructor
- // continue;
- // }
- // const value = Object.getOwnPropertyDescriptor(pObj, key);
- // // Only compare functions. Look for any not given in the map
- // if (this.isF(value.value) && !fnLookup.get(key)) {
- // extraFound = true;
- // }
- // }
- // }
- // return !extraFound;
- // }
+ areFunctions(api: Object, fnNames: string[]): boolean {
+ const fnLookup: Map<string, boolean> = new Map();
+ let extraFound: boolean = false;
+
+ if (!this.isA(fnNames)) {
+ return false;
+ }
+
+ const n: number = fnNames.length;
+ let i: number;
+ let name: string;
+
+ for (i = 0; i < n; i++) {
+ name = fnNames[i];
+ if (!this.isF(api[name])) {
+ return false;
+ }
+ fnLookup.set(name, true);
+ }
+
+ // check for properties on the API that are not listed in the array,
+ const keys = Object.getOwnPropertyNames(api);
+ if (keys.length === 0) {
+ return true;
+ }
+ // If the api is a class it will have a name,
+ // else it will just be called 'Object'
+ const apiObjectName: string = api.constructor.name;
+ if (apiObjectName === 'Object') {
+ Object.keys(api).forEach((key) => {
+ if (!fnLookup.get(key)) {
+ extraFound = true;
+ }
+ });
+ } else { // It is a class, so its functions will be in the child (prototype)
+ const pObj: Object = Object.getPrototypeOf(api);
+ for ( const key in Object.getOwnPropertyDescriptors(pObj) ) {
+ if (key === 'constructor') { // Filter out constructor
+ continue;
+ }
+ const value = Object.getOwnPropertyDescriptor(pObj, key);
+ // Only compare functions. Look for any not given in the map
+ if (this.isF(value.value) && !fnLookup.get(key)) {
+ extraFound = true;
+ }
+ }
+ }
+ return !extraFound;
+ }
/**
* Returns true if all names in the array are defined as functions
diff --git a/web/gui2-fw-lib/patches/@angular+bazel+9.0.0-rc.7.patch b/web/gui2-fw-lib/patches/@angular+bazel+9.0.0-rc.7.patch
deleted file mode 100644
index 89fa345..0000000
--- a/web/gui2-fw-lib/patches/@angular+bazel+9.0.0-rc.7.patch
+++ /dev/null
@@ -1,51 +0,0 @@
-diff --git a/node_modules/@angular/bazel/src/ng_package/ng_package.bzl b/node_modules/@angular/bazel/src/ng_package/ng_package.bzl
-index ccda5a5..00f1624 100755
---- a/node_modules/@angular/bazel/src/ng_package/ng_package.bzl
-+++ b/node_modules/@angular/bazel/src/ng_package/ng_package.bzl
-@@ -15,9 +15,9 @@ specification of this format at https://goo.gl/jB3GVv
-
- load("@build_bazel_rules_nodejs//:providers.bzl", "JSEcmaScriptModuleInfo", "JSNamedModuleInfo", "NpmPackageInfo", "node_modules_aspect")
- load(
-- "@build_bazel_rules_nodejs//internal/npm_package:npm_package.bzl",
-- "NPM_PACKAGE_ATTRS",
-- "NPM_PACKAGE_OUTPUTS",
-+ "@build_bazel_rules_nodejs//internal/pkg_npm:pkg_npm.bzl",
-+ "PKG_NPM_ATTRS",
-+ "PKG_NPM_OUTPUTS",
- "create_package",
- )
- load("//src:external.bzl", "FLAT_DTS_FILE_SUFFIX")
-@@ -619,7 +619,7 @@ def _ng_package_impl(ctx):
- if JSNamedModuleInfo in dep:
- devfiles = depset(transitive = [devfiles, dep[JSNamedModuleInfo].sources])
-
-- # Re-use the create_package function from the nodejs npm_package rule.
-+ # Re-use the create_package function from the nodejs pkg_npm rule.
- package_dir = create_package(
- ctx,
- devfiles.to_list(),
-@@ -631,7 +631,7 @@ def _ng_package_impl(ctx):
-
- _NG_PACKAGE_DEPS_ASPECTS = [esm5_outputs_aspect, ng_package_module_mappings_aspect, node_modules_aspect]
-
--_NG_PACKAGE_ATTRS = dict(NPM_PACKAGE_ATTRS, **{
-+_NG_PACKAGE_ATTRS = dict(PKG_NPM_ATTRS, **{
- "srcs": attr.label_list(
- doc = """JavaScript source files from the workspace.
- These can use ES2015 syntax and ES Modules (import/export)""",
-@@ -807,12 +807,12 @@ def _ng_package_outputs(name, entry_point, entry_point_name):
- "umd": "%s.umd.js" % basename,
- "umd_min": "%s.umd.min.js" % basename,
- }
-- for key in NPM_PACKAGE_OUTPUTS:
-- # NPM_PACKAGE_OUTPUTS is a "normal" dict-valued outputs so it looks like
-+ for key in PKG_NPM_OUTPUTS:
-+ # PKG_NPM_OUTPUTS is a "normal" dict-valued outputs so it looks like
- # "pack": "%{name}.pack",
- # But this is a function-valued outputs.
- # Bazel won't replace the %{name} token so we have to do it.
-- outputs[key] = NPM_PACKAGE_OUTPUTS[key].replace("%{name}", name)
-+ outputs[key] = PKG_NPM_OUTPUTS[key].replace("%{name}", name)
- return outputs
-
- ng_package = rule(
diff --git a/web/gui2-fw-lib/test.ts b/web/gui2-fw-lib/test.ts
deleted file mode 100644
index af048c5e..0000000
--- a/web/gui2-fw-lib/test.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// This file is required by karma.conf.js and loads recursively all the .spec and framework files
-
-import 'core-js/es7/reflect';
-import 'zone.js/dist/zone';
-import 'zone.js/dist/zone-testing';
-import { getTestBed } from '@angular/core/testing';
-import {
- BrowserDynamicTestingModule,
- platformBrowserDynamicTesting
-} from '@angular/platform-browser-dynamic/testing';
-
-declare const require: any;
-
-// First, initialize the Angular testing environment.
-getTestBed().initTestEnvironment(
- BrowserDynamicTestingModule,
- platformBrowserDynamicTesting()
-);
-// Then we find all the tests.
-const context = require.context('./', true, /\.spec\.ts$/);
-// And load the modules.
-context.keys().map(context);