Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions tensorboard/components/tf_tensorboard/test/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package(
default_testonly = True,
default_visibility = ["//tensorboard:internal"],
)

load("//tensorboard/defs:web.bzl", "tf_web_library", "tf_web_test")

licenses(["notice"]) # Apache 2.0

tf_web_test(
name = "test",
src = "/tf-tensorboard/test/tests.html",
web_library = ":test_web_library",
)

tf_web_library(
name = "test_web_library",
srcs = [
"autoReloadTests.ts",
"tensorboardTests.ts",
"tests.html",
],
path = "/tf-tensorboard/test",
deps = [
"//tensorboard/components:analytics",
"//tensorboard/components/tf_imports:polymer",
"//tensorboard/components/tf_imports:web_component_tester",
"//tensorboard/components/tf_tensorboard",
],
)
30 changes: 0 additions & 30 deletions tensorboard/components/tf_tensorboard/test/index.html

This file was deleted.

32 changes: 28 additions & 4 deletions tensorboard/components/tf_tensorboard/test/tensorboardTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
namespace tf_tensorboard {
const {expect} = chai;

declare function fixture(id: string): void;
declare const Polymer: any;

function checkSlottedUnderAncestor(element: Element, ancestor: Element) {
expect(!!element.assignedSlot).to.be.true;

const slot = element.assignedSlot as Element;
const isContained = Polymer.dom(ancestor).deepContains(slot);
expect(isContained).to.be.true;
}

describe('tf-tensorboard tests', () => {
window.HTMLImports.whenReady(() => {
let tensorboard: any;
Expand All @@ -23,11 +36,20 @@ namespace tf_tensorboard {
});

it('renders injected content', function() {
let injected = tensorboard.querySelector('#inject-me');
chai.assert.isNotNull(injected);
const overview = tensorboard.querySelector('#custom-overview');
const contentPane = tensorboard.$$('#content-pane');
checkSlottedUnderAncestor(overview, contentPane);

const headerItem1 = tensorboard.querySelector('#custom-header-item1');
const headerItem2 = tensorboard.querySelector('#custom-header-item2');
const header = tensorboard.$$('.header');
checkSlottedUnderAncestor(headerItem1, header);
checkSlottedUnderAncestor(headerItem2, header);
});

it('reloads the active dashboard on request', (done) => {
// TODO(psybuzz): Restore/remove these old tests, which fail due to broken
// DOM ids that changed. Previously this folder's tests did not run.
xit('reloads the active dashboard on request', (done) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer to accompany skipped tests with a reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xdescribe, too. if you think they are stale, maybe just omit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - added to xdescribe

tensorboard.$.tabs.set('selected', 'scalars');
setTimeout(() => {
let called = false;
Expand All @@ -40,7 +62,9 @@ namespace tf_tensorboard {
});
});

describe('top right global icons', function() {
// TODO(psybuzz): Restore/remove these old tests, which fail due to broken
// DOM ids that changed. Previously this folder's tests did not run.
xdescribe('top right global icons', function() {
it('Clicking the reload button will call reload', function() {
let called = false;
tensorboard.reload = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,21 @@
<html>
<head>
<link rel="import" href="../../tf-imports/polymer.html" />
<script
jscomp-nocompile
src="../../webcomponentsjs/webcomponents-lite.js"
></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../../analytics.html" />
<link rel="import" href="../tf-tensorboard.html" />
<link rel="stylesheet" type="text/css" href="../../../lib/css/global.css" />
</head>
<body>
<test-fixture id="tensorboardFixture">
<template>
<tf-tensorboard>
<span id="inject-me"
<span id="custom-overview" slot="injected-overview"
>Injected content should be rendered by the element.</span
>
<span id="custom-header-item1" slot="injected-header-items"
>Injected content should be rendered by the element.</span
>
<span id="custom-header-item2" slot="injected-header-items"
>Injected content should be rendered by the element.</span
>
</tf-tensorboard>
Expand Down
4 changes: 3 additions & 1 deletion tensorboard/components/tf_tensorboard/tf-tensorboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ <h2>Settings</h2>
</template>
</template>
<div class="global-actions">
<slot name="injected-header-items"></slot>
<paper-icon-button
id="reload-button"
class$="[[_getDataRefreshingClass(_refreshing)]]"
Expand All @@ -154,7 +155,7 @@ <h2>Settings</h2>
</paper-toolbar>

<div id="content-pane" class="fit">
<slot id="injected-overview"></slot>
<slot name="injected-overview"></slot>
<div id="content">
<template is="dom-if" if="[[_activeDashboardsFailedToLoad]]">
<div class="warning-message">
Expand Down Expand Up @@ -348,6 +349,7 @@ <h3>
.global-actions {
display: inline-flex; /* Ensure that icons stay aligned */
justify-content: flex-end;
align-items: center;
text-align: right;
color: white;
}
Expand Down