Skip to content

Commit

Permalink
[Flexible Layouts] Flexible Layout styling fixes (#7319)
Browse files Browse the repository at this point in the history
  • Loading branch information
khalidadil authored Jan 4, 2024
1 parent 6f3bb5f commit 70de736
Show file tree
Hide file tree
Showing 40 changed files with 1,222 additions and 58 deletions.
4 changes: 3 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,9 @@
"oger",
"lcovonly",
"gcov",
"WCAG"
"WCAG",
"stackedplot",
"Andale"
],
"dictionaries": ["npm", "softwareTerms", "node", "html", "css", "bash", "en_US"],
"ignorePaths": [
Expand Down
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# Requires Git > 2.23
# See https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt

# vue-eslint update 2019
14a0f84c1bcd56886d7c9e4e6afa8f7d292734e5
# eslint changes 2022
d80b6923541704ab925abf0047cbbc58735c27e2
# Copyright year update 2022
4a9744e916d24122a81092f6b7950054048ba860
# Copyright year update 2023
Expand Down
7 changes: 6 additions & 1 deletion e2e/.percy.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ snapshot:
/* Time Conductor Start Time */
.c-compact-tc__setting-value{
opacity: 0 !important;
}
}
/* Chart Area for Plots */
.gl-plot-chart-area{
opacity: 0 !important;
}
4 changes: 4 additions & 0 deletions e2e/.percy.nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ snapshot:
/* Time Conductor Start Time */
.c-compact-tc__setting-value{
opacity: 0 !important;
}
/* Chart Area for Plots */
.gl-plot-chart-area{
opacity: 0 !important;
}
104 changes: 104 additions & 0 deletions e2e/helper/stylingUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*****************************************************************************
* 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.
*****************************************************************************/

import { expect } from '../pluginFixtures.js';

/**
* Converts a hex color value to its RGB equivalent.
*
* @param {string} hex - The hex color value. i.e. '#5b0f00'
* @returns {string} The RGB equivalent of the hex color.
*/
function hexToRGB(hex) {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result
? `rgb(${parseInt(result[1], 16)}, ${parseInt(result[2], 16)}, ${parseInt(result[3], 16)})`
: null;
}

/**
* Sets the background and text color of a given element.
*
* @param {import('@playwright/test').Page} page - The Playwright page object.
* @param {string} borderColorHex - The hex value of the border color to set, or 'No Style'.
* @param {string} backgroundColorHex - The hex value of the background color to set, or 'No Style'.
* @param {string} textColorHex - The hex value of the text color to set, or 'No Style'.
* @param {import('@playwright/test').Locator} locator - The Playwright locator for the element whose style is to be set.
*/
async function setStyles(page, borderColorHex, backgroundColorHex, textColorHex, locator) {
await locator.click(); // Assuming the locator is clickable and opens the style setting UI
await page.getByLabel('Set border color').click();
await page.getByLabel(borderColorHex).click();
await page.getByLabel('Set background color').click();
await page.getByLabel(backgroundColorHex).click();
await page.getByLabel('Set text color').click();
await page.getByLabel(textColorHex).click();
}

/**
* Checks if the styles of an element match the expected values.
*
* @param {string} expectedBorderColor - The expected border color in RGB format. Default is '#e6b8af' or 'rgb(230, 184, 175)'
* @param {string} expectedBackgroundColor - The expected background color in RGB format.
* @param {string} expectedTextColor - The expected text color in RGB format. Default is #aaaaaa or 'rgb(170, 170, 170)'
* @param {import('@playwright/test').Locator} locator - The Playwright locator for the element whose style is to be checked.
*/
async function checkStyles(
expectedBorderColor,
expectedBackgroundColor,
expectedTextColor,
locator
) {
const layoutStyles = await locator.evaluate((el) => {
return {
border: window.getComputedStyle(el).getPropertyValue('border-top-color'), //infer the left, right, and bottom
background: window.getComputedStyle(el).getPropertyValue('background-color'),
fontColor: window.getComputedStyle(el).getPropertyValue('color')
};
});
expect(layoutStyles.border).toContain(expectedBorderColor);
expect(layoutStyles.background).toContain(expectedBackgroundColor);
expect(layoutStyles.fontColor).toContain(expectedTextColor);
}

/**
* Checks if the font Styles of an element match the expected values.
*
* @param {string} expectedFontSize - The expected font size in '72px' format. Default is 'Default'
* @param {string} expectedFontWeight - The expected font Type. Format as '700' for bold. Default is 'Default'
* @param {string} expectedFontFamily - The expected font Type. Format as "\"Andale Mono\", sans-serif". Default is 'Default'
* @param {import('@playwright/test').Locator} locator - The Playwright locator for the element whose style is to be checked.
*/
async function checkFontStyles(expectedFontSize, expectedFontWeight, expectedFontFamily, locator) {
const layoutStyles = await locator.evaluate((el) => {
return {
fontSize: window.getComputedStyle(el).getPropertyValue('font-size'),
fontWeight: window.getComputedStyle(el).getPropertyValue('font-weight'),
fontFamily: window.getComputedStyle(el).getPropertyValue('font-family')
};
});
expect(layoutStyles.fontSize).toContain(expectedFontSize);
expect(layoutStyles.fontWeight).toContain(expectedFontWeight);
expect(layoutStyles.fontFamily).toContain(expectedFontFamily);
}

export { checkFontStyles, checkStyles, hexToRGB, setStyles };
2 changes: 1 addition & 1 deletion e2e/tests/framework/exampleTemplate.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async function renameTimerFrom3DotMenu(page, timerUrl, newNameForTimer) {
await page.goto(timerUrl);

// Click on 3 Dot Menu
await page.locator('button[title="More options"]').click();
await page.locator('button[title="More actions"]').click();

// Click text=Edit Properties...
await page.locator('text=Edit Properties...').click();
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/framework/generateLocalStorageData.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ test.describe('Generate Visual Test Data @localStorage @generatedata', () => {
const exampleTelemetry = await createExampleTelemetryObject(page);

// Make Link from Telemetry Object to Overlay Plot
await page.locator('button[title="More options"]').click();
await page.locator('button[title="More actions"]').click();

// Select 'Create Link' from dropdown
await page.getByRole('menuitem', { name: ' Create Link' }).click();
Expand Down Expand Up @@ -206,7 +206,7 @@ test.describe('Generate Visual Test Data @localStorage @generatedata', () => {
const swgWith5sDelay = await createExampleTelemetryObject(page, overlayPlot.uuid);

await page.goto(swgWith5sDelay.url);
await page.getByTitle('More options').click();
await page.getByTitle('More actions').click();
await page.getByRole('menuitem', { name: ' Edit Properties...' }).click();

//Edit Example Telemetry Object to include 5s loading Delay
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/functional/clearDataAction.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test.describe('Clear Data Action', () => {
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();
await page.getByTitle('More actions').click();
const clearDataMenuItem = page.getByRole('menuitem', {
name: 'Clear Data'
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/functional/forms.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ test.describe('Persistence operations @couchdb', () => {
});

// Open the edit form for the clock object
await page.click('button[title="More options"]');
await page.click('button[title="More actions"]');
await page.click('li[title="Edit properties of this object."]');

// Modify the display format from default 12hr -> 24hr and click 'Save'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ test.describe.serial('Condition Set CRUD Operations on @localStorage', () => {
.first()
.click();
// Click hamburger button
await page.locator('[title="More options"]').click();
await page.locator('[title="More actions"]').click();

// Click 'Remove' and press OK
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
Expand Down Expand Up @@ -366,7 +366,7 @@ test.describe('Basic Condition Set Use', () => {

// Edit SWG to add 8 second loading delay to simulate the case
// where telemetry is not available.
await page.getByTitle('More options').click();
await page.getByTitle('More actions').click();
await page.getByRole('menuitem', { name: 'Edit Properties...' }).click();
await page.getByRole('spinbutton', { name: 'Loading Delay (ms)' }).fill('8000');
await page.getByLabel('Save').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,18 @@ test.describe('Flexible Layout Toolbar Actions @localStorage', () => {
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/7234'
});
expect(await page.getByRole('group', { name: 'Container' }).count()).toEqual(2);
await page.getByRole('group', { name: 'Container' }).nth(1).click();

const containerHandles = page.getByRole('columnheader', { name: 'Handle' });
expect(await containerHandles.count()).toEqual(2);
await page.getByRole('columnheader', { name: 'Container Handle 1' }).click();
await page.getByTitle('Add Container').click();
expect(await page.getByRole('group', { name: 'Container' }).count()).toEqual(3);
expect(await containerHandles.count()).toEqual(3);
await page.getByTitle('Remove Container').click();
await expect(page.getByRole('dialog')).toHaveText(
'This action will permanently delete this container from this Flexible Layout. Do you want to continue?'
);
await page.getByRole('button', { name: 'OK' }).click();
expect(await page.getByRole('group', { name: 'Container' }).count()).toEqual(2);
expect(await containerHandles.count()).toEqual(2);
});
test('Remove Frame', async ({ page }) => {
expect(await page.getByRole('group', { name: 'Frame' }).count()).toEqual(2);
Expand All @@ -305,11 +307,12 @@ test.describe('Flexible Layout Toolbar Actions @localStorage', () => {
expect(await page.getByRole('group', { name: 'Frame' }).count()).toEqual(1);
});
test('Columns/Rows Layout Toggle', async ({ page }) => {
await page.getByRole('group', { name: 'Container' }).nth(1).click();
expect(await page.locator('.c-fl--rows').count()).toEqual(0);
await page.getByRole('columnheader', { name: 'Container Handle 1' }).click();
const flexRows = page.getByLabel('Flexible Layout Row');
expect(await flexRows.count()).toEqual(0);
await page.getByTitle('Columns layout').click();
expect(await page.locator('.c-fl--rows').count()).toEqual(1);
expect(await flexRows.count()).toEqual(1);
await page.getByTitle('Rows layout').click();
expect(await page.locator('.c-fl--rows').count()).toEqual(0);
expect(await flexRows.count()).toEqual(0);
});
});
4 changes: 2 additions & 2 deletions e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ test.describe('Gauge', () => {

// Create the gauge with defaults
await createDomainObjectWithDefaults(page, { type: 'Gauge' });
await page.click('button[title="More options"]');
await page.click('button[title="More actions"]');
await page.click('li[role="menuitem"]:has-text("Edit Properties")');
// FIXME: We need better selectors for these custom form controls
const displayCurrentValueSwitch = page.locator('.c-toggle-switch__slider >> nth=0');
Expand All @@ -148,7 +148,7 @@ test.describe('Gauge', () => {
const swgWith5sDelay = await createExampleTelemetryObject(page, gauge.uuid);

await page.goto(swgWith5sDelay.url);
await page.getByTitle('More options').click();
await page.getByTitle('More actions').click();
await page.getByRole('menuitem', { name: /Edit Properties.../ }).click();

//Edit Example Telemetry Object to include 5s loading Delay
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/functional/plugins/notebook/notebook.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ test.describe('Notebook export tests', () => {
test('can export notebook as text', async ({ page }) => {
await nbUtils.enterTextEntry(page, `Foo bar entry`);
// Click on 3 Dot Menu
await page.locator('button[title="More options"]').click();
await page.locator('button[title="More actions"]').click();
const downloadPromise = page.waitForEvent('download');

await page.getByRole('menuitem', { name: /Export Notebook as Text/ }).click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ test.describe('Snapshot Container tests', () => {
test.fixme(
'A snapshot can be Viewed, Annotated, display deleted, and saved from Container with 3 dot action menu',
async ({ page }) => {
await page.locator('.c-snapshot.c-ne__embed').first().getByTitle('More options').click();
await page.locator('.c-snapshot.c-ne__embed').first().getByTitle('More actions').click();
await page.getByRole('menuitem', { name: ' View Snapshot' }).click();
await expect(page.locator('.c-overlay__outer')).toBeVisible();
await page.getByTitle('Annotate').click();
Expand All @@ -118,7 +118,7 @@ test.describe('Snapshot Container tests', () => {
}
);
test('A snapshot can be Quick Viewed from Container with 3 dot action menu', async ({ page }) => {
await page.locator('.c-snapshot.c-ne__embed').first().getByTitle('More options').click();
await page.locator('.c-snapshot.c-ne__embed').first().getByTitle('More actions').click();
await page.getByRole('menuitem', { name: 'Quick View' }).click();
await expect(page.locator('.c-overlay__outer')).toBeVisible();
});
Expand Down Expand Up @@ -212,7 +212,7 @@ test.describe('Snapshot image tests', () => {
// expect two embedded images now
expect(await page.getByRole('img', { name: 'favicon-96x96.png thumbnail' }).count()).toBe(2);

await page.locator('.c-snapshot.c-ne__embed').first().getByTitle('More options').click();
await page.locator('.c-snapshot.c-ne__embed').first().getByTitle('More actions').click();

await page.getByRole('menuitem', { name: /Remove This Embed/ }).click();
await page.getByRole('button', { name: 'Ok', exact: true }).click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,18 @@ test.describe('Restricted Notebook with a page locked and with an embed @addInit

test('Allows embeds to be deleted if page unlocked @addInit', async ({ page }) => {
// Click embed popup menu
await page.locator('.c-ne__embed__name .c-icon-button').click();
await page.getByLabel('Notebook Entry').getByLabel('More actions').click();

const embedMenu = page.locator('body >> .c-menu');
const embedMenu = page.getByLabel('Super Menu');
await expect(embedMenu).toContainText('Remove This Embed');
});

test('Disallows embeds to be deleted if page locked @addInit', async ({ page }) => {
await lockPage(page);
// Click embed popup menu
await page.locator('.c-ne__embed__name .c-icon-button').click();
await page.getByLabel('Notebook Entry').getByLabel('More actions').click();

const embedMenu = page.locator('body >> .c-menu');
const embedMenu = page.getByLabel('Super Menu');
await expect(embedMenu).not.toContainText('Remove This Embed');
});
});
Expand All @@ -176,7 +176,7 @@ test.describe('can export restricted notebook as text', () => {
test('basic functionality ', async ({ page }) => {
await enterTextEntry(page, `Foo bar entry`);
// Click on 3 Dot Menu
await page.locator('button[title="More options"]').click();
await page.locator('button[title="More actions"]').click();
const downloadPromise = page.waitForEvent('download');

await page.getByRole('menuitem', { name: /Export Notebook as Text/ }).click();
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/functional/plugins/notebook/tags.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ test.describe('Tagging in Notebooks @addInit', () => {
test('Can delete objects with tags and neither return in search', async ({ page }) => {
await createNotebookEntryAndTags(page);
// Delete Notebook
await page.locator('button[title="More options"]').click();
await page.locator('button[title="More actions"]').click();
await page.locator('li[title="Remove this object from its containing object."]').click();
await page.locator('button:has-text("OK")').click();
await page.goto('./', { waitUntil: 'domcontentloaded' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ test.describe('Plot Rendering', () => {
async function editSineWaveToUseInfinityOption(page, sineWaveGeneratorObject) {
await page.goto(sineWaveGeneratorObject.url);
// Edit SWG properties to include infinity values
await page.locator('[title="More options"]').click();
await page.locator('[title="More actions"]').click();
await page.locator('[title="Edit properties of this object."]').click();
await page
.getByRole('switch', {
Expand Down
Loading

0 comments on commit 70de736

Please sign in to comment.