Skip to content

Commit ed5e9d0

Browse files
authored
Update tests in preparation for Angular 13 upgrade. (#6056)
The upcoming upgrade to Angular 13 (and related libraries) requires some modifications to tests that we can make pre-upgrade. 1. ngrx can no longer automatically reset selectors that have been modified with overrideSelector() call. We must now call store.resetSelectors() after each test. * See: ngrx/platform#3264 (comment) 2. The upgrade has exposed a latent test bug. In one of the tests there is the potential to refresh the window with a call to `window.location.refresh()`. After the Angular 13 upgrade the refresh actually happens and the test karma runner fails and complains "Some of your tests did a full page reload!". The fix is to mock out the call to `window.location.refresh()`.
1 parent 888dcdc commit ed5e9d0

File tree

65 files changed

+265
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+265
-4
lines changed

tensorboard/components/experimental/plugin_util/plugin_api_host_test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ describe('plugin_api_host test', () => {
6161
runApi = TestBed.inject(PluginRunsApiHostImpl);
6262
});
6363

64+
afterEach(() => {
65+
store?.resetSelectors();
66+
});
67+
6468
describe('runs apis', () => {
6569
describe('#experimental.RunsChanged', () => {
6670
it('broadcasts runs when runs change', () => {

tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/effects/debugger_effects_test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ describe('Debugger effects', () => {
395395
store.overrideSelector(getActivePlugin, '');
396396
});
397397

398+
afterEach(() => {
399+
store?.resetSelectors();
400+
});
401+
398402
function createAndSubscribeToDebuggerEffectsWithEmptyRepeater() {
399403
spyOn(TEST_ONLY, 'createTimedRepeater').and.callFake(
400404
(stream: Observable<any>) => stream

tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/views/graph/graph_container_test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ describe('Graph Container', () => {
5656
dispatchSpy = spyOn(store, 'dispatch');
5757
});
5858

59+
afterEach(() => {
60+
store?.resetSelectors();
61+
});
62+
5963
it('renders no-op-selected element and nothing else when no op is selected', () => {
6064
const fixture = TestBed.createComponent(GraphContainer);
6165
store.overrideSelector(getFocusedGraphOpInfo, null);

tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/views/graph_executions/graph_executions_container_test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ describe('Graph Executions Container', () => {
8787
store = TestBed.inject<Store<State>>(Store) as MockStore<State>;
8888
});
8989

90+
afterEach(() => {
91+
store?.resetSelectors();
92+
});
93+
9094
it('does not render execs viewport if # execs = 0', fakeAsync(() => {
9195
const fixture = TestBed.createComponent(GraphExecutionsContainer);
9296
store.overrideSelector(getNumGraphExecutions, 0);

tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/views/source_files/source_files_container_test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ describe('Source Files Container', () => {
7575

7676
afterEach(() => {
7777
tearDownMonacoFakes();
78+
store?.resetSelectors();
7879
});
7980

8081
it('renders no file selected when no source line is focused on', () => {

tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/views/stack_trace/stack_trace_container_test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ describe('Stack Trace container', () => {
5858
dispatchSpy = spyOn(store, 'dispatch');
5959
});
6060

61+
afterEach(() => {
62+
store?.resetSelectors();
63+
});
64+
6165
for (const stickToBottommostFrame of [false, true]) {
6266
it(
6367
`shows non-empty eager stack frames; highlights focused frame: ` +

tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/views/timeline/timeline_container_test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ describe('Timeline Container', () => {
9191
dispatchSpy = spyOn(store, 'dispatch');
9292
});
9393

94+
afterEach(() => {
95+
store?.resetSelectors();
96+
});
97+
9498
it('shows total number of executions', () => {
9599
const fixture = TestBed.createComponent(TimelineContainer);
96100
fixture.detectChanges();

tensorboard/webapp/alert/views/alert_snackbar_test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ describe('alert snackbar', () => {
6666

6767
afterEach(() => {
6868
snackbar.dismiss();
69+
store?.resetSelectors();
6970
});
7071

7172
it('opens the snackbar on each alert', () => {

tensorboard/webapp/app_routing/effects/app_routing_effects_test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ describe('app_routing_effects', () => {
250250
);
251251
});
252252

253+
afterEach(() => {
254+
store?.resetSelectors();
255+
});
256+
253257
describe('bootstrapReducers$', () => {
254258
beforeEach(() => {
255259
effects = TestBed.inject(AppRoutingEffects);

tensorboard/webapp/app_routing/views/router_outlet_test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ describe('router_outlet', () => {
7474
getNgComponentByRouteKindSpy = spyOn(registry, 'getNgComponentByRouteKind');
7575
});
7676

77+
afterEach(() => {
78+
store?.resetSelectors();
79+
});
80+
7781
function setActiveRoute(routeKind: RouteKind) {
7882
store.overrideSelector(
7983
getActiveRoute,

0 commit comments

Comments
 (0)