refactor: migrate to ESM (#7331)

* refactor: move package.json to type: module

this is where the fun begins

* chore: move webpack common and prod to esm

* chore: move webpack to esm, eslint to explicit cjs

* refactor: migrate all files to esm

* style: lint

* refactor: begin moving karma to cjs, use dynamic esm import

* refactor: move index-test to cjs

* refactor: begin moving e2e to ESM

this was manual. I'm committing this because I'm about to try the `cjstoesm` tool

* refactor: move all to esm

* fix: make all e2e tests use .js imports

* refactor: begin moving exports to esm

* refactor: use URL transforms instead of __dirname

* fix: use libraryExport: default to properly handle openmct

* fix: export all playwright configs as modules

* refactor: move all instances of __dirname to import.meta.url

* refactor: lint, drop unnecessary URL call

* fix: use correct URL path on helper/addNoneditableObject.js

* fix: more incorrect URL resolve issues

* fix: parse json after reading it
This commit is contained in:
Tristan F 2024-01-02 10:24:22 -05:00 committed by GitHub
parent 68e60e332e
commit fce98a1c47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
485 changed files with 1220 additions and 1190 deletions

View File

@ -1,5 +1,3 @@
/* global __dirname module */
/*
This is the OpenMCT common webpack file. It is imported by the other three webpack configurations:
- webpack.prod.js - the production configuration for OpenMCT (default)
@ -8,27 +6,30 @@ This is the OpenMCT common webpack file. It is imported by the other three webpa
There are separate npm scripts to use these configurations, though simply running `npm install`
will use the default production configuration.
*/
const path = require('path');
const packageDefinition = require('../package.json');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
import path from 'node:path';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import webpack from 'webpack';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import fs from 'node:fs';
import { execSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
const { VueLoaderPlugin } = require('vue-loader');
import { VueLoaderPlugin } from 'vue-loader';
let gitRevision = 'error-retrieving-revision';
let gitBranch = 'error-retrieving-branch';
const packageDefinition = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)));
try {
gitRevision = require('child_process').execSync('git rev-parse HEAD').toString().trim();
gitBranch = require('child_process')
.execSync('git rev-parse --abbrev-ref HEAD')
gitRevision = execSync('git rev-parse HEAD').toString().trim();
gitBranch = execSync('git rev-parse --abbrev-ref HEAD')
.toString()
.trim();
} catch (err) {
console.warn(err);
}
const projectRootDir = path.resolve(__dirname, '..');
const projectRootDir = fileURLToPath(new URL('../', import.meta.url));
/** @type {import('webpack').Configuration} */
const config = {
@ -56,6 +57,7 @@ const config = {
filename: '[name].js',
path: path.resolve(projectRootDir, 'dist'),
library: 'openmct',
libraryExport: 'default',
libraryTarget: 'umd',
publicPath: '',
hashFunction: 'xxhash64',
@ -183,4 +185,4 @@ const config = {
}
};
module.exports = config;
export default config;

View File

@ -1,12 +1,10 @@
/* global module */
/*
This file extends the webpack.dev.js config to add babel istanbul coverage.
OpenMCT Continuous Integration servers use this configuration to add code coverage
information to pull requests.
*/
const config = require('./webpack.dev');
import config from './webpack.dev.js';
// eslint-disable-next-line no-undef
const CI = process.env.CI === 'true';
@ -34,4 +32,4 @@ config.module.rules.push({
}
});
module.exports = config;
export default config;

View File

@ -1,18 +1,16 @@
/* global __dirname module */
/*
This configuration should be used for development purposes. It contains full source map, a
devServer (which be invoked using by `npm start`), and a non-minified Vue.js distribution.
If OpenMCT is to be used for a production server, use webpack.prod.js instead.
*/
const path = require('path');
const webpack = require('webpack');
const { merge } = require('webpack-merge');
import path from 'path';
import webpack from 'webpack';
import { merge } from 'webpack-merge';
import { fileURLToPath } from 'node:url';
const common = require('./webpack.common');
const projectRootDir = path.resolve(__dirname, '..');
import common from './webpack.common.js';
module.exports = merge(common, {
export default merge(common, {
mode: 'development',
watchOptions: {
// Since we use require.context, webpack is watching the entire directory.
@ -42,7 +40,7 @@ module.exports = merge(common, {
},
watchFiles: ['**/*.css'],
static: {
directory: path.join(__dirname, '..', '/dist'),
directory: fileURLToPath(new URL('../dist', import.meta.url)),
publicPath: '/dist',
watch: false
}

View File

@ -1,17 +1,14 @@
/* global __dirname module */
/*
This configuration should be used for production installs.
It is the default webpack configuration.
*/
const path = require('path');
const webpack = require('webpack');
const { merge } = require('webpack-merge');
const common = require('./webpack.common');
const projectRootDir = path.resolve(__dirname, '..');
import webpack from 'webpack';
import { merge } from 'webpack-merge';
module.exports = merge(common, {
import common from './webpack.common.js';
export default merge(common, {
mode: 'production',
plugins: [
new webpack.DefinePlugin({

View File

@ -480,7 +480,7 @@ The following contains a list of tips and tricks which don't exactly fit into a
It is possible to override the browser's clock in order to control time-based elements. Since this can cause unwanted behavior (i.e. Tree not rendering), only use this sparingly. To do this, use the `overrideClock` fixture as such:
```js
const { test, expect } = require('../../pluginFixtures.js');
import { test, expect } from '../../pluginFixtures.js';
test.describe('foo test suite', () => {

View File

@ -54,9 +54,9 @@
* @property {import('../src/api/notifications/NotificationAPI').NotificationOptions} [notificationOptions] additional options
*/
const Buffer = require('buffer').Buffer;
const genUuid = require('uuid').v4;
const { expect } = require('@playwright/test');
import { expect } from '@playwright/test';
import { Buffer } from 'buffer';
import { v4 as genUuid } from 'uuid';
/**
* This common function creates a domain object with the default options. It is the preferred way of creating objects
@ -644,8 +644,7 @@ async function renameObjectFromContextMenu(page, url, newName) {
await page.click('[aria-label="Save"]');
}
// eslint-disable-next-line no-undef
module.exports = {
export {
createDomainObjectWithDefaults,
createExampleTelemetryObject,
createNotification,
@ -653,16 +652,16 @@ module.exports = {
expandEntireTree,
expandTreePaneItemByName,
getCanvasPixels,
getHashUrlToDomainObject,
getFocusedObjectUuid,
getHashUrlToDomainObject,
navigateToObjectWithFixedTimeBounds,
openObjectTreeContextMenu,
renameObjectFromContextMenu,
setEndOffset,
setFixedTimeMode,
setIndependentTimeConductorBounds,
setRealTimeMode,
setStartOffset,
setEndOffset,
setTimeConductorBounds,
setIndependentTimeConductorBounds,
waitForPlotsToRender,
renameObjectFromContextMenu
waitForPlotsToRender
};

View File

@ -33,10 +33,11 @@
* existing ones.
*/
const fs = require('fs');
const path = require('path');
const { test, expect } = require('./pluginFixtures');
const AxeBuilder = require('@axe-core/playwright').default;
import AxeBuilder from '@axe-core/playwright';
import fs from 'fs';
import path from 'path';
import { expect, test } from './pluginFixtures.js';
// Constants for repeated values
const TEST_RESULTS_DIR = './test-results';
@ -56,7 +57,7 @@ const TEST_RESULTS_DIR = './test-results';
* otherwise returns null.
*/
/* eslint-disable no-undef */
exports.scanForA11yViolations = async function (page, testCaseName, options = {}) {
export async function scanForA11yViolations(page, testCaseName, options = {}) {
const builder = new AxeBuilder({ page });
builder.withTags(['wcag2aa']);
// https://github.com/dequelabs/axe-core/blob/develop/doc/rule-descriptions.md
@ -91,7 +92,6 @@ exports.scanForA11yViolations = async function (page, testCaseName, options = {}
console.log('No accessibility violations found, no report generated.');
return null;
}
};
}
exports.expect = expect;
exports.test = test;
export { expect, test };

View File

@ -28,12 +28,12 @@
* GitHub issues.
*/
const base = require('@playwright/test');
const { expect, request } = base;
const fs = require('fs');
const path = require('path');
const { v4: uuid } = require('uuid');
const sinon = require('sinon');
import { expect, request, test } from '@playwright/test';
import fs from 'fs';
import path from 'path';
import sinon from 'sinon';
import { fileURLToPath } from 'url';
import { v4 as uuid } from 'uuid';
/**
* Takes a `ConsoleMessage` and returns a formatted string. Used to enable console log error detection.
@ -68,7 +68,7 @@ function waitForAnimations(locator) {
*/
const istanbulCLIOutput = path.join(process.cwd(), '.nyc_output');
exports.test = base.test.extend({
const extendedTest = test.extend({
/**
* This allows the test to manipulate the browser clock. This is useful for Visual and Snapshot tests which need
* the Time Indicator Clock to be in a specific state.
@ -97,7 +97,7 @@ exports.test = base.test.extend({
async ({ context, clockOptions }, use) => {
if (clockOptions !== undefined) {
await context.addInitScript({
path: path.join(__dirname, '../', './node_modules/sinon/pkg/sinon.js')
path: fileURLToPath(new URL('../node_modules/sinon/pkg/sinon.js', import.meta.url))
});
await context.addInitScript((options) => {
window.__clock = sinon.useFakeTimers(options);
@ -201,6 +201,4 @@ exports.test = base.test.extend({
}
});
exports.expect = expect;
exports.request = request;
exports.waitForAnimations = waitForAnimations;
export { expect, request, extendedTest as test, waitForAnimations };

View File

@ -19,14 +19,15 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/* global __dirname */
const path = require('path');
import { fileURLToPath } from 'url';
/**
* @param {import('@playwright/test').Page} page
*/
async function navigateToFaultManagementWithExample(page) {
await page.addInitScript({ path: path.join(__dirname, './', 'addInitExampleFaultProvider.js') });
await page.addInitScript({
path: fileURLToPath(new URL('./addInitExampleFaultProvider.js', import.meta.url))
});
await navigateToFaultItemInTree(page);
}
@ -36,7 +37,7 @@ async function navigateToFaultManagementWithExample(page) {
*/
async function navigateToFaultManagementWithStaticExample(page) {
await page.addInitScript({
path: path.join(__dirname, './', 'addInitExampleFaultProviderStatic.js')
path: fileURLToPath(new URL('./addInitExampleFaultProviderStatic.js', import.meta.url))
});
await navigateToFaultItemInTree(page);
@ -46,7 +47,9 @@ async function navigateToFaultManagementWithStaticExample(page) {
* @param {import('@playwright/test').Page} page
*/
async function navigateToFaultManagementWithoutExample(page) {
await page.addInitScript({ path: path.join(__dirname, './', 'addInitFaultManagementPlugin.js') });
await page.addInitScript({
path: fileURLToPath(new URL('./addInitFaultManagementPlugin.js', import.meta.url))
});
await navigateToFaultItemInTree(page);
}
@ -265,29 +268,28 @@ async function openFaultRowMenu(page, rowNumber) {
.click();
}
// eslint-disable-next-line no-undef
module.exports = {
navigateToFaultManagementWithExample,
navigateToFaultManagementWithStaticExample,
navigateToFaultManagementWithoutExample,
navigateToFaultItemInTree,
export {
acknowledgeFault,
shelveMultipleFaults,
acknowledgeMultipleFaults,
shelveFault,
changeViewTo,
sortFaultsBy,
enterSearchTerm,
clearSearch,
selectFaultItem,
getHighestSeverity,
getLowestSeverity,
getFaultResultCount,
enterSearchTerm,
getFault,
getFaultByName,
getFaultName,
getFaultSeverity,
getFaultNamespace,
getFaultResultCount,
getFaultSeverity,
getFaultTriggerTime,
openFaultRowMenu
getHighestSeverity,
getLowestSeverity,
navigateToFaultItemInTree,
navigateToFaultManagementWithExample,
navigateToFaultManagementWithoutExample,
navigateToFaultManagementWithStaticExample,
openFaultRowMenu,
selectFaultItem,
shelveFault,
shelveMultipleFaults,
sortFaultsBy
};

View File

@ -20,11 +20,11 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
const { createDomainObjectWithDefaults } = require('../appActions');
import { createDomainObjectWithDefaults } from '../appActions.js';
const NOTEBOOK_DROP_AREA = '.c-notebook__drag-area';
const CUSTOM_NAME = 'CUSTOM_NAME';
const path = require('path');
import { fileURLToPath } from 'url';
/**
* @param {import('@playwright/test').Page} page
@ -69,7 +69,9 @@ async function commitEntry(page) {
*/
async function startAndAddRestrictedNotebookObject(page) {
// eslint-disable-next-line no-undef
await page.addInitScript({ path: path.join(__dirname, 'addInitRestrictedNotebook.js') });
await page.addInitScript({
path: fileURLToPath(new URL('./addInitRestrictedNotebook.js', import.meta.url))
});
await page.goto('./', { waitUntil: 'domcontentloaded' });
return createDomainObjectWithDefaults(page, {
@ -138,12 +140,11 @@ async function createNotebookEntryAndTags(page, iterations = 1) {
return notebook;
}
// eslint-disable-next-line no-undef
module.exports = {
enterTextEntry,
dragAndDropEmbed,
startAndAddRestrictedNotebookObject,
lockPage,
export {
createNotebookAndEntry,
createNotebookEntryAndTags,
createNotebookAndEntry
dragAndDropEmbed,
enterTextEntry,
lockPage,
startAndAddRestrictedNotebookObject
};

View File

@ -20,7 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
import { expect } from '../pluginFixtures';
import { expect } from '../pluginFixtures.js';
/**
* Asserts that the number of activities in the plan view matches the number of

View File

@ -20,8 +20,8 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
import { expect } from '../pluginFixtures';
const { waitForPlotsToRender } = require('../appActions');
import { waitForPlotsToRender } from '../appActions.js';
import { expect } from '../pluginFixtures.js';
/**
* Given a canvas and a set of points, tags the points on the canvas.

View File

@ -1,9 +1,8 @@
/* eslint-disable no-undef */
// playwright.config.js
// @ts-check
// eslint-disable-next-line no-unused-vars
const { devices } = require('@playwright/test');
import { devices } from '@playwright/test';
const MAX_FAILURES = 5;
const NUM_WORKERS = 2;
@ -81,4 +80,4 @@ const config = {
]
};
module.exports = config;
export default config;

View File

@ -1,9 +1,8 @@
/* eslint-disable no-undef */
// playwright.config.js
// @ts-check
// eslint-disable-next-line no-unused-vars
const { devices } = require('@playwright/test');
import { devices } from '@playwright/test';
/** @type {import('@playwright/test').PlaywrightTestConfig} */
const config = {
@ -104,4 +103,4 @@ const config = {
]
};
module.exports = config;
export default config;

View File

@ -1,4 +1,3 @@
/* eslint-disable no-undef */
// playwright.config.js
// @ts-check
@ -40,4 +39,4 @@ const config = {
]
};
module.exports = config;
export default config;

View File

@ -1,4 +1,3 @@
/* eslint-disable no-undef */
// playwright.config.js
// @ts-check
@ -57,4 +56,4 @@ const config = {
]
};
module.exports = config;
export default config;

View File

@ -51,4 +51,4 @@ const config = {
]
};
module.exports = config;
export default config;

View File

@ -1,9 +1,8 @@
/* eslint-disable no-undef */
// playwright.config.js
// @ts-check
// eslint-disable-next-line no-unused-vars
const { devices } = require('@playwright/test');
import { devices } from '@playwright/test';
const MAX_FAILURES = 5;
const NUM_WORKERS = 2;
@ -51,4 +50,4 @@ const config = {
]
};
module.exports = config;
export default config;

View File

@ -26,9 +26,10 @@
* and appActions. These fixtures should be generalized across all plugins.
*/
const { test, expect, request } = require('./baseFixtures');
// const { createDomainObjectWithDefaults } = require('./appActions');
const path = require('path');
// import { createDomainObjectWithDefaults } from './appActions.js';
import { fileURLToPath } from 'url';
import { expect, request, test } from './baseFixtures.js';
/**
* @typedef {Object} ObjectCreateOptions
@ -117,7 +118,7 @@ const theme = 'espresso';
*/
const myItemsFolderName = 'My Items';
exports.test = test.extend({
const extendedTest = test.extend({
// This should follow in the Project's configuration. Can be set to 'snow' in playwright config.js
theme: [theme, { option: true }],
// eslint-disable-next-line no-shadow
@ -125,7 +126,9 @@ exports.test = test.extend({
// eslint-disable-next-line playwright/no-conditional-in-test
if (theme === 'snow') {
//inject snow theme
await page.addInitScript({ path: path.join(__dirname, './helper', './useSnowTheme.js') });
await page.addInitScript({
path: fileURLToPath(new URL('./helper/useSnowTheme.js', import.meta.url))
});
}
// Attach info about the currently running test and its project.
@ -142,19 +145,18 @@ exports.test = test.extend({
}
});
exports.expect = expect;
exports.request = request;
export { expect, request, extendedTest as test };
/**
* Takes a readable stream and returns a string.
* @param {ReadableStream} readable - the readable stream
* @return {Promise<String>} the stringified stream
*/
exports.streamToString = async function (readable) {
export async function streamToString(readable) {
let result = '';
for await (const chunk of readable) {
result += chunk;
}
return result;
};
}

View File

@ -20,12 +20,12 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
const { test, expect } = require('../../pluginFixtures.js');
const {
import {
createDomainObjectWithDefaults,
createNotification,
expandEntireTree
} = require('../../appActions.js');
} from '../../appActions.js';
import { expect, test } from '../../pluginFixtures.js';
test.describe('AppActions', () => {
test('createDomainObjectsWithDefaults', async ({ page }) => {

View File

@ -26,7 +26,7 @@ relates to how we've extended it (i.e. ./e2e/baseFixtures.js) and assumptions ma
(`npm start` and ./e2e/webpack-dev-middleware.js)
*/
const { test } = require('../../baseFixtures.js');
import { test } from '../../baseFixtures.js';
test.describe('baseFixtures tests', () => {
//Skip this test for now https://github.com/nasa/openmct/issues/6785

View File

@ -45,8 +45,8 @@
*/
// Structure: Some standard Imports. Please update the required pathing.
const { test, expect } = require('../../pluginFixtures');
const { createDomainObjectWithDefaults } = require('../../appActions');
import { createDomainObjectWithDefaults } from '../../appActions.js';
import { expect, test } from '../../pluginFixtures.js';
/**
* Structure:

View File

@ -19,7 +19,6 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/* global __dirname */
/**
* This test suite is dedicated to generating LocalStorage via Session Storage to be used
* in some visual test suites like controlledClock.visual.spec.js. This suite should run to completion
@ -32,13 +31,11 @@
* and is additionally verified in the validation test suites below.
*/
const { test, expect } = require('../../pluginFixtures.js');
const {
createDomainObjectWithDefaults,
createExampleTelemetryObject
} = require('../../appActions.js');
const { MISSION_TIME } = require('../../constants.js');
const path = require('path');
import { fileURLToPath } from 'url';
import { createDomainObjectWithDefaults, createExampleTelemetryObject } from '../../appActions.js';
import { MISSION_TIME } from '../../constants.js';
import { expect, test } from '../../pluginFixtures.js';
const overlayPlotName = 'Overlay Plot with Telemetry Object';
@ -87,7 +84,9 @@ test.describe('Generate Visual Test Data @localStorage @generatedata', () => {
//Save localStorage for future test execution
await context.storageState({
path: path.join(__dirname, '../../../e2e/test-data/display_layout_with_child_layouts.json')
path: fileURLToPath(
new URL('../../../e2e/test-data/display_layout_with_child_layouts.json', import.meta.url)
)
});
});
@ -112,7 +111,9 @@ test.describe('Generate Visual Test Data @localStorage @generatedata', () => {
//Save localStorage for future test execution
await context.storageState({
path: path.join(__dirname, '../../../e2e/test-data/flexible_layout_with_child_layouts.json')
path: fileURLToPath(
new URL('../../../e2e/test-data/flexible_layout_with_child_layouts.json', import.meta.url)
)
});
});
@ -189,7 +190,9 @@ test.describe('Generate Visual Test Data @localStorage @generatedata', () => {
// Save localStorage for future test execution
await context.storageState({
path: path.join(__dirname, '../../../e2e/test-data/overlay_plot_storage.json')
path: fileURLToPath(
new URL('../../../e2e/test-data/overlay_plot_storage.json', import.meta.url)
)
});
});
// TODO: Merge this with previous test. Edit object created in previous test.
@ -226,14 +229,18 @@ test.describe('Generate Visual Test Data @localStorage @generatedata', () => {
await page.getByRole('button', { name: 'OK' }).click();
//Save localStorage for future test execution
await context.storageState({
path: path.join(__dirname, '../../../e2e/test-data/overlay_plot_with_delay_storage.json')
path: fileURLToPath(
new URL('../../../e2e/test-data/overlay_plot_with_delay_storage.json', import.meta.url)
)
});
});
});
test.describe('Validate Overlay Plot with Telemetry Object @localStorage @generatedata', () => {
test.use({
storageState: path.join(__dirname, '../../../e2e/test-data/overlay_plot_storage.json')
storageState: fileURLToPath(
new URL('../../../e2e/test-data/overlay_plot_storage.json', import.meta.url)
)
});
test('Validate Overlay Plot with Telemetry Object', async ({ page }) => {
await page.goto('./', { waitUntil: 'domcontentloaded' });
@ -275,9 +282,8 @@ test.describe('Validate Overlay Plot with Telemetry Object @localStorage @genera
test.describe('Validate Overlay Plot with 5s Delay Telemetry Object @localStorage @generatedata', () => {
test.use({
storageState: path.join(
__dirname,
'../../../e2e/test-data/overlay_plot_with_delay_storage.json'
storageState: fileURLToPath(
new URL('../../../e2e/test-data/overlay_plot_with_delay_storage.json', import.meta.url)
)
});
test('Validate Overlay Plot with Telemetry Object', async ({ page }) => {

View File

@ -25,7 +25,7 @@ This test suite is dedicated to testing our use of our custom fixtures to verify
that they are working as expected.
*/
const { test } = require('../../pluginFixtures.js');
import { test } from '../../pluginFixtures.js';
// eslint-disable-next-line playwright/no-skipped-test
test.describe.skip('pluginFixtures tests', () => {

View File

@ -24,7 +24,7 @@
This test suite is dedicated to tests which verify branding related components.
*/
const { test, expect } = require('../../baseFixtures.js');
import { expect, test } from '../../baseFixtures.js';
test.describe('Branding tests', () => {
test('About Modal launches with basic branding properties', async ({ page }) => {

View File

@ -24,8 +24,8 @@
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');
import { createDomainObjectWithDefaults } from '../../appActions.js';
import { expect, test } from '../../pluginFixtures.js';
const backgroundImageSelector = '.c-imagery__main-image__background-image';

View File

@ -25,7 +25,7 @@
*
*/
const { test, expect } = require('../../pluginFixtures');
import { expect, test } from '../../pluginFixtures.js';
test.describe('CouchDB Status Indicator with mocked responses @couchdb', () => {
test.use({ failOnConsoleError: false });

View File

@ -24,8 +24,8 @@
This test suite is dedicated to tests which verify the basic operations surrounding the example event generator.
*/
const { test, expect } = require('../../../pluginFixtures');
const { createDomainObjectWithDefaults } = require('../../../appActions');
import { createDomainObjectWithDefaults } from '../../../appActions.js';
import { expect, test } from '../../../pluginFixtures.js';
test.describe('Example Event Generator CRUD Operations', () => {
test('Can create a Test Event Generator and it results in the table View', async ({ page }) => {

View File

@ -24,7 +24,7 @@
This test suite is dedicated to tests which verify the basic operations surrounding conditionSets.
*/
const { test, expect } = require('../../../../baseFixtures');
import { expect, test } from '../../../../baseFixtures.js';
test.describe('Sine Wave Generator', () => {
test('Create new Sine Wave Generator Object and validate create Form Logic', async ({

View File

@ -19,15 +19,16 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/* global __dirname */
/*
This test suite is dedicated to tests which verify form functionality in isolation
*/
const { test, expect } = require('../../pluginFixtures');
const { createDomainObjectWithDefaults } = require('../../appActions');
const genUuid = require('uuid').v4;
const path = require('path');
import { fileURLToPath } from 'url';
import { v4 as genUuid } from 'uuid';
import { createDomainObjectWithDefaults } from '../../appActions.js';
import { expect, test } from '../../pluginFixtures.js';
const TEST_FOLDER = 'test folder';
const jsonFilePath = 'e2e/test-data/ExampleLayouts.json';
@ -72,7 +73,7 @@ test.describe('Form Validation Behavior', () => {
test.describe('Form File Input Behavior', () => {
test.beforeEach(async ({ page }) => {
await page.addInitScript({
path: path.join(__dirname, '../../helper', 'addInitFileInputObject.js')
path: fileURLToPath(new URL('../../helper/addInitFileInputObject.js', import.meta.url))
});
});
@ -109,7 +110,7 @@ test.describe('Persistence operations @addInit', () => {
// add non persistable root item
test.beforeEach(async ({ page }) => {
await page.addInitScript({
path: path.join(__dirname, '../../helper', 'addNoneditableObject.js')
path: fileURLToPath(new URL('../../helper/addNoneditableObject.js', import.meta.url))
});
});

View File

@ -19,20 +19,20 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/* global __dirname */
/*
This test suite is dedicated to tests which verify persistability checks
*/
const { test, expect } = require('../../baseFixtures.js');
import { fileURLToPath } from 'url';
const path = require('path');
import { expect, test } from '../../baseFixtures.js';
test.describe('Persistence operations @addInit', () => {
// add non persistable root item
test.beforeEach(async ({ page }) => {
await page.addInitScript({
path: path.join(__dirname, '../../helper', 'addNoneditableObject.js')
path: fileURLToPath(new URL('../../helper/addNoneditableObject.js', import.meta.url))
});
});

View File

@ -24,8 +24,8 @@
This test suite is dedicated to tests which verify the basic operations surrounding moving & linking objects.
*/
const { test, expect } = require('../../pluginFixtures');
const { createDomainObjectWithDefaults } = require('../../appActions');
import { createDomainObjectWithDefaults } from '../../appActions.js';
import { expect, test } from '../../pluginFixtures.js';
test.describe('Move & link item tests', () => {
test('Create a basic object and verify that it can be moved to another folder', async ({

View File

@ -24,8 +24,8 @@
This test suite is dedicated to tests which verify Open MCT's Notification functionality
*/
const { createDomainObjectWithDefaults, createNotification } = require('../../appActions');
const { test, expect } = require('../../pluginFixtures');
import { createDomainObjectWithDefaults, createNotification } from '../../appActions.js';
import { expect, test } from '../../pluginFixtures.js';
test.describe('Notifications List', () => {
test.fixme('Notifications can be dismissed individually', async ({ page }) => {

View File

@ -19,15 +19,26 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
const { test, expect } = require('../../../pluginFixtures');
const { createPlanFromJSON, createDomainObjectWithDefaults } = require('../../../appActions');
const testPlan1 = require('../../../test-data/examplePlans/ExamplePlan_Small1.json');
const testPlan2 = require('../../../test-data/examplePlans/ExamplePlan_Small2.json');
const {
import fs from 'fs';
import { getPreciseDuration } from '../../../../src/utils/duration.js';
import { createDomainObjectWithDefaults, createPlanFromJSON } from '../../../appActions.js';
import {
assertPlanActivities,
setBoundsToSpanAllActivities
} = require('../../../helper/planningUtils');
const { getPreciseDuration } = require('../../../../src/utils/duration');
} from '../../../helper/planningUtils.js';
import { expect, test } from '../../../pluginFixtures.js';
const testPlan1 = JSON.parse(
fs.readFileSync(
new URL('../../../test-data/examplePlans/ExamplePlan_Small1.json', import.meta.url)
)
);
const testPlan2 = JSON.parse(
fs.readFileSync(
new URL('../../../test-data/examplePlans/ExamplePlan_Small2.json', import.meta.url)
)
);
test.describe('Gantt Chart', () => {
let ganttChart;

View File

@ -19,15 +19,27 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
const { test } = require('../../../pluginFixtures');
const { createPlanFromJSON } = require('../../../appActions');
const { addPlanGetInterceptor } = require('../../../helper/planningUtils.js');
const testPlan1 = require('../../../test-data/examplePlans/ExamplePlan_Small1.json');
const testPlanWithOrderedLanes = require('../../../test-data/examplePlans/ExamplePlanWithOrderedLanes.json');
const {
import fs from 'fs';
import { createPlanFromJSON } from '../../../appActions.js';
import {
addPlanGetInterceptor,
assertPlanActivities,
assertPlanOrderedSwimLanes
} = require('../../../helper/planningUtils');
} from '../../../helper/planningUtils.js';
import { test } from '../../../pluginFixtures.js';
const testPlan1 = JSON.parse(
fs.readFileSync(
new URL('../../../test-data/examplePlans/ExamplePlan_Small1.json', import.meta.url)
)
);
const testPlanWithOrderedLanes = JSON.parse(
fs.readFileSync(
new URL('../../../test-data/examplePlans/ExamplePlanWithOrderedLanes.json', import.meta.url)
)
);
test.describe('Plan', () => {
let plan;

View File

@ -20,8 +20,8 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
const { test, expect } = require('../../../pluginFixtures');
const { createDomainObjectWithDefaults, createPlanFromJSON } = require('../../../appActions');
import { createDomainObjectWithDefaults, createPlanFromJSON } from '../../../appActions.js';
import { expect, test } from '../../../pluginFixtures.js';
const testPlan = {
TEST_GROUP: [

View File

@ -20,12 +20,12 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
const { test, expect } = require('../../../pluginFixtures');
const {
import {
createDomainObjectWithDefaults,
createPlanFromJSON,
setIndependentTimeConductorBounds
} = require('../../../appActions');
} from '../../../appActions.js';
import { expect, test } from '../../../pluginFixtures.js';
const testPlan = {
TEST_GROUP: [

View File

@ -24,7 +24,7 @@
This test suite is dedicated to tests which verify the basic operations surrounding Clock.
*/
const { test, expect } = require('../../../../baseFixtures');
import { expect, test } from '../../../../baseFixtures.js';
test.describe('Clock Generator CRUD Operations', () => {
test('Timezone dropdown will collapse when clicked outside or on dropdown icon again', async ({

View File

@ -22,7 +22,7 @@
// FIXME: Remove this eslint exception once tests are implemented
// eslint-disable-next-line no-unused-vars
const { test, expect } = require('../../../../baseFixtures');
import { expect, test } from '../../../../baseFixtures.js';
test.describe('Remote Clock', () => {
// eslint-disable-next-line require-await

View File

@ -19,19 +19,19 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/* global __dirname */
/*
This test suite is dedicated to tests which verify the basic operations surrounding conditionSets. Note: this
suite is sharing state between tests which is considered an anti-pattern. Implementing in this way to
demonstrate some playwright for test developers. This pattern should not be re-used in other CRUD suites.
*/
const { test, expect } = require('../../../../pluginFixtures.js');
const {
import { fileURLToPath } from 'url';
import {
createDomainObjectWithDefaults,
createExampleTelemetryObject
} = require('../../../../appActions');
const path = require('path');
} from '../../../../appActions.js';
import { expect, test } from '../../../../pluginFixtures.js';
let conditionSetUrl;
let getConditionSetIdentifierFromUrl;
@ -50,7 +50,9 @@ test.describe.serial('Condition Set CRUD Operations on @localStorage', () => {
//Save localStorage for future test execution
await context.storageState({
path: path.resolve(__dirname, '../../../../test-data/recycled_local_storage.json')
path: fileURLToPath(
new URL('../../../../test-data/recycled_local_storage.json', import.meta.url)
)
});
//Set object identifier from url
@ -63,7 +65,9 @@ test.describe.serial('Condition Set CRUD Operations on @localStorage', () => {
//Load localStorage for subsequent tests
test.use({
storageState: path.resolve(__dirname, '../../../../test-data/recycled_local_storage.json')
storageState: fileURLToPath(
new URL('../../../../test-data/recycled_local_storage.json', import.meta.url)
)
});
//Begin suite of tests again localStorage