Skip to content

Commit

Permalink
remove bzl file change. Test every possible filter checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
rileyajones committed Aug 15, 2023
1 parent 1e47e93 commit ded89cf
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 39 deletions.
47 changes: 23 additions & 24 deletions tensorboard/defs/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -90,6 +91,7 @@ def tf_js_binary(
**kwargs
)


def tf_ng_prod_js_binary(
name,
compile,
Expand All @@ -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
Expand All @@ -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):
Expand All @@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -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,
],
)

Expand All @@ -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 + [
Expand Down
48 changes: 33 additions & 15 deletions tensorboard/webapp/widgets/data_table/filter_dialog_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -146,33 +144,53 @@ 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],
},
});
const filterValues: DiscreteFilterValue[] = [];
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 () => {
Expand Down

0 comments on commit ded89cf

Please sign in to comment.