2022-04-11 18:22:44 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* Open MCT, Copyright (c) 2014-2022, 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.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2022-05-04 16:15:39 +00:00
|
|
|
Testsuite for plot autoscale.
|
2022-04-11 18:22:44 +00:00
|
|
|
*/
|
|
|
|
|
2022-07-27 21:31:18 +00:00
|
|
|
const { test, expect } = require('../../../../pluginFixtures');
|
2022-04-11 18:22:44 +00:00
|
|
|
test.use({
|
|
|
|
viewport: {
|
|
|
|
width: 1280,
|
|
|
|
height: 720
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
[Staleness] API and Component Functionality (#6108)
* initial telemetry api updates for staleness support
* modifying staleness to a subsription style
* fixing variable name
* debuggin
* put the subscribe in the wrong place
* stale class for object views
* temp cyan border for testing
* added staleness to swg, working on stacked plot staleness
* WIP: stacked plot staleness
* reverting, going a different route
* staleness on stacked plots
* plot legend staleness
* remove debug code
* staleness for alphanumerics
* lad table and table set staleness
* overlay plot staleness
* remove debug code
* hardened lad staleness functionality fixed plots without composition bug
* adding staleness to gauges
* renaming telemetry age check functionality so it does not conflict with new staleness functionality
* couple one-off fixes here and there, and WIP for condition sets, moving to telemetry tables to facilitate styling of completed components
* small fix on lad tables, added staleness functionality to tables
* finishing up condition sets
* some cleaning up
* adding border to condition sets when an item is stale
* fixing dub sub
* addressing PR comment, moving repeated code to a function
* robustified the SWG stalenes provider, little fixes here and there as far as cleaning up listeners and... whatnot
* removing debug code
* typo fixes
* cleanin up debug code
* created a simple stalenes mixin for more basic usage in components
* more robustification, if a new staleness subscription happens, will now send the current staleness value if we have it, beefed up example stalenes swg provider
* beefed up staleness mixin a bit to give it more use
* copyright
* cleanin up ladtable code
* cleanin up ladtable code
* cleaning up lad table sets
* some minor updates
* Closes #6109
- New staleness glyph and font CSS added.
* Closes #6109
- Normalized staleness colors as theme constants.
- New mixins for staleness application to view elements.
- Applied staleness styling to all relevant view elements.
- TODO: smoke-test in Show theme.
* adding staleness utils helper, mixin and isStale functionalirty for telemtry api
* Closes #6109
- Refined style for Snow theme.
* need to have one domainObject per stalenes utility
* making sure we handle domains correctly while dealing with staleness
* couple fixes
* moving abort controller logic to a spot where it makes more sense
* added some more info for the StalenesProvider interface docs
* returning undefinded for ifStale requests with no provider
* debuggin
* debuggin
* missed "isStale" call in condtioncollections
* removing debug code and using mixin unsubscribe in gauge
* fixing tests
* more targeted tree item click
Co-authored-by: Charles Hacskaylo <charlesh88@gmail.com>
Co-authored-by: Andrew Henry <akhenry@gmail.com>
Co-authored-by: Scott Bell <scott@traclabs.com>
2023-01-23 18:27:04 +00:00
|
|
|
test.fixme('ExportAsJSON', () => {
|
2022-07-27 21:31:18 +00:00
|
|
|
test('User can set autoscale with a valid range @snapshot', async ({ page, openmctConfig }) => {
|
|
|
|
const { myItemsFolderName } = openmctConfig;
|
|
|
|
|
2022-05-13 17:55:34 +00:00
|
|
|
//This is necessary due to the size of the test suite.
|
2022-06-30 18:50:47 +00:00
|
|
|
test.slow();
|
2022-05-13 17:55:34 +00:00
|
|
|
|
2022-07-25 20:21:41 +00:00
|
|
|
await page.goto('./', { waitUntil: 'networkidle' });
|
2022-04-11 18:22:44 +00:00
|
|
|
|
|
|
|
await setTimeRange(page);
|
|
|
|
|
2022-07-27 21:31:18 +00:00
|
|
|
await createSinewaveOverlayPlot(page, myItemsFolderName);
|
2022-04-11 18:22:44 +00:00
|
|
|
|
|
|
|
await testYTicks(page, ['-1.00', '-0.50', '0.00', '0.50', '1.00']);
|
|
|
|
|
|
|
|
await turnOffAutoscale(page);
|
|
|
|
|
2022-06-30 18:50:47 +00:00
|
|
|
// Make sure that after turning off autoscale, the user selected range values start at the same values the plot had prior.
|
|
|
|
await testYTicks(page, ['-1.00', '-0.50', '0.00', '0.50', '1.00']);
|
|
|
|
|
2022-04-11 18:22:44 +00:00
|
|
|
const canvas = page.locator('canvas').nth(1);
|
|
|
|
|
2022-06-30 18:50:47 +00:00
|
|
|
await canvas.hover({trial: true});
|
|
|
|
|
2022-09-13 22:10:21 +00:00
|
|
|
expect(await canvas.screenshot()).toMatchSnapshot('autoscale-canvas-prepan.png', { animations: 'disabled' });
|
2022-04-11 18:22:44 +00:00
|
|
|
|
2022-06-30 18:50:47 +00:00
|
|
|
//Alt Drag Start
|
2022-04-11 18:22:44 +00:00
|
|
|
await page.keyboard.down('Alt');
|
|
|
|
|
|
|
|
await canvas.dragTo(canvas, {
|
|
|
|
sourcePosition: {
|
|
|
|
x: 200,
|
|
|
|
y: 200
|
|
|
|
},
|
|
|
|
targetPosition: {
|
|
|
|
x: 400,
|
|
|
|
y: 400
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-06-30 18:50:47 +00:00
|
|
|
//Alt Drag End
|
2022-04-11 18:22:44 +00:00
|
|
|
await page.keyboard.up('Alt');
|
|
|
|
|
|
|
|
// Ensure the drag worked.
|
2022-06-30 18:50:47 +00:00
|
|
|
await testYTicks(page, ['0.00', '0.50', '1.00', '1.50', '2.00']);
|
|
|
|
|
|
|
|
await canvas.hover({trial: true});
|
|
|
|
|
2022-09-13 22:10:21 +00:00
|
|
|
expect(await canvas.screenshot()).toMatchSnapshot('autoscale-canvas-panned.png', { animations: 'disabled' });
|
2022-04-11 18:22:44 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {import('@playwright/test').Page} page
|
|
|
|
* @param {string} start
|
|
|
|
* @param {string} end
|
|
|
|
*/
|
|
|
|
async function setTimeRange(page, start = '2022-03-29 22:00:00.000Z', end = '2022-03-29 22:00:30.000Z') {
|
|
|
|
// Set a specific time range for consistency, otherwise it will change
|
|
|
|
// on every test to a range based on the current time.
|
|
|
|
|
|
|
|
const timeInputs = page.locator('input.c-input--datetime');
|
|
|
|
await timeInputs.first().click();
|
|
|
|
await timeInputs.first().fill(start);
|
|
|
|
|
|
|
|
await timeInputs.nth(1).click();
|
|
|
|
await timeInputs.nth(1).fill(end);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {import('@playwright/test').Page} page
|
2022-07-27 21:31:18 +00:00
|
|
|
* @param {string} myItemsFolderName
|
2022-04-11 18:22:44 +00:00
|
|
|
*/
|
2022-07-27 21:31:18 +00:00
|
|
|
async function createSinewaveOverlayPlot(page, myItemsFolderName) {
|
2022-04-11 18:22:44 +00:00
|
|
|
// click create button
|
|
|
|
await page.locator('button:has-text("Create")').click();
|
|
|
|
|
|
|
|
// add overlay plot with defaults
|
2022-11-07 23:50:33 +00:00
|
|
|
await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click();
|
2022-04-11 18:22:44 +00:00
|
|
|
await Promise.all([
|
2022-05-04 16:15:39 +00:00
|
|
|
page.waitForNavigation(),
|
2022-11-07 23:50:33 +00:00
|
|
|
page.locator('button:has-text("OK")').click(),
|
2022-05-04 16:15:39 +00:00
|
|
|
//Wait for Save Banner to appear1
|
|
|
|
page.waitForSelector('.c-message-banner__message')
|
2022-04-11 18:22:44 +00:00
|
|
|
]);
|
2022-05-04 16:15:39 +00:00
|
|
|
//Wait until Save Banner is gone
|
2022-05-09 20:25:21 +00:00
|
|
|
await page.locator('.c-message-banner__close-button').click();
|
2022-05-04 16:15:39 +00:00
|
|
|
await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
|
2022-04-11 18:22:44 +00:00
|
|
|
|
|
|
|
// save (exit edit mode)
|
|
|
|
await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1).click();
|
|
|
|
await page.locator('text=Save and Finish Editing').click();
|
|
|
|
|
|
|
|
// click create button
|
|
|
|
await page.locator('button:has-text("Create")').click();
|
|
|
|
|
|
|
|
// add sine wave generator with defaults
|
2022-11-07 23:50:33 +00:00
|
|
|
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
|
2022-04-11 18:22:44 +00:00
|
|
|
await Promise.all([
|
2022-05-04 16:15:39 +00:00
|
|
|
page.waitForNavigation(),
|
2022-11-07 23:50:33 +00:00
|
|
|
page.locator('button:has-text("OK")').click(),
|
2022-05-04 16:15:39 +00:00
|
|
|
//Wait for Save Banner to appear1
|
|
|
|
page.waitForSelector('.c-message-banner__message')
|
2022-04-11 18:22:44 +00:00
|
|
|
]);
|
2022-05-04 16:15:39 +00:00
|
|
|
//Wait until Save Banner is gone
|
2022-05-09 20:25:21 +00:00
|
|
|
await page.locator('.c-message-banner__close-button').click();
|
2022-05-04 16:15:39 +00:00
|
|
|
await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
|
2022-04-11 18:22:44 +00:00
|
|
|
|
|
|
|
// focus the overlay plot
|
2022-07-27 21:31:18 +00:00
|
|
|
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
|
2022-04-11 18:22:44 +00:00
|
|
|
await Promise.all([
|
2022-05-04 16:15:39 +00:00
|
|
|
page.waitForNavigation(),
|
2022-04-11 18:22:44 +00:00
|
|
|
page.locator('text=Unnamed Overlay Plot').first().click()
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {import('@playwright/test').Page} page
|
|
|
|
*/
|
|
|
|
async function turnOffAutoscale(page) {
|
|
|
|
// enter edit mode
|
|
|
|
await page.locator('text=Unnamed Overlay Plot Snapshot >> button').nth(3).click();
|
|
|
|
|
|
|
|
// uncheck autoscale
|
2023-01-23 15:34:26 +00:00
|
|
|
await page.getByRole('listitem').filter({ hasText: 'Auto scale' }).getByRole('checkbox').uncheck();
|
2022-04-11 18:22:44 +00:00
|
|
|
|
|
|
|
// save
|
|
|
|
await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1).click();
|
2022-05-09 20:25:21 +00:00
|
|
|
await Promise.all([
|
|
|
|
page.locator('text=Save and Finish Editing').click(),
|
|
|
|
//Wait for Save Banner to appear
|
|
|
|
page.waitForSelector('.c-message-banner__message')
|
|
|
|
]);
|
|
|
|
//Wait until Save Banner is gone
|
|
|
|
await page.locator('.c-message-banner__close-button').click();
|
|
|
|
await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
|
2022-04-11 18:22:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {import('@playwright/test').Page} page
|
|
|
|
*/
|
|
|
|
async function testYTicks(page, values) {
|
|
|
|
const yTicks = page.locator('.gl-plot-y-tick-label');
|
2022-05-09 20:25:21 +00:00
|
|
|
await page.locator('canvas >> nth=1').hover();
|
2022-04-11 18:22:44 +00:00
|
|
|
let promises = [yTicks.count().then(c => expect(c).toBe(values.length))];
|
|
|
|
|
|
|
|
for (let i = 0, l = values.length; i < l; i += 1) {
|
|
|
|
promises.push(expect(yTicks.nth(i)).toHaveText(values[i])); // eslint-disable-line
|
|
|
|
}
|
|
|
|
|
|
|
|
await Promise.all(promises);
|
|
|
|
}
|