@@ -47,6 +47,19 @@ function expectPluginIframe(element: HTMLElement, name: string) {
47
47
) ;
48
48
}
49
49
50
+ class TestableCustomElement extends HTMLElement {
51
+ constructor ( ) {
52
+ super ( ) ;
53
+
54
+ const shadow = this . attachShadow ( { mode : 'open' } ) ;
55
+ const wrapper = document . createElement ( 'div' ) ;
56
+ wrapper . textContent = 'Test TensorBoard' ;
57
+ shadow . appendChild ( wrapper ) ;
58
+ }
59
+ }
60
+
61
+ customElements . define ( 'tb-bar' , TestableCustomElement ) ;
62
+
50
63
describe ( 'plugins_component' , ( ) => {
51
64
let store : MockStore < State > ;
52
65
const PLUGINS = {
@@ -163,9 +176,9 @@ describe('plugins_component', () => {
163
176
expect ( nativeElement . childElementCount ) . toBe ( 2 ) ;
164
177
const [ fooElement , barElement ] = nativeElement . children ;
165
178
expectPluginIframe ( fooElement , 'foo' ) ;
166
- expect ( fooElement . style . display ) . toBe ( 'none ' ) ;
179
+ expect ( fooElement . style . visibility ) . toBe ( 'hidden ' ) ;
167
180
expect ( barElement . tagName ) . toBe ( 'TB-BAR' ) ;
168
- expect ( barElement . style . display ) . not . toBe ( 'none ' ) ;
181
+ expect ( barElement . style . visibility ) . not . toBe ( 'hidden ' ) ;
169
182
} ) ;
170
183
171
184
it ( 'does not create same instance of plugin' , async ( ) => {
@@ -189,9 +202,9 @@ describe('plugins_component', () => {
189
202
190
203
const { nativeElement} = fixture . debugElement . query ( By . css ( '.plugins' ) ) ;
191
204
expect ( nativeElement . childElementCount ) . toBe ( 2 ) ;
192
- const [ fooElement , barElement ] = nativeElement . children ;
205
+ const [ fooElement ] = nativeElement . children ;
193
206
expectPluginIframe ( fooElement , 'foo' ) ;
194
- expect ( fooElement . style . display ) . not . toBe ( 'none ' ) ;
207
+ expect ( fooElement . style . visibility ) . not . toBe ( 'hidden ' ) ;
195
208
} ) ;
196
209
197
210
it ( 'creates components for plugins registered dynamically' , async ( ) => {
@@ -208,6 +221,25 @@ describe('plugins_component', () => {
208
221
const pluginElement = nativeElement . children [ 0 ] ;
209
222
expect ( pluginElement . tagName ) . toBe ( 'EXTRA-DASHBOARD' ) ;
210
223
} ) ;
224
+
225
+ it ( 'hides inactive plugin but keeps their width' , async ( ) => {
226
+ setActivePlugin ( 'bar' ) ;
227
+
228
+ const fixture = TestBed . createComponent ( PluginsContainer ) ;
229
+ fixture . detectChanges ( ) ;
230
+
231
+ setActivePlugin ( 'foo' ) ;
232
+ fixture . detectChanges ( ) ;
233
+
234
+ const { nativeElement} = fixture . debugElement . query ( By . css ( '.plugins' ) ) ;
235
+ const [ barElement ] = nativeElement . children ;
236
+ expect ( barElement . shadowRoot . firstElementChild . textContent ) . toBe (
237
+ 'Test TensorBoard'
238
+ ) ;
239
+ expect (
240
+ barElement . shadowRoot . firstElementChild . clientWidth
241
+ ) . toBeGreaterThan ( 0 ) ;
242
+ } ) ;
211
243
} ) ;
212
244
213
245
describe ( 'updates' , ( ) => {
0 commit comments