Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#7791): tc form shouldn't submit bounds changes on dismiss #7792

Merged
merged 8 commits into from
Jul 25, 2024
73 changes: 51 additions & 22 deletions e2e/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,61 +436,67 @@ async function setRealTimeMode(page) {
/**
* Set the values (hours, mins, secs) for the TimeConductor offsets when in realtime mode
* @param {import('@playwright/test').Page} page
* @param {OffsetValues} offset
* @param {import('@playwright/test').Locator} offsetButton
* @param {OffsetValues} offset - Object containing offset values
* @param {boolean} [offset.submitChanges=true] - If true, submit the offset changes; otherwise, discard them
*/
async function setTimeConductorOffset(
page,
{ startHours, startMins, startSecs, endHours, endMins, endSecs }
{ startHours, startMins, startSecs, endHours, endMins, endSecs, submitChanges = true }
) {
if (startHours) {
await page.getByRole('spinbutton', { name: 'Start offset hours' }).fill(startHours);
await page.getByLabel('Start offset hours').fill(startHours);
}

if (startMins) {
await page.getByRole('spinbutton', { name: 'Start offset minutes' }).fill(startMins);
await page.getByLabel('Start offset minutes').fill(startMins);
}

if (startSecs) {
await page.getByRole('spinbutton', { name: 'Start offset seconds' }).fill(startSecs);
await page.getByLabel('Start offset seconds').fill(startSecs);
}

if (endHours) {
await page.getByRole('spinbutton', { name: 'End offset hours' }).fill(endHours);
await page.getByLabel('End offset hours').fill(endHours);
}

if (endMins) {
await page.getByRole('spinbutton', { name: 'End offset minutes' }).fill(endMins);
await page.getByLabel('End offset minutes').fill(endMins);
}

if (endSecs) {
await page.getByRole('spinbutton', { name: 'End offset seconds' }).fill(endSecs);
await page.getByLabel('End offset seconds').fill(endSecs);
}

// Click the check button
await page.locator('.pr-time-input--buttons .icon-check').click();
if (submitChanges) {
await page.getByLabel('Submit time offsets').click();
} else {
await page.getByLabel('Discard changes and close time popup').click();
}
}

/**
* Set the values (hours, mins, secs) for the start time offset when in realtime mode
* @param {import('@playwright/test').Page} page
* @param {OffsetValues} offset
* @param {boolean} [submit=true] If true, submit the offset changes; otherwise, discard them
*/
async function setStartOffset(page, offset) {
async function setStartOffset(page, { submitChanges = true, ...offset }) {
// Click 'mode' button
await page.getByRole('button', { name: 'Time Conductor Mode', exact: true }).click();
await setTimeConductorOffset(page, offset);
await setTimeConductorOffset(page, { submitChanges, ...offset });
}

/**
* Set the values (hours, mins, secs) for the end time offset when in realtime mode
* @param {import('@playwright/test').Page} page
* @param {OffsetValues} offset
* @param {boolean} [submit=true] If true, submit the offset changes; otherwise, discard them
*/
async function setEndOffset(page, offset) {
async function setEndOffset(page, { submitChanges = true, ...offset }) {
// Click 'mode' button
await page.getByRole('button', { name: 'Time Conductor Mode', exact: true }).click();
await setTimeConductorOffset(page, offset);
await setTimeConductorOffset(page, { submitChanges, ...offset });
}

/**
Expand All @@ -499,17 +505,40 @@ async function setEndOffset(page, offset) {
* NOTE: Unless explicitly testing the Time Conductor itself, it is advised to instead
* navigate directly to the object with the desired time bounds using `navigateToObjectWithFixedTimeBounds()`.
* @param {import('@playwright/test').Page} page
* @param {string} startDate
* @param {string} endDate
* @param {Object} bounds - The time conductor bounds
* @param {string} [bounds.startDate] - The start date in YYYY-MM-DD format
* @param {string} [bounds.startTime] - The start time in HH:mm:ss format
* @param {string} [bounds.endDate] - The end date in YYYY-MM-DD format
* @param {string} [bounds.endTime] - The end time in HH:mm:ss format
* @param {boolean} [bounds.submitChanges=true] - If true, submit the changes; otherwise, discard them.
*/
async function setTimeConductorBounds(page, startDate, endDate) {
// Bring up the time conductor popup
expect(await page.locator('.l-shell__time-conductor.c-compact-tc').count()).toBe(1);
await page.click('.l-shell__time-conductor.c-compact-tc');
async function setTimeConductorBounds(page, { submitChanges = true, ...bounds }) {
const { startDate, endDate, startTime, endTime } = bounds;

await setTimeBounds(page, startDate, endDate);
// Open the time conductor popup
await page.getByRole('button', { name: 'Time Conductor Mode', exact: true }).click();

await page.keyboard.press('Enter');
if (startDate) {
await page.getByLabel('Start date').fill(startDate);
}

if (startTime) {
await page.getByLabel('Start time').fill(startTime);
}

if (endDate) {
await page.getByLabel('End date').fill(endDate);
}

if (endTime) {
await page.getByLabel('End time').fill(endTime);
}

if (submitChanges) {
await page.getByLabel('Submit time bounds').click();
} else {
await page.getByLabel('Discard changes and close time popup').click();
}
}

/**
Expand Down
27 changes: 17 additions & 10 deletions e2e/tests/framework/generateLocalStorageData.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,25 @@ test.describe('Generate Visual Test Data @localStorage @generatedata @clock', ()
end: '2024-11-12 20:11:11.000Z'
});

const NEW_GLOBAL_START_BOUNDS = '2024-11-11 19:11:11.000Z';
const NEW_GLOBAL_END_BOUNDS = '2024-11-11 20:11:11.000Z';

await setTimeConductorBounds(page, NEW_GLOBAL_START_BOUNDS, NEW_GLOBAL_END_BOUNDS);
const NEW_GLOBAL_START_DATE = '2024-11-11';
const NEW_GLOBAL_START_TIME = '19:11:11';
const NEW_GLOBAL_END_DATE = '2024-11-11';
const NEW_GLOBAL_END_TIME = '20:11:11';

await setTimeConductorBounds(page, {
startDate: NEW_GLOBAL_START_DATE,
startTime: NEW_GLOBAL_START_TIME,
endDate: NEW_GLOBAL_END_DATE,
endTime: NEW_GLOBAL_END_TIME
});

// Verify that the global time conductor bounds have been updated
expect(
await page.getByLabel('Global Time Conductor').getByLabel('Start bounds').textContent()
).toEqual(NEW_GLOBAL_START_BOUNDS);
expect(
await page.getByLabel('Global Time Conductor').getByLabel('End bounds').textContent()
).toEqual(NEW_GLOBAL_END_BOUNDS);
await expect(
page.getByLabel(`Start bounds: ${NEW_GLOBAL_START_DATE} ${NEW_GLOBAL_START_TIME}.000Z`)
).toBeVisible();
await expect(
page.getByLabel(`End bounds: ${NEW_GLOBAL_END_DATE} ${NEW_GLOBAL_END_TIME}.000Z`)
).toBeVisible();

//Save localStorage for future test execution
await context.storageState({
Expand Down
59 changes: 22 additions & 37 deletions e2e/tests/functional/plugins/plot/logPlot.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Tests to verify log plot functionality. Note this test suite if very much under
necessarily be used for reference when writing new tests in this area.
*/

import { setTimeConductorBounds } from '../../../../appActions.js';
import { createDomainObjectWithDefaults, setTimeConductorBounds } from '../../../../appActions.js';
import { expect, test } from '../../../../pluginFixtures.js';

test.describe('Log plot tests', () => {
Expand Down Expand Up @@ -86,51 +86,36 @@ async function makeOverlayPlot(page, myItemsFolderName) {
// Set a specific time range for consistency, otherwise it will change
// on every test to a range based on the current time.

const start = '2022-03-29 22:00:00.000Z';
const end = '2022-03-29 22:00:30.000Z';
const startDate = '2022-03-29';
const startTime = '22:00:00';
const endDate = '2022-03-29';
const endTime = '22:00:30';

await setTimeConductorBounds(page, start, end);
await setTimeConductorBounds(page, { startDate, startTime, endDate, endTime });

// create overlay plot

await page.locator('button.c-create-button').click();
await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click();
// Click OK button and wait for Navigate event
await Promise.all([
page.waitForLoadState(),
await page.getByRole('button', { name: 'Save' }).click(),
// Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message')
]);

// save the overlay plot
await saveOverlayPlot(page);
const overlayPlot = await createDomainObjectWithDefaults(page, {
type: 'Overlay Plot',
name: 'Unnamed Overlay Plot'
});

// create a sinewave generator
await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
name: 'Unnamed Sine Wave Generator',
parent: overlayPlot.uuid
});

await page.locator('button.c-create-button').click();
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
await page.getByLabel('More actions').click();
await page.getByLabel('Edit Properties...').click();

// set amplitude to 6, offset 4, data rate 2 hz
await page.getByLabel('Amplitude', { exact: true }).fill('6');
await page.getByLabel('Offset', { exact: true }).fill('4');
await page.getByLabel('Data Rate (hz)', { exact: true }).fill('2');

await page.getByLabel('Amplitude').fill('6');
await page.getByLabel('Offset').fill('4');
await page.getByLabel('Data Rate (hz)').fill('2');
await page.getByLabel('Save').click();

// Click OK button and wait for Navigate event
await Promise.all([
page.waitForLoadState(),
await page.getByRole('button', { name: 'Save' }).click(),
// Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message')
]);

// click on overlay plot
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
await Promise.all([
page.waitForLoadState(),
page.locator('text=Unnamed Overlay Plot').first().click()
]);
await page.goto(overlayPlot.url);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,14 @@ test.describe('Telemetry Table', () => {

// Subtract 5 minutes from the current end bound datetime and set it
// Bring up the time conductor popup
let endDate = await page.locator('[aria-label="End bounds"]').textContent();
endDate = new Date(endDate);
let endTimeStamp = await page.getByLabel('End bounds').textContent();
endTimeStamp = new Date(endTimeStamp);

endDate.setUTCMinutes(endDate.getUTCMinutes() - 5);
endDate = endDate.toISOString().replace(/T/, ' ');
endTimeStamp.setUTCMinutes(endTimeStamp.getUTCMinutes() - 5);
const endDate = endTimeStamp.toISOString().split('T')[0];
const endTime = endTimeStamp.toISOString().split('T')[1];

await setTimeConductorBounds(page, undefined, endDate);
await setTimeConductorBounds(page, { endDate, endTime });

await expect(tableWrapper).not.toHaveClass(/is-paused/);

Expand All @@ -131,7 +132,7 @@ test.describe('Telemetry Table', () => {

// Verify that it is <= our new end bound
const latestMilliseconds = Date.parse(latestTelemetryDate);
const endBoundMilliseconds = Date.parse(endDate);
const endBoundMilliseconds = Date.parse(endTimeStamp);
expect(latestMilliseconds).toBeLessThanOrEqual(endBoundMilliseconds);
});

Expand Down
Loading
Loading