Skip to content

Commit

Permalink
chore: remove vue/compat and complete Vue 3 migration (#7133)
Browse files Browse the repository at this point in the history
* chore: remove custom `compatConfig` settings

* chore: remove `vue-compat` and adjust webpack config

* chore: explicitly define Vue feature flags

* fix: `_data` property moved to `_.data`

* fix(e2e): revert to original test procedures

* refactor: replace final instances of `$set`

* refactor: remove `Vue` imports from tests

* refactor: `Vue.ref()` -> `ref()`

* refactor: actually push the changes...

* test: replace unit test with e2e test

* test: remove test as it's already covered by e2e

* fix(test): use `$ref`s instead of `$children`

* test(fix): more `$refs`

* fix(test): more `$refs`

* fix(test): use `$refs` in InspectorStyles tests

* fix(SearchComponent): use `$attrs` correctly

---------

Co-authored-by: Scott Bell <[email protected]>
  • Loading branch information
ozyx and scottbell authored Oct 19, 2023
1 parent 1414f54 commit 43338f3
Show file tree
Hide file tree
Showing 51 changed files with 436 additions and 471 deletions.
14 changes: 6 additions & 8 deletions .webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,17 @@ const config = {
MCT: path.join(projectRootDir, 'src/MCT'),
testUtils: path.join(projectRootDir, 'src/utils/testUtils.js'),
objectUtils: path.join(projectRootDir, 'src/api/objects/object-utils.js'),
utils: path.join(projectRootDir, 'src/utils'),
vue: path.join(projectRootDir, 'node_modules/@vue/compat/dist/vue.esm-bundler.js'),
utils: path.join(projectRootDir, 'src/utils')
}
},
plugins: [
new webpack.DefinePlugin({
__OPENMCT_VERSION__: `'${packageDefinition.version}'`,
__OPENMCT_BUILD_DATE__: `'${new Date()}'`,
__OPENMCT_REVISION__: `'${gitRevision}'`,
__OPENMCT_BUILD_BRANCH__: `'${gitBranch}'`
__OPENMCT_BUILD_BRANCH__: `'${gitBranch}'`,
__VUE_OPTIONS_API__: true, // enable/disable Options API support, default: true
__VUE_PROD_DEVTOOLS__: false // enable/disable devtools support in production, default: false
}),
new VueLoaderPlugin(),
new CopyWebpackPlugin({
Expand Down Expand Up @@ -115,7 +116,7 @@ const config = {
new webpack.BannerPlugin({
test: /.*Theme\.css$/,
raw: true,
banner: '@charset "UTF-8";',
banner: '@charset "UTF-8";'
})
],
module: {
Expand All @@ -142,10 +143,7 @@ const config = {
options: {
compilerOptions: {
hoistStatic: false,
whitespace: 'preserve',
compatConfig: {
MODE: 2
}
whitespace: 'preserve'
}
}
},
Expand Down
59 changes: 59 additions & 0 deletions e2e/tests/functional/clearDataAction.e2e.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/

/*
Verify that the "Clear Data" menu action performs as expected for various object types.
*/

const { test, expect } = require('../../pluginFixtures.js');
const { createDomainObjectWithDefaults } = require('../../appActions.js');

const backgroundImageSelector = '.c-imagery__main-image__background-image';

test.describe('Clear Data Action', () => {
test.beforeEach(async ({ page }) => {
// Go to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' });

// Create a default 'Example Imagery' object
const exampleImagery = await createDomainObjectWithDefaults(page, { type: 'Example Imagery' });

// Verify that the created object is focused
await expect(page.locator('.l-browse-bar__object-name')).toContainText(exampleImagery.name);
await page.locator('.c-imagery__main-image__bg').hover({ trial: true });
await expect(page.locator(backgroundImageSelector)).toBeVisible();
});
test('works as expected with Example Imagery', async ({ page }) => {
await expect(await page.locator('.c-thumb__image').count()).toBeGreaterThan(0);
// Click the "Clear Data" menu action
await page.getByTitle('More options').click();
const clearDataMenuItem = page.getByRole('menuitem', {
name: 'Clear Data'
});
await expect(clearDataMenuItem).toBeEnabled();
await clearDataMenuItem.click();

// Verify that the background image is no longer visible
await expect(page.locator(backgroundImageSelector)).toBeHidden();
await expect(await page.locator('.c-thumb__image').count()).toBe(0);
});
});
4 changes: 2 additions & 2 deletions e2e/tests/functional/search.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ test.describe('Grand Search', () => {

// Click [aria-label="OpenMCT Search"] a >> nth=0
await page.locator('[aria-label="Search Result"] >> nth=0').click();
await expect(page.locator('[aria-label="Search Result"] >> nth=0')).toBeInViewport();
await expect(page.locator('[aria-label="Search Result"] >> nth=0')).toBeHidden();

// Fill [aria-label="OpenMCT Search"] input[type="search"]
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('foo');
await expect(page.locator('[aria-label="Search Result"] >> nth=0')).not.toBeInViewport();
await expect(page.locator('[aria-label="Search Result"] >> nth=0')).toBeHidden();

// Click text=Snapshot Save and Finish Editing Save and Continue Editing >> button >> nth=1
await page
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"@types/eventemitter3": "1.2.0",
"@types/jasmine": "4.3.4",
"@types/lodash": "4.14.192",
"@vue/compat": "3.3.4",
"@vue/compiler-sfc": "3.3.4",
"babel-loader": "9.1.0",
"babel-plugin-istanbul": "6.1.1",
Expand Down
4 changes: 2 additions & 2 deletions src/api/menu/MenuAPISpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/

import Vue from 'vue';
import { nextTick } from 'vue';

import { createMouseEvent, createOpenMct, resetApplicationState } from '../../utils/testing';
import Menu from './menu';
Expand Down Expand Up @@ -186,7 +186,7 @@ describe('The Menu API', () => {
superMenuItem.dispatchEvent(mouseOverEvent);
const itemDescription = document.querySelector('.l-item-description__description');

Vue.nextTick(() => {
nextTick(() => {
expect(menuElement).not.toBeNull();
expect(itemDescription.innerText).toEqual(actionsArray[0].description);

Expand Down
10 changes: 0 additions & 10 deletions src/api/menu/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ class Menu extends EventEmitter {
},
provide: {
options: this.options
},
// TODO: Remove this exception upon full migration to Vue 3
// https://v3-migration.vuejs.org/breaking-changes/render-function-api.html#render-function-argument
compatConfig: {
RENDER_FUNCTION: false
}
});

Expand All @@ -98,11 +93,6 @@ class Menu extends EventEmitter {
},
provide: {
options: this.options
},
// TODO: Remove this exception upon full migration to Vue 3
// https://v3-migration.vuejs.org/breaking-changes/render-function-api.html#render-function-argument
compatConfig: {
RENDER_FUNCTION: false
}
});

Expand Down
6 changes: 1 addition & 5 deletions src/plugins/LADTable/components/LadTableSet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,7 @@ export default {
reorderLadTables(reorderPlan) {
let oldComposition = this.ladTableObjects.slice();
reorderPlan.forEach((reorderEvent) => {
this.$set(
this.ladTableObjects,
reorderEvent.newIndex,
oldComposition[reorderEvent.oldIndex]
);
this.ladTableObjects[reorderEvent.newIndex] = oldComposition[reorderEvent.oldIndex];
});
},
addTelemetryObject(ladTable) {
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/LADTable/pluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
resetApplicationState,
spyOnBuiltins
} from 'utils/testing';
import Vue from 'vue';
import { nextTick } from 'vue';

import LadPlugin from './plugin.js';

Expand Down Expand Up @@ -233,7 +233,7 @@ describe('The LAD Table', () => {
anotherTelemetryObjectPromise,
aggregateTelemetryObjectResolve
]);
await Vue.nextTick();
await nextTick();
});

it('should show one row per object in the composition', () => {
Expand All @@ -244,7 +244,7 @@ describe('The LAD Table', () => {
it('should show the most recent datum from the telemetry producing object', async () => {
const latestDatum = getLatestTelemetry(mockTelemetry, { timeFormat });
const expectedDate = utcTimeFormat(latestDatum[timeFormat]);
await Vue.nextTick();
await nextTick();
const latestDate = parent.querySelector(TABLE_BODY_FIRST_ROW_SECOND_DATA).innerText;
expect(latestDate).toBe(expectedDate);
const dataType = parent
Expand All @@ -254,7 +254,7 @@ describe('The LAD Table', () => {
});

it('should show aggregate telemetry type with blank data', async () => {
await Vue.nextTick();
await nextTick();
const latestData = parent
.querySelectorAll(TABLE_BODY_ROWS)[1]
.querySelectorAll('td')[2].innerText;
Expand Down Expand Up @@ -282,7 +282,7 @@ describe('The LAD Table', () => {
const mostRecentTelemetry = getLatestTelemetry(mockTelemetry, { timeFormat });
const rangeValue = mostRecentTelemetry[range];
const domainValue = utcTimeFormat(mostRecentTelemetry[domain]);
await Vue.nextTick();
await nextTick();
const actualDomainValue = parent.querySelector(TABLE_BODY_FIRST_ROW_SECOND_DATA).innerText;
const actualRangeValue = parent.querySelector(TABLE_BODY_FIRST_ROW_THIRD_DATA).innerText;
expect(actualRangeValue).toBe(rangeValue);
Expand Down Expand Up @@ -424,7 +424,7 @@ describe('The LAD Table Set', () => {
ladTableSetView = ladTableSetViewProvider.view(mockObj.ladTableSet, [mockObj.ladTableSet]);
ladTableSetView.show(child);

return Vue.nextTick();
return nextTick();
});

it('should show one row per lad table object in the composition', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/autoflow/AutoflowTabularPluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
import { createOpenMct, resetApplicationState, spyOnBuiltins } from 'utils/testing';
import Vue from 'vue';
import { nextTick } from 'vue';

import AutoflowTabularConstants from './AutoflowTabularConstants';
import AutoflowTabularPlugin from './AutoflowTabularPlugin';
Expand Down Expand Up @@ -175,7 +175,7 @@ xdescribe('AutoflowTabularPlugin', () => {
view = provider.view(testObject, [testObject]);
view.show(testContainer);

return Vue.nextTick();
return nextTick();
});

afterEach(() => {
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/charts/bar/pluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// import BarGraph from './BarGraphPlot.vue';
import EventEmitter from 'EventEmitter';
import { createOpenMct, resetApplicationState } from 'utils/testing';
import Vue from 'vue';
import { nextTick } from 'vue';

import { BAR_GRAPH_INSPECTOR_KEY, BAR_GRAPH_KEY, BAR_GRAPH_VIEW } from './BarGraphConstants';
import BarGraphPlugin from './plugin';
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('the plugin', function () {

spyOn(openmct.composition, 'get').and.returnValue(mockComposition);

await Vue.nextTick();
await nextTick();
});

it('provides a bar graph view', () => {
Expand Down Expand Up @@ -254,7 +254,7 @@ describe('the plugin', function () {

spyOn(openmct.composition, 'get').and.returnValue(mockComposition);

await Vue.nextTick();
await nextTick();
});

it('Renders spectral plots', async () => {
Expand Down Expand Up @@ -305,8 +305,8 @@ describe('the plugin', function () {
barGraphView.show(child, true);
mockComposition.emit('add', dotFullTelemetryObject);

await Vue.nextTick();
await Vue.nextTick();
await nextTick();
await nextTick();

const plotElement = element.querySelector('.cartesianlayer .scatterlayer .trace .lines');
expect(plotElement).not.toBeNull();
Expand Down Expand Up @@ -581,7 +581,7 @@ describe('the plugin', function () {
plotInspectorView = applicableViews.filter((view) => view.key === BAR_GRAPH_INSPECTOR_KEY)[0];
plotInspectorView.show(viewContainer);

await Vue.nextTick();
await nextTick();
optionsElement = element.querySelector('.c-bar-graph-options');
});

Expand Down
6 changes: 3 additions & 3 deletions src/plugins/charts/scatter/pluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import EventEmitter from 'EventEmitter';
import { createOpenMct, resetApplicationState } from 'utils/testing';
import Vue from 'vue';
import { nextTick } from 'vue';

import ScatterPlotPlugin from './plugin';
import { SCATTER_PLOT_KEY, SCATTER_PLOT_VIEW } from './scatterPlotConstants';
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('the plugin', function () {

spyOn(openmct.composition, 'get').and.returnValue(mockComposition);

await Vue.nextTick();
await nextTick();
});

it('provides a scatter plot view', () => {
Expand Down Expand Up @@ -406,7 +406,7 @@ describe('the plugin', function () {
plotInspectorView = applicableViews[0];
plotInspectorView.show(viewContainer);

await Vue.nextTick();
await nextTick();
optionsElement = element.querySelector('.c-scatter-plot-options');
});

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/clearData/pluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*****************************************************************************/

import { createMouseEvent, createOpenMct, resetApplicationState } from 'utils/testing';
import Vue from 'vue';
import { nextTick } from 'vue';

import ClearDataPlugin from './plugin.js';

Expand Down Expand Up @@ -213,7 +213,7 @@ describe('The Clear Data Plugin:', () => {
});

it('renders its major elements', async () => {
await Vue.nextTick();
await nextTick();
const indicatorClass = appHolder.querySelector('.c-indicator');
const iconClass = appHolder.querySelector('.icon-clear-data');
const indicatorLabel = appHolder.querySelector('.c-indicator__label');
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/clock/pluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import EventEmitter from 'EventEmitter';
import { createOpenMct, resetApplicationState } from 'utils/testing';
import Vue from 'vue';
import { nextTick } from 'vue';

import clockPlugin from './plugin';

Expand Down Expand Up @@ -106,7 +106,7 @@ describe('Clock plugin:', () => {
clockView = clockViewProvider.view(mutableClockObject);
clockView.show(child);

await Vue.nextTick();
await nextTick();
await new Promise((resolve) => requestAnimationFrame(resolve));
});

Expand Down Expand Up @@ -232,7 +232,7 @@ describe('Clock plugin:', () => {
it('contains text', async () => {
await setupClock(true);

await Vue.nextTick();
await nextTick();
await new Promise((resolve) => requestAnimationFrame(resolve));

clockIndicator = openmct.indicators.indicatorObjects.find(
Expand Down
1 change: 1 addition & 0 deletions src/plugins/condition/components/inspector/StyleEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<!-- Save Styles -->
<toolbar-button
v-if="canSaveStyle"
ref="saveStyleButton"
class="c-style__toolbar-button--save c-local-controls--show-on-hover c-icon-button c-icon-button--major"
:options="saveOptions"
@click="saveItemStyle()"
Expand Down
1 change: 1 addition & 0 deletions src/plugins/condition/components/inspector/StylesView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<div class="c-inspect-styles__content">
<div v-if="staticStyle" class="c-inspect-styles__style">
<StyleEditor
ref="styleEditor"
class="c-inspect-styles__editor"
:style-item="staticStyle"
:is-editing="allowEditing"
Expand Down
Loading

0 comments on commit 43338f3

Please sign in to comment.