2022-04-11 18:22:44 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* 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.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2022-05-04 16:15:39 +00:00
|
|
|
Testsuite for plot autoscale.
|
2022-04-11 18:22:44 +00:00
|
|
|
*/
|
|
|
|
|
2024-01-02 15:24:22 +00:00
|
|
|
import { createDomainObjectWithDefaults } from '../../../../appActions.js';
|
|
|
|
import { expect, test } from '../../../../pluginFixtures.js';
|
2022-04-11 18:22:44 +00:00
|
|
|
test.use({
|
|
|
|
viewport: {
|
|
|
|
width: 1280,
|
|
|
|
height: 720
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-02-07 23:19:50 +00:00
|
|
|
test.describe('Autoscale', () => {
|
2023-08-07 22:48:29 +00:00
|
|
|
test('User can set autoscale with a valid range @snapshot', async ({ page }) => {
|
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
|
|
|
|
2023-04-18 22:32:29 +00:00
|
|
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
2022-04-11 18:22:44 +00:00
|
|
|
|
2023-08-07 22:48:29 +00:00
|
|
|
const overlayPlot = await createDomainObjectWithDefaults(page, {
|
|
|
|
name: 'Test Overlay Plot',
|
|
|
|
type: 'Overlay Plot'
|
|
|
|
});
|
|
|
|
await createDomainObjectWithDefaults(page, {
|
|
|
|
name: 'Test Sine Wave Generator',
|
|
|
|
type: 'Sine Wave Generator',
|
|
|
|
parent: overlayPlot.uuid
|
|
|
|
});
|
2022-04-11 18:22:44 +00:00
|
|
|
|
2023-08-07 22:48:29 +00:00
|
|
|
// Switch to fixed time, start: 2022-03-28 22:00:00.000 UTC, end: 2022-03-28 22:00:30.000 UTC
|
|
|
|
await page.goto(
|
|
|
|
`${overlayPlot.url}?tc.mode=fixed&tc.startBound=1648591200000&tc.endBound=1648591230000&tc.timeSystem=utc&view=plot-overlay`
|
|
|
|
);
|
2022-04-11 18:22:44 +00:00
|
|
|
|
|
|
|
await testYTicks(page, ['-1.00', '-0.50', '0.00', '0.50', '1.00']);
|
|
|
|
|
2023-02-07 23:19:50 +00:00
|
|
|
// enter edit mode
|
|
|
|
await page.click('button[title="Edit"]');
|
|
|
|
|
2023-09-11 23:33:46 +00:00
|
|
|
await page.getByRole('tab', { name: 'Config' }).click();
|
2022-04-11 18:22:44 +00:00
|
|
|
await turnOffAutoscale(page);
|
|
|
|
|
2023-02-07 23:19:50 +00:00
|
|
|
await setUserDefinedMinAndMax(page, '-2', '2');
|
|
|
|
|
|
|
|
// save
|
|
|
|
await page.click('button[title="Save"]');
|
|
|
|
await Promise.all([
|
2023-11-16 18:31:35 +00:00
|
|
|
page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(),
|
2023-02-07 23:19:50 +00:00
|
|
|
//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' });
|
2023-05-18 21:54:46 +00:00
|
|
|
|
2023-08-10 16:20:16 +00:00
|
|
|
// Make sure that after turning off autoscale, the user entered range values are reflected in the ticks.
|
2023-02-07 23:19:50 +00:00
|
|
|
await testYTicks(page, [
|
|
|
|
'-2.00',
|
|
|
|
'-1.50',
|
|
|
|
'-1.00',
|
|
|
|
'-0.50',
|
|
|
|
'0.00',
|
|
|
|
'0.50',
|
|
|
|
'1.00',
|
|
|
|
'1.50',
|
|
|
|
'2.00'
|
|
|
|
]);
|
2022-06-30 18:50:47 +00: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 });
|
2023-04-18 22:32:29 +00:00
|
|
|
await expect(page.locator('.js-series-data-loaded')).toBeVisible();
|
2022-06-30 18:50:47 +00:00
|
|
|
|
2023-02-07 23:19:50 +00:00
|
|
|
expect
|
|
|
|
.soft(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.
|
2023-07-28 02:06:41 +00:00
|
|
|
await testYTicks(page, ['-0.50', '0.00', '0.50', '1.00', '1.50', '2.00', '2.50', '3.00']);
|
2022-06-30 18:50:47 +00:00
|
|
|
|
2023-08-10 16:20:16 +00:00
|
|
|
//Wait for canvas to stabilize.
|
2022-06-30 18:50:47 +00:00
|
|
|
await canvas.hover({ trial: true });
|
|
|
|
|
2023-02-07 23:19:50 +00:00
|
|
|
expect
|
|
|
|
.soft(await canvas.screenshot())
|
|
|
|
.toMatchSnapshot('autoscale-canvas-panned.png', { animations: 'disabled' });
|
2022-04-11 18:22:44 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {import('@playwright/test').Page} page
|
|
|
|
*/
|
|
|
|
async function turnOffAutoscale(page) {
|
|
|
|
// uncheck autoscale
|
2023-04-18 22:32:29 +00:00
|
|
|
await page.getByRole('checkbox', { name: 'Auto scale' }).uncheck();
|
2023-02-07 23:19:50 +00:00
|
|
|
}
|
2022-04-11 18:22:44 +00:00
|
|
|
|
2023-02-07 23:19:50 +00:00
|
|
|
/**
|
|
|
|
* @param {import('@playwright/test').Page} page
|
|
|
|
* @param {string} min
|
|
|
|
* @param {string} max
|
|
|
|
*/
|
|
|
|
async function setUserDefinedMinAndMax(page, min, max) {
|
|
|
|
// set minimum value
|
2023-04-18 22:32:29 +00:00
|
|
|
await page.getByRole('spinbutton').first().fill(min);
|
2023-02-07 23:19:50 +00:00
|
|
|
// set maximum value
|
2023-04-18 22:32:29 +00:00
|
|
|
await page.getByRole('spinbutton').nth(1).fill(max);
|
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) {
|
2023-02-07 23:19:50 +00:00
|
|
|
promises.push(expect.soft(yTicks.nth(i)).toHaveText(values[i])); // eslint-disable-line
|
2022-04-11 18:22:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
await Promise.all(promises);
|
|
|
|
}
|