mirror of
https://github.com/nasa/openmct.git
synced 2025-01-29 23:53:56 +00:00
440474b2e3
* fix: apply `is-style-invisible` className to image and alphanumeric items * test: generate storagestate file with basic condition set * refactor: small a11y additions for Toolbars * test: add suite for display layout conditional styling * fix: make condition true half of the time * fix: use a period of 5 so tests are more stable * test: mark as slow * test: use inline base64 image text instead of a url * fix: use vue reactivity system to conditionally show these objects * test: use tiny base64 image * fix: condition for v-show * fix: use both v-if and v-show to toggle visibility * refactor: convert to ES6 class * fix: remove focused test * fix: switch back to a div due to visual artifacts. settle for an aria role instead - IT'S CALLED COMPROMISE!
115 lines
5.4 KiB
JavaScript
115 lines
5.4 KiB
JavaScript
/*****************************************************************************
|
|
* Open MCT, Copyright (c) 2014-2024, 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 { fileURLToPath } from 'url';
|
|
|
|
import {
|
|
createDomainObjectWithDefaults,
|
|
navigateToObjectWithRealTime
|
|
} from '../../../../../appActions.js';
|
|
import { expect, test } from '../../../../../pluginFixtures.js';
|
|
|
|
const TINY_IMAGE_BASE64 =
|
|
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII';
|
|
|
|
test.describe('Display Layout Conditional Styling', () => {
|
|
test.use({
|
|
storageState: fileURLToPath(
|
|
new URL('../../../../../test-data/condition_set_storage.json', import.meta.url)
|
|
)
|
|
});
|
|
|
|
let displayLayout;
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
|
displayLayout = await createDomainObjectWithDefaults(page, {
|
|
type: 'Display Layout',
|
|
name: 'Test Display Layout'
|
|
});
|
|
});
|
|
|
|
test('Image Drawing Object can have visibility toggled conditionally', async ({ page }) => {
|
|
await page.getByLabel('Edit Object').click();
|
|
|
|
// Add Image Drawing Object to the layout
|
|
await page.getByLabel('Add Drawing Object').click();
|
|
await page.getByLabel('Image').click();
|
|
await page.getByLabel('Image URL').fill(TINY_IMAGE_BASE64);
|
|
await page.getByText('Ok').click();
|
|
|
|
// Use the "Test Condition Set" for conditional styling on the image
|
|
await page.getByRole('tab', { name: 'Styles' }).click();
|
|
await page.getByRole('button', { name: 'Use Conditional Styling...' }).click();
|
|
await page.getByLabel('Modal Overlay').getByLabel('Expand My Items folder').click();
|
|
await page.getByLabel('Modal Overlay').getByLabel('Preview Test Condition Set').click();
|
|
await page.getByText('Ok').click();
|
|
|
|
// Set the image to be hidden when the condition is met
|
|
await page.getByTitle('Visible').first().click();
|
|
await page.getByLabel('Save Style').first().click();
|
|
await page.getByLabel('Save', { exact: true }).click();
|
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
|
|
|
// Switch to real-time mode and verify that the image toggles visibility
|
|
await navigateToObjectWithRealTime(page, displayLayout.url);
|
|
await expect(page.getByLabel('Image View')).toBeVisible();
|
|
await expect(page.getByLabel('Image View')).toBeHidden();
|
|
|
|
// Reload the page and verify that the image toggles visibility
|
|
await page.reload({ waitUntil: 'domcontentloaded' });
|
|
await expect(page.getByLabel('Image View')).toBeVisible();
|
|
await expect(page.getByLabel('Image View')).toBeHidden();
|
|
});
|
|
|
|
test('Alphanumeric object can have visibility toggled conditionally', async ({ page }) => {
|
|
await page.getByLabel('Edit Object').click();
|
|
|
|
// Add Alphanumeric Object to the layout
|
|
await page.getByLabel('Expand My Items folder').click();
|
|
await page.getByLabel('Expand Test Condition Set').click();
|
|
await page.getByLabel('Preview VIPER Rover Heading').dragTo(page.getByLabel('Layout Grid'));
|
|
|
|
// Use the "Test Condition Set" for conditional styling on the alphanumeric
|
|
await page.getByRole('tab', { name: 'Styles' }).click();
|
|
await page.getByRole('button', { name: 'Use Conditional Styling...' }).click();
|
|
await page.getByLabel('Modal Overlay').getByLabel('Expand My Items folder').click();
|
|
await page.getByLabel('Modal Overlay').getByLabel('Preview Test Condition Set').click();
|
|
await page.getByText('Ok').click();
|
|
|
|
// Set the alphanumeric to be hidden when the condition is met
|
|
await page.getByTitle('Visible').first().click();
|
|
await page.getByLabel('Save Style').first().click();
|
|
await page.getByLabel('Save', { exact: true }).click();
|
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
|
|
|
// Switch to real-time mode and verify that the image toggles visibility
|
|
await navigateToObjectWithRealTime(page, displayLayout.url);
|
|
await expect(page.getByLabel('Alpha-numeric telemetry', { exact: true })).toBeVisible();
|
|
await expect(page.getByLabel('Alpha-numeric telemetry', { exact: true })).toBeHidden();
|
|
|
|
// Reload the page and verify that the alphanumeric toggles visibility
|
|
await page.reload({ waitUntil: 'domcontentloaded' });
|
|
await expect(page.getByLabel('Alpha-numeric telemetry', { exact: true })).toBeVisible();
|
|
await expect(page.getByLabel('Alpha-numeric telemetry', { exact: true })).toBeHidden();
|
|
});
|
|
});
|