2022-09-19 17:18:20 +00:00
|
|
|
/*****************************************************************************
|
2024-01-09 21:31:51 +00:00
|
|
|
* Open MCT, Copyright (c) 2014-2024, United States Government
|
2022-09-19 17:18:20 +00:00
|
|
|
* 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.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2024-01-02 15:24:22 +00:00
|
|
|
import { fileURLToPath } from 'url';
|
|
|
|
|
|
|
|
import {
|
2023-07-28 02:06:41 +00:00
|
|
|
createDomainObjectWithDefaults,
|
2024-08-07 21:36:14 +00:00
|
|
|
setFixedIndependentTimeConductorBounds
|
2024-01-02 15:24:22 +00:00
|
|
|
} from '../../../../appActions.js';
|
|
|
|
import { expect, test } from '../../../../pluginFixtures.js';
|
2023-11-16 17:21:23 +00:00
|
|
|
|
2024-01-02 15:24:22 +00:00
|
|
|
const LOCALSTORAGE_PATH = fileURLToPath(
|
|
|
|
new URL('../../../../test-data/flexible_layout_with_child_layouts.json', import.meta.url)
|
2023-11-16 17:21:23 +00:00
|
|
|
);
|
2022-09-19 17:18:20 +00:00
|
|
|
|
2022-11-10 20:06:13 +00:00
|
|
|
test.describe('Flexible Layout', () => {
|
|
|
|
let sineWaveObject;
|
2023-01-25 19:18:26 +00:00
|
|
|
let clockObject;
|
2023-08-16 17:52:23 +00:00
|
|
|
let treePane;
|
|
|
|
let sineWaveGeneratorTreeItem;
|
|
|
|
let clockTreeItem;
|
|
|
|
let flexibleLayout;
|
2022-09-19 17:18:20 +00:00
|
|
|
test.beforeEach(async ({ page }) => {
|
2023-04-18 22:32:29 +00:00
|
|
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2022-09-19 17:18:20 +00:00
|
|
|
// Create Sine Wave Generator
|
2022-11-10 20:06:13 +00:00
|
|
|
sineWaveObject = await createDomainObjectWithDefaults(page, {
|
2023-01-25 19:18:26 +00:00
|
|
|
type: 'Sine Wave Generator'
|
2022-09-19 17:18:20 +00:00
|
|
|
});
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2022-09-19 17:18:20 +00:00
|
|
|
// Create Clock Object
|
|
|
|
clockObject = await createDomainObjectWithDefaults(page, {
|
2023-01-25 19:18:26 +00:00
|
|
|
type: 'Clock'
|
2022-09-19 17:18:20 +00:00
|
|
|
});
|
2023-08-16 17:52:23 +00:00
|
|
|
|
|
|
|
// Create a Flexible Layout
|
|
|
|
flexibleLayout = await createDomainObjectWithDefaults(page, {
|
|
|
|
type: 'Flexible Layout'
|
|
|
|
});
|
|
|
|
|
|
|
|
// Define the Sine Wave Generator and Clock tree items
|
|
|
|
treePane = page.getByRole('tree', {
|
2023-01-26 17:25:15 +00:00
|
|
|
name: 'Main Tree'
|
|
|
|
});
|
2023-08-16 17:52:23 +00:00
|
|
|
sineWaveGeneratorTreeItem = treePane.getByRole('treeitem', {
|
2023-01-25 19:18:26 +00:00
|
|
|
name: new RegExp(sineWaveObject.name)
|
|
|
|
});
|
2023-08-16 17:52:23 +00:00
|
|
|
clockTreeItem = treePane.getByRole('treeitem', {
|
2023-01-25 19:18:26 +00:00
|
|
|
name: new RegExp(clockObject.name)
|
|
|
|
});
|
2023-08-16 17:52:23 +00:00
|
|
|
});
|
|
|
|
test('panes have the appropriate draggable attribute while in Edit and Browse modes', async ({
|
|
|
|
page
|
|
|
|
}) => {
|
|
|
|
await page.goto(flexibleLayout.url);
|
2022-09-19 17:18:20 +00:00
|
|
|
// Edit Flexible Layout
|
2024-01-11 22:47:00 +00:00
|
|
|
await page.getByLabel('Edit Object').click();
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2022-09-19 17:18:20 +00:00
|
|
|
// Expand the 'My Items' folder in the left tree
|
|
|
|
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').first().click();
|
|
|
|
// Add the Sine Wave Generator and Clock to the Flexible Layout
|
2024-04-18 23:38:11 +00:00
|
|
|
await sineWaveGeneratorTreeItem.dragTo(page.locator('.c-fl-container.is-empty').first());
|
|
|
|
await clockTreeItem.dragTo(page.locator('.c-fl-container.is-empty'));
|
2023-01-25 19:18:26 +00:00
|
|
|
// Check that panes can be dragged while Flexible Layout is in Edit mode
|
2022-11-10 20:06:13 +00:00
|
|
|
let dragWrapper = page
|
2023-01-25 19:18:26 +00:00
|
|
|
.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper')
|
2023-05-18 21:54:46 +00:00
|
|
|
.first();
|
2023-01-25 19:18:26 +00:00
|
|
|
await expect(dragWrapper).toHaveAttribute('draggable', 'true');
|
2022-11-10 20:06:13 +00:00
|
|
|
// Save Flexible Layout
|
2023-01-25 19:18:26 +00:00
|
|
|
await page.locator('button[title="Save"]').click();
|
2023-11-16 18:31:35 +00:00
|
|
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
2022-09-19 17:18:20 +00:00
|
|
|
// Check that panes are not draggable while Flexible Layout is in Browse mode
|
2022-11-10 20:06:13 +00:00
|
|
|
dragWrapper = page.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper').first();
|
2022-09-19 17:18:20 +00:00
|
|
|
await expect(dragWrapper).toHaveAttribute('draggable', 'false');
|
2023-05-18 21:54:46 +00:00
|
|
|
});
|
2023-08-16 17:52:23 +00:00
|
|
|
test('changing toolbar settings in edit mode is immediately reflected and persists upon save', async ({
|
2023-05-18 21:54:46 +00:00
|
|
|
page
|
|
|
|
}) => {
|
2023-08-16 17:52:23 +00:00
|
|
|
test.info().annotations.push({
|
|
|
|
type: 'issue',
|
|
|
|
description: 'https://github.com/nasa/openmct/issues/6942'
|
2023-05-18 21:54:46 +00:00
|
|
|
});
|
2023-08-16 17:52:23 +00:00
|
|
|
|
|
|
|
await page.goto(flexibleLayout.url);
|
|
|
|
|
|
|
|
// Expand the 'My Items' folder in the left tree
|
|
|
|
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').first().click();
|
|
|
|
// Add the Sine Wave Generator and Clock to the Flexible Layout
|
2024-04-18 23:38:11 +00:00
|
|
|
await sineWaveGeneratorTreeItem.dragTo(page.locator('.c-fl-container.is-empty').first());
|
|
|
|
await clockTreeItem.dragTo(page.locator('.c-fl-container.is-empty'));
|
2023-08-16 17:52:23 +00:00
|
|
|
|
|
|
|
// Click on the first frame to select it
|
|
|
|
await page.locator('.c-fl-container__frame').first().click();
|
|
|
|
await expect(page.locator('.c-fl-container__frame > .c-frame').first()).toHaveAttribute(
|
|
|
|
's-selected',
|
|
|
|
''
|
|
|
|
);
|
|
|
|
|
|
|
|
// Assert the toolbar is visible
|
|
|
|
await expect(page.locator('.c-toolbar')).toBeInViewport();
|
|
|
|
|
|
|
|
// Assert the layout is in columns orientation
|
|
|
|
expect(await page.locator('.c-fl--rows').count()).toEqual(0);
|
|
|
|
|
|
|
|
// Change the layout to rows orientation
|
2024-04-18 23:38:11 +00:00
|
|
|
await page.getByTitle('Switch to rows layout').click();
|
2023-08-16 17:52:23 +00:00
|
|
|
|
|
|
|
// Assert the layout is in rows orientation
|
|
|
|
expect(await page.locator('.c-fl--rows').count()).toBeGreaterThan(0);
|
|
|
|
|
|
|
|
// Assert the frame of the first item is visible
|
|
|
|
await expect(page.locator('.c-so-view').first()).not.toHaveClass(/c-so-view--no-frame/);
|
|
|
|
|
|
|
|
// Hide the frame of the first item
|
|
|
|
await page.getByTitle('Frame visible').click();
|
|
|
|
|
|
|
|
// Assert the frame is hidden
|
|
|
|
await expect(page.locator('.c-so-view').first()).toHaveClass(/c-so-view--no-frame/);
|
|
|
|
|
|
|
|
// Assert there are 2 containers
|
|
|
|
expect(await page.locator('.c-fl-container').count()).toEqual(2);
|
|
|
|
|
|
|
|
// Add a container
|
|
|
|
await page.getByTitle('Add Container').click();
|
|
|
|
|
|
|
|
// Assert there are 3 containers
|
|
|
|
expect(await page.locator('.c-fl-container').count()).toEqual(3);
|
|
|
|
|
|
|
|
// Save Flexible Layout
|
|
|
|
await page.locator('button[title="Save"]').click();
|
|
|
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
|
|
|
|
|
|
|
// Nav away and back
|
|
|
|
await page.goto(sineWaveObject.url);
|
|
|
|
await page.goto(flexibleLayout.url);
|
|
|
|
|
|
|
|
// Wait for the first frame to be visible so we know the layout has loaded
|
|
|
|
await expect(page.locator('.c-fl-container').nth(0)).toBeInViewport();
|
|
|
|
|
|
|
|
// Assert the settings have persisted
|
|
|
|
expect(await page.locator('.c-fl-container').count()).toEqual(3);
|
|
|
|
expect(await page.locator('.c-fl--rows').count()).toBeGreaterThan(0);
|
|
|
|
await expect(page.locator('.c-so-view').first()).toHaveClass(/c-so-view--no-frame/);
|
|
|
|
});
|
|
|
|
test('items in a flexible layout can be removed with object tree context menu when viewing the flexible layout', async ({
|
|
|
|
page
|
|
|
|
}) => {
|
|
|
|
await page.goto(flexibleLayout.url);
|
2022-11-10 20:06:13 +00:00
|
|
|
// Edit Flexible Layout
|
2024-01-11 22:47:00 +00:00
|
|
|
await page.getByLabel('Edit Object').click();
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2022-11-10 20:06:13 +00:00
|
|
|
// Expand the 'My Items' folder in the left tree
|
|
|
|
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').first().click();
|
2022-09-19 17:18:20 +00:00
|
|
|
// Add the Sine Wave Generator to the Flexible Layout and save changes
|
2024-04-18 23:38:11 +00:00
|
|
|
await sineWaveGeneratorTreeItem.dragTo(page.locator('.c-fl-container.is-empty').first());
|
2022-09-19 17:18:20 +00:00
|
|
|
await page.locator('button[title="Save"]').click();
|
2023-11-16 18:31:35 +00:00
|
|
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2022-09-19 17:18:20 +00:00
|
|
|
expect.soft(await page.locator('.c-fl-container__frame').count()).toEqual(1);
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2022-09-19 17:18:20 +00:00
|
|
|
// Expand the Flexible Layout so we can remove the sine wave generator
|
|
|
|
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2022-09-19 17:18:20 +00:00
|
|
|
// Bring up context menu and remove
|
2023-01-25 19:18:26 +00:00
|
|
|
await sineWaveGeneratorTreeItem.first().click({ button: 'right' });
|
2022-11-10 20:06:13 +00:00
|
|
|
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
|
|
|
await page.locator('button:has-text("OK")').click();
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2022-09-19 17:18:20 +00:00
|
|
|
// Verify that the item has been removed from the layout
|
2022-11-10 20:06:13 +00:00
|
|
|
expect(await page.locator('.c-fl-container__frame').count()).toEqual(0);
|
2023-05-18 21:54:46 +00:00
|
|
|
});
|
2022-09-19 17:18:20 +00:00
|
|
|
test('items in a flexible layout can be removed with object tree context menu when viewing another item', async ({
|
2022-11-10 20:06:13 +00:00
|
|
|
page
|
|
|
|
}) => {
|
|
|
|
test.info().annotations.push({
|
2022-09-19 17:18:20 +00:00
|
|
|
type: 'issue',
|
|
|
|
description: 'https://github.com/nasa/openmct/issues/3117'
|
|
|
|
});
|
2023-08-16 17:52:23 +00:00
|
|
|
await page.goto(flexibleLayout.url);
|
2022-11-10 20:06:13 +00:00
|
|
|
// Edit Flexible Layout
|
2024-01-11 22:47:00 +00:00
|
|
|
await page.getByLabel('Edit Object').click();
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2022-11-10 20:06:13 +00:00
|
|
|
// Expand the 'My Items' folder in the left tree
|
|
|
|
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
|
|
|
|
// Add the Sine Wave Generator to the Flexible Layout and save changes
|
2024-04-18 23:38:11 +00:00
|
|
|
await sineWaveGeneratorTreeItem.dragTo(page.locator('.c-fl-container.is-empty').first());
|
2022-11-10 20:06:13 +00:00
|
|
|
await page.locator('button[title="Save"]').click();
|
2023-11-16 18:31:35 +00:00
|
|
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2022-11-10 20:06:13 +00:00
|
|
|
expect.soft(await page.locator('.c-fl-container__frame').count()).toEqual(1);
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2022-11-10 20:06:13 +00:00
|
|
|
// Expand the Flexible Layout so we can remove the sine wave generator
|
|
|
|
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2022-11-10 20:06:13 +00:00
|
|
|
// Go to the original Sine Wave Generator to navigate away from the Flexible Layout
|
|
|
|
await page.goto(sineWaveObject.url);
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2022-11-10 20:06:13 +00:00
|
|
|
// Bring up context menu and remove
|
2023-01-25 19:18:26 +00:00
|
|
|
await sineWaveGeneratorTreeItem.first().click({ button: 'right' });
|
2022-11-10 20:06:13 +00:00
|
|
|
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
|
|
|
await page.locator('button:has-text("OK")').click();
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2022-11-10 20:06:13 +00:00
|
|
|
// navigate back to the display layout to confirm it has been removed
|
|
|
|
await page.goto(flexibleLayout.url);
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2022-11-10 20:06:13 +00:00
|
|
|
// Verify that the item has been removed from the layout
|
|
|
|
expect(await page.locator('.c-fl-container__frame').count()).toEqual(0);
|
2023-05-18 21:54:46 +00:00
|
|
|
});
|
2023-07-19 00:32:05 +00:00
|
|
|
|
|
|
|
test('independent time works with flexible layouts and its children', async ({ page }) => {
|
|
|
|
// Create Example Imagery
|
|
|
|
const exampleImageryObject = await createDomainObjectWithDefaults(page, {
|
|
|
|
type: 'Example Imagery'
|
|
|
|
});
|
2023-08-16 17:52:23 +00:00
|
|
|
|
|
|
|
await page.goto(flexibleLayout.url);
|
|
|
|
// Edit Flexible Layout
|
2024-01-11 22:47:00 +00:00
|
|
|
await page.getByLabel('Edit Object').click();
|
2023-07-19 00:32:05 +00:00
|
|
|
|
|
|
|
// Expand the 'My Items' folder in the left tree
|
|
|
|
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
|
|
|
|
const exampleImageryTreeItem = treePane.getByRole('treeitem', {
|
|
|
|
name: new RegExp(exampleImageryObject.name)
|
|
|
|
});
|
|
|
|
// Add the Sine Wave Generator to the Flexible Layout and save changes
|
2024-04-18 23:38:11 +00:00
|
|
|
await exampleImageryTreeItem.dragTo(page.locator('.c-fl-container.is-empty').first());
|
2023-07-19 00:32:05 +00:00
|
|
|
|
|
|
|
await page.locator('button[title="Save"]').click();
|
2023-11-16 18:31:35 +00:00
|
|
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
2023-07-19 00:32:05 +00:00
|
|
|
|
|
|
|
// flip on independent time conductor
|
2024-08-07 21:36:14 +00:00
|
|
|
await setFixedIndependentTimeConductorBounds(page, {
|
2024-03-11 23:39:38 +00:00
|
|
|
start: '2021-12-30 01:01:00.000Z',
|
|
|
|
end: '2021-12-30 01:11:00.000Z'
|
|
|
|
});
|
2023-07-19 00:32:05 +00:00
|
|
|
|
|
|
|
// check image date
|
|
|
|
await expect(page.getByText('2021-12-30 01:11:00.000Z').first()).toBeVisible();
|
|
|
|
|
|
|
|
// flip it off
|
2023-07-28 02:06:41 +00:00
|
|
|
await page.getByRole('switch').click();
|
2023-07-19 00:32:05 +00:00
|
|
|
// timestamp shouldn't be in the past anymore
|
|
|
|
await expect(page.getByText('2021-12-30 01:11:00.000Z')).toBeHidden();
|
|
|
|
});
|
2022-09-19 17:18:20 +00:00
|
|
|
});
|
2023-11-16 17:21:23 +00:00
|
|
|
|
|
|
|
test.describe('Flexible Layout Toolbar Actions @localStorage', () => {
|
|
|
|
test.use({
|
2024-01-02 15:24:22 +00:00
|
|
|
storageState: LOCALSTORAGE_PATH
|
2023-11-16 17:21:23 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
|
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
|
|
|
await page
|
|
|
|
.locator('a')
|
|
|
|
.filter({ hasText: 'Parent Flexible Layout Flexible Layout' })
|
|
|
|
.first()
|
|
|
|
.click();
|
2024-01-11 22:47:00 +00:00
|
|
|
await page.getByLabel('Edit Object').click();
|
2023-11-16 17:21:23 +00:00
|
|
|
});
|
|
|
|
test('Add/Remove Container', async ({ page }) => {
|
|
|
|
test.info().annotations.push({
|
|
|
|
type: 'issue',
|
|
|
|
description: 'https://github.com/nasa/openmct/issues/7234'
|
|
|
|
});
|
2024-01-04 01:11:35 +00:00
|
|
|
|
|
|
|
const containerHandles = page.getByRole('columnheader', { name: 'Handle' });
|
|
|
|
expect(await containerHandles.count()).toEqual(2);
|
|
|
|
await page.getByRole('columnheader', { name: 'Container Handle 1' }).click();
|
2023-11-16 17:21:23 +00:00
|
|
|
await page.getByTitle('Add Container').click();
|
2024-01-04 01:11:35 +00:00
|
|
|
expect(await containerHandles.count()).toEqual(3);
|
2023-11-16 17:21:23 +00:00
|
|
|
await page.getByTitle('Remove Container').click();
|
2024-03-13 20:27:49 +00:00
|
|
|
await expect(page.getByRole('dialog', { name: 'Overlay' })).toContainText(
|
2023-11-17 18:02:58 +00:00
|
|
|
'This action will permanently delete this container from this Flexible Layout. Do you want to continue?'
|
|
|
|
);
|
2024-08-07 21:36:14 +00:00
|
|
|
await page.getByRole('button', { name: 'Ok', exact: true }).click();
|
2024-01-04 01:11:35 +00:00
|
|
|
expect(await containerHandles.count()).toEqual(2);
|
2023-11-17 18:02:58 +00:00
|
|
|
});
|
|
|
|
test('Remove Frame', async ({ page }) => {
|
|
|
|
expect(await page.getByRole('group', { name: 'Frame' }).count()).toEqual(2);
|
|
|
|
await page.getByRole('group', { name: 'Child Layout 1' }).click();
|
|
|
|
await page.getByTitle('Remove Frame').click();
|
2024-03-13 20:27:49 +00:00
|
|
|
await expect(page.getByRole('dialog', { name: 'Overlay' })).toContainText(
|
2023-11-17 18:02:58 +00:00
|
|
|
'This action will remove this frame from this Flexible Layout. Do you want to continue?'
|
|
|
|
);
|
2024-08-07 21:36:14 +00:00
|
|
|
await page.getByRole('button', { name: 'Ok', exact: true }).click();
|
2023-11-17 18:02:58 +00:00
|
|
|
expect(await page.getByRole('group', { name: 'Frame' }).count()).toEqual(1);
|
2023-11-16 17:21:23 +00:00
|
|
|
});
|
|
|
|
test('Columns/Rows Layout Toggle', async ({ page }) => {
|
2024-01-04 01:11:35 +00:00
|
|
|
await page.getByRole('columnheader', { name: 'Container Handle 1' }).click();
|
|
|
|
const flexRows = page.getByLabel('Flexible Layout Row');
|
|
|
|
expect(await flexRows.count()).toEqual(0);
|
2024-04-18 23:38:11 +00:00
|
|
|
await page.getByTitle('Switch to rows layout').click();
|
2024-01-04 01:11:35 +00:00
|
|
|
expect(await flexRows.count()).toEqual(1);
|
2024-04-18 23:38:11 +00:00
|
|
|
await page.getByTitle('Switch to columns layout').click();
|
2024-01-04 01:11:35 +00:00
|
|
|
expect(await flexRows.count()).toEqual(0);
|
2023-11-16 17:21:23 +00:00
|
|
|
});
|
|
|
|
});
|