From ded89cf6add7d7a089b3fa0c38fe0eae11515ec5 Mon Sep 17 00:00:00 2001 From: Riley Jones Date: Tue, 15 Aug 2023 18:23:40 +0000 Subject: [PATCH] remove bzl file change. Test every possible filter checkbox --- tensorboard/defs/defs.bzl | 47 +++++++++--------- .../widgets/data_table/filter_dialog_test.ts | 48 +++++++++++++------ 2 files changed, 56 insertions(+), 39 deletions(-) diff --git a/tensorboard/defs/defs.bzl b/tensorboard/defs/defs.bzl index e5aebf4ede..0be01beb93 100644 --- a/tensorboard/defs/defs.bzl +++ b/tensorboard/defs/defs.bzl @@ -22,6 +22,7 @@ load("@npm//@bazel/concatjs:index.bzl", "karma_web_test_suite", "ts_library") load("@npm//@bazel/esbuild:index.bzl", "esbuild") load("@npm//@bazel/typescript:index.bzl", "ts_config") + def tensorboard_webcomponent_library(**kwargs): """Rules referencing this will be deleted from the codebase soon.""" pass @@ -71,8 +72,8 @@ def tf_js_binary( # the global level and tends to overwrite `window` functions. "iife" is # just a thin wrapper around "esm" (it adds 11 bytes) and doesn't # suffer from the same overwriting problem. - format = "iife", - minify = False if dev_mode_only else True, + format="iife", + minify= False if dev_mode_only else True, args = { # Must specify that 'mjs' extensions are preferred, since that is # the extension that is used for es2015/esm code generated by @@ -90,6 +91,7 @@ def tf_js_binary( **kwargs ) + def tf_ng_prod_js_binary( name, compile, @@ -112,7 +114,7 @@ def tf_ng_prod_js_binary( https://esbuild.github.io/api/ for more details. """ - app_bundle_name = "%s_app_bundle" % name + app_bundle_name = '%s_app_bundle' % name app_bundle( name = app_bundle_name, **kwargs @@ -122,8 +124,8 @@ def tf_ng_prod_js_binary( # through a terser pass to be the output of this rule. copy_file( name = name, - src = "%s.min.js" % app_bundle_name, - out = "%s.js" % name, + src = '%s.min.js' % app_bundle_name, + out = '%s.js' % name, ) def tf_ts_config(**kwargs): @@ -146,24 +148,22 @@ def tf_ts_library(srcs = [], strict_checks = True, **kwargs): kwargs.setdefault("deps", []).extend(["@npm//tslib", "//tensorboard/defs:strict_types"]) new_srcs = [] - # Find test.ts and testbed.ts files and rename to test.spec.ts to be # compatible with spec_bundle() tooling. for s in srcs: - if s.endswith("_test.ts") or s.endswith("-test.ts") or s.endswith("_testbed.ts"): - # Make a copy of the file with name .spec.ts and switch to that as - # the src file. - new_src = s[0:s.rindex(".ts")] + ".spec.ts" - copy_file( - name = new_src + "_spec_copy", - src = s, - out = new_src, - allow_symlink = True, - ) - new_srcs.append(new_src) - else: - # Not a test file. Nothing to do here. - new_srcs.append(s) + if s.endswith("_test.ts") or s.endswith("-test.ts") or s.endswith("_testbed.ts"): + # Make a copy of the file with name .spec.ts and switch to that as + # the src file. + new_src = s[0:s.rindex('.ts')] + ".spec.ts" + copy_file( + name = new_src + '_spec_copy', + src = s, + out = new_src, + allow_symlink = True) + new_srcs.append(new_src) + else: + # Not a test file. Nothing to do here. + new_srcs.append(s) ts_library( srcs = new_srcs, @@ -176,8 +176,7 @@ def tf_ts_library(srcs = [], strict_checks = True, **kwargs): prodmode_target = "es2020", devmode_target = "es2020", devmode_module = "esnext", - **kwargs - ) + **kwargs) def tf_ng_web_test_suite(name, deps = [], **kwargs): """TensorBoard wrapper for the rule for a Karma web test suite. @@ -232,7 +231,7 @@ def tf_ng_web_test_suite(name, deps = [], **kwargs): # karma_web_test_suite() will rebundle it along with the test framework # in a CommonJS bundle. deps = [ - "%s_bundle" % name, + "%s_bundle" % name, ], ) @@ -257,7 +256,7 @@ def tf_sass_binary(deps = [], include_paths = [], strict_deps = True, **kwargs): internally. """ if (strict_deps): - fail("all tf_sass_binary calls need to have the strict_deps = False override for internal calls") + fail("all tf_sass_binary calls need to have the strict_deps = False override for internal calls"); sass_binary( deps = deps, include_paths = include_paths + [ diff --git a/tensorboard/webapp/widgets/data_table/filter_dialog_test.ts b/tensorboard/webapp/widgets/data_table/filter_dialog_test.ts index 1dfe1ce026..c40bcb4f5b 100644 --- a/tensorboard/webapp/widgets/data_table/filter_dialog_test.ts +++ b/tensorboard/webapp/widgets/data_table/filter_dialog_test.ts @@ -135,9 +135,7 @@ describe('filter dialog', () => { filterValues: [2, 4, 6], }, }); - const checkboxes = await rootLoader.getAllHarnesses( - MatCheckboxHarness.with() - ); + const checkboxes = await rootLoader.getAllHarnesses(MatCheckboxHarness); const checkboxLabels = await Promise.all( checkboxes.map((checkbox) => checkbox.getLabelText()) @@ -146,11 +144,12 @@ describe('filter dialog', () => { }); it('dispatches event when an discrete filter value is changed', async () => { + const possibleValues = [2, 4, 6, 8]; const fixture = createComponent({ filter: { type: DomainType.DISCRETE, includeUndefined: false, - possibleValues: [2, 4, 6, 8], + possibleValues, filterValues: [2, 4, 6], }, }); @@ -158,21 +157,40 @@ describe('filter dialog', () => { spyOn(fixture.componentInstance.discreteFilterChanged, 'emit').and.callFake( (value: DiscreteFilterValue) => filterValues.push(value) ); - let checkbox = await rootLoader.getHarness( - MatCheckboxHarness.with({label: '2'}) - ); - await checkbox.uncheck(); + + for (const value of possibleValues) { + const checkbox = await rootLoader.getHarness( + MatCheckboxHarness.with({label: `${value}`}) + ); + await checkbox.uncheck(); + } + expect(filterValues).toEqual([2, 4, 6]); // Unchecking an unchecked box should not trigger an event. - await checkbox.uncheck(); + for (const value of possibleValues) { + const checkbox = await rootLoader.getHarness( + MatCheckboxHarness.with({label: `${value}`}) + ); + await checkbox.uncheck(); + } + expect(filterValues).toEqual([2, 4, 6]); - await checkbox.check(); - checkbox = await rootLoader.getHarness( - MatCheckboxHarness.with({label: '4'}) - ); - await checkbox.uncheck(); + for (const value of possibleValues) { + const checkbox = await rootLoader.getHarness( + MatCheckboxHarness.with({label: `${value}`}) + ); + await checkbox.check(); + } + expect(filterValues).toEqual([2, 4, 6, 2, 4, 6, 8]); - expect(filterValues).toEqual([2, 2, 4]); + // Checking a checked box should not trigger an event. + for (const value of possibleValues) { + const checkbox = await rootLoader.getHarness( + MatCheckboxHarness.with({label: `${value}`}) + ); + await checkbox.check(); + } + expect(filterValues).toEqual([2, 4, 6, 2, 4, 6, 8]); }); it('dispatches an event when include undefined is changed while viewing a discrete filter', async () => {