From 0249ab4df5af278814d716a145042b0b04472eae Mon Sep 17 00:00:00 2001 From: Jamie V Date: Fri, 22 Oct 2021 10:54:46 -0700 Subject: [PATCH] [StackedPlots] Destroy programmatically created component instances (#4345) --- src/plugins/plot/pluginSpec.js | 29 ++++--------------- src/plugins/plot/stackedPlot/StackedPlot.vue | 5 +--- .../plot/stackedPlot/StackedPlotItem.vue | 5 ++++ 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/src/plugins/plot/pluginSpec.js b/src/plugins/plot/pluginSpec.js index 74895af1ba..16b77f2e89 100644 --- a/src/plugins/plot/pluginSpec.js +++ b/src/plugins/plot/pluginSpec.js @@ -37,7 +37,6 @@ describe("the plugin", function () { let openmct; let telemetryPromise; let telemetryPromiseResolve; - let cleanupFirst; let mockObjectPath; let telemetrylimitProvider; @@ -77,7 +76,6 @@ describe("the plugin", function () { 'some-other-key': 'some-other-value 3' } ]; - cleanupFirst = []; const timeSystem = { timeSystemKey: 'utc', @@ -168,19 +166,13 @@ describe("the plugin", function () { }); afterEach((done) => { - // Needs to be in a timeout because plots use a bunch of setTimeouts, some of which can resolve during or after - // teardown, which causes problems - // This is hacky, we should find a better approach here. - setTimeout(() => { - //Cleanup code that needs to happen before dom elements start being destroyed - cleanupFirst.forEach(cleanup => cleanup()); - cleanupFirst = []; - document.body.removeChild(element); - - configStore.deleteAll(); - - resetApplicationState(openmct).then(done).catch(done); + openmct.time.timeSystem('utc', { + start: 0, + end: 1 }); + + configStore.deleteAll(); + resetApplicationState(openmct).then(done).catch(done); }); describe("the plot views", () => { @@ -393,10 +385,6 @@ describe("the plugin", function () { plotView = plotViewProvider.view(testTelemetryObject, [testTelemetryObject]); plotView.show(child, true); - cleanupFirst.push(() => { - plotView.destroy(); - }); - return Vue.nextTick(); }); @@ -759,11 +747,6 @@ describe("the plugin", function () { template: "" }); - cleanupFirst.push(() => { - component.$destroy(); - component = undefined; - }); - return telemetryPromise .then(Vue.nextTick()) .then(() => { diff --git a/src/plugins/plot/stackedPlot/StackedPlot.vue b/src/plugins/plot/stackedPlot/StackedPlot.vue index 146989c835..cfa262cab1 100644 --- a/src/plugins/plot/stackedPlot/StackedPlot.vue +++ b/src/plugins/plot/stackedPlot/StackedPlot.vue @@ -69,7 +69,7 @@