[StackedPlots] Destroy programmatically created component instances (#4345)

This commit is contained in:
Jamie V 2021-10-22 10:54:46 -07:00 committed by GitHub
parent 4f8cba160d
commit 0249ab4df5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 27 deletions

View File

@ -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: "<stacked-plot></stacked-plot>"
});
cleanupFirst.push(() => {
component.$destroy();
component = undefined;
});
return telemetryPromise
.then(Vue.nextTick())
.then(() => {

View File

@ -69,7 +69,7 @@
</template>
<script>
import eventHelpers from '../lib/eventHelpers';
import StackedPlotItem from './StackedPlotItem.vue';
import ImageExporter from '../../../exporters/ImageExporter';
@ -104,8 +104,6 @@ export default {
this.destroy();
},
mounted() {
eventHelpers.extend(this);
this.imageExporter = new ImageExporter(this.openmct);
this.tickWidthMap = {};
@ -120,7 +118,6 @@ export default {
this.loading = loaded;
},
destroy() {
this.stopListening();
this.composition.off('add', this.addChild);
this.composition.off('remove', this.removeChild);
this.composition.off('reorder', this.compositionReorder);

View File

@ -75,6 +75,11 @@ export default {
mounted() {
this.updateView();
},
beforeDestroy() {
if (this.component) {
this.component.$destroy();
}
},
methods: {
updateComponentProp(prop, value) {
if (this.component) {