clock, timeConductor and appActions fixes

This commit is contained in:
Shefali 2023-07-19 14:05:14 -07:00 committed by Jesse Mazzella
parent 4885c816dc
commit 72c432ffcc
4 changed files with 101 additions and 49 deletions

View File

@ -317,12 +317,13 @@ async function setTimeConductorMode(page, isFixedTimespan = true) {
const timeConductorMode = await page.locator('.c-compact-tc');
await timeConductorMode.click();
await timeConductorMode.locator('.js-mode-button').click();
const modeMenu = await page.locator('.c-conductor__mode-menu .c-super-menu__menu');
console.log(modeMenu);
// Switch time conductor mode
if (isFixedTimespan) {
await page.locator('data-testid=conductor-modeOption-fixed').click();
await modeMenu.getByRole('menuitem').first().click();
} else {
await page.locator('data-testid=conductor-modeOption-realtime').click();
await modeMenu.getByRole('menuitem').nth(1).click();
}
}
@ -353,21 +354,34 @@ 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 {Boolean} end is it the end offset?
* @param {import('@playwright/test').Locator} offsetButton
*/
async function setTimeConductorOffset(page, { hours, mins, secs }) {
// await offsetButton.click();
async function setTimeConductorOffset(page, { hours, mins, secs }, end) {
if (!end) {
if (hours) {
await page.locator('.pr-time-input__hrs').first().fill(hours);
}
if (hours) {
await page.fill('.pr-time-input__hrs', hours);
}
if (mins) {
await page.locator('.pr-time-input__mins').first().fill(mins);
}
if (mins) {
await page.fill('.pr-time-input__mins', mins);
}
if (secs) {
await page.locator('.pr-time-input__secs').first().fill(secs);
}
} else {
if (hours) {
await page.locator('.pr-time-input__hrs').nth(1).fill(hours);
}
if (secs) {
await page.fill('.pr-time-input__secs', secs);
if (mins) {
await page.locator('.pr-time-input__mins').nth(1).fill(mins);
}
if (secs) {
await page.locator('.pr-time-input__secs').nth(1).fill(secs);
}
}
// Click the check button
@ -383,7 +397,7 @@ async function setStartOffset(page, offset) {
// Click 'mode' button
const timeConductorMode = await page.locator('.c-compact-tc');
await timeConductorMode.click();
await setTimeConductorOffset(page, offset);
await setTimeConductorOffset(page, offset, false);
}
/**
@ -395,7 +409,37 @@ async function setEndOffset(page, offset) {
// Click 'mode' button
const timeConductorMode = await page.locator('.c-compact-tc');
await timeConductorMode.click();
await setTimeConductorOffset(page, offset);
await setTimeConductorOffset(page, offset, true);
}
async function setDateAndTime(page, startDate, endDate, independentTimeConductor) {
// Bring up the time conductor popup
const timeConductorMode = independentTimeConductor
? await page.locator('.c-conductor-holder--compact .c-compact-tc')
: await page.locator('.c-compact-tc');
await timeConductorMode.click();
if (startDate) {
const startDateLocator = page.locator('input[type="text"]').first();
const startTimeLocator = page.locator('input[type="text"]').nth(1);
// Click and fill start time
await startDateLocator.click();
await startDateLocator.fill(startDate.toString().substring(0, 10));
await startTimeLocator.click();
await startTimeLocator.fill(startDate.toString().substring(11, 19));
}
if (endDate) {
const endDateLocator = page.locator('input[type="text"]').nth(2);
const endTimeLocator = page.locator('input[type="text"]').nth(3);
// Click and fill end time
await endDateLocator.click();
await endDateLocator.fill(endDate.toString().substring(0, 10));
await endTimeLocator.click();
await endTimeLocator.fill(endDate.toString().substring(11, 19));
}
}
/**
@ -509,6 +553,7 @@ module.exports = {
setRealTimeMode,
setStartOffset,
setEndOffset,
setDateAndTime,
selectInspectorTab,
waitForPlotsToRender
};

View File

@ -41,7 +41,7 @@ test.describe('Clock Generator CRUD Operations', () => {
await page.click('button:has-text("Create")');
// Click Clock
await page.click('text=Clock');
await page.getByRole('menuitem').first().click();
// Click .icon-arrow-down
await page.locator('.icon-arrow-down').click();

View File

@ -25,7 +25,8 @@ const {
createDomainObjectWithDefaults,
setStartOffset,
setFixedTimeMode,
setRealTimeMode
setRealTimeMode,
setDateAndTime
} = require('../../../../appActions');
test.describe('Display Layout', () => {
@ -231,20 +232,31 @@ test.describe('Display Layout', () => {
let layoutGridHolder = page.locator('.l-layout__grid-holder');
await exampleImageryTreeItem.dragTo(layoutGridHolder);
//adjust so that we can see the independent time conductor toggle
// Adjust object height
await page.locator('div[title="Resize object height"] > input').click();
await page.locator('div[title="Resize object height"] > input').fill('70');
// Adjust object width
await page.locator('div[title="Resize object width"] > input').click();
await page.locator('div[title="Resize object width"] > input').fill('70');
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
// flip on independent time conductor
await page.getByTitle('Enable independent Time Conductor').first().locator('label').click();
await page.getByRole('textbox').nth(1).fill('2021-12-30 01:11:00.000Z');
await page.getByRole('textbox').nth(0).fill('2021-12-30 01:01:00.000Z');
await page.getByRole('textbox').nth(1).click();
await page.getByRole('switch').click();
const startDate = '2021-12-30 01:11:00.000Z';
const endDate = '2021-12-30 01:01:00.000Z';
await setDateAndTime(page, startDate, endDate, true);
await page.locator('.pr-time-input--buttons .icon-check').click();
// check image date
await expect(page.getByText('2021-12-30 01:11:00.000Z').first()).toBeVisible();
// flip it off
await page.getByTitle('Disable independent Time Conductor').first().locator('label').click();
await page.getByRole('switch').click();
// timestamp shouldn't be in the past anymore
await expect(page.getByText('2021-12-30 01:11:00.000Z')).toBeHidden();
});

View File

@ -25,7 +25,8 @@ const {
setFixedTimeMode,
setRealTimeMode,
setStartOffset,
setEndOffset
setEndOffset,
setDateAndTime
} = require('../../../../appActions');
test.describe('Time conductor operations', () => {
@ -40,38 +41,36 @@ test.describe('Time conductor operations', () => {
let endDate = 'xxxx-01-01 02:00:00.000Z';
endDate = year + endDate.substring(4);
const startTimeLocator = page.locator('input[type="text"]').first();
const endTimeLocator = page.locator('input[type="text"]').nth(1);
// Click start time
await startTimeLocator.click();
// Click end time
await endTimeLocator.click();
await endTimeLocator.fill(endDate.toString());
await startTimeLocator.fill(startDate.toString());
await setDateAndTime(page, startDate, endDate);
// invalid start date
startDate = year + 1 + startDate.substring(4);
await startTimeLocator.fill(startDate.toString());
await endTimeLocator.click();
await setDateAndTime(page, startDate);
const startDateValidityStatus = await startTimeLocator.evaluate((element) =>
// Bring up the time conductor popup
const timeConductorMode = await page.locator('.c-compact-tc');
await timeConductorMode.click();
const startDateLocator = page.locator('input[type="text"]').first();
const endDateLocator = page.locator('input[type="text"]').nth(2);
await endDateLocator.click();
const startDateValidityStatus = await startDateLocator.evaluate((element) =>
element.checkValidity()
);
expect(startDateValidityStatus).not.toBeTruthy();
// fix to valid start date
startDate = year - 1 + startDate.substring(4);
await startTimeLocator.fill(startDate.toString());
await setDateAndTime(page, startDate);
// invalid end date
endDate = year - 2 + endDate.substring(4);
await endTimeLocator.fill(endDate.toString());
await startTimeLocator.click();
await setDateAndTime(page, undefined, endDate);
const endDateValidityStatus = await endTimeLocator.evaluate((element) =>
await startDateLocator.click();
const endDateValidityStatus = await endDateLocator.evaluate((element) =>
element.checkValidity()
);
expect(endDateValidityStatus).not.toBeTruthy();
@ -100,15 +99,13 @@ test.describe('Time conductor input fields real-time mode', () => {
await setStartOffset(page, startOffset);
// Verify time was updated on time offset button
await expect(page.locator('data-testid=conductor-start-offset-button')).toContainText(
'00:30:23'
);
await expect(page.locator('.c-compact-tc__setting-value.icon-minus')).toContainText('00:30:23');
// Set end time offset
await setEndOffset(page, endOffset);
// Verify time was updated on preceding time offset button
await expect(page.locator('data-testid=conductor-end-offset-button')).toContainText('00:00:31');
await expect(page.locator('.c-compact-tc__setting-value.icon-plus')).toContainText('00:00:31');
});
/**
@ -150,12 +147,10 @@ test.describe('Time conductor input fields real-time mode', () => {
await setRealTimeMode(page);
// Verify updated start time offset persists after mode switch
await expect(page.locator('data-testid=conductor-start-offset-button')).toContainText(
'00:30:23'
);
await expect(page.locator('.c-compact-tc__setting-value.icon-minus')).toContainText('00:30:23');
// Verify updated end time offset persists after mode switch
await expect(page.locator('data-testid=conductor-end-offset-button')).toContainText('00:00:01');
await expect(page.locator('.c-compact-tc__setting-value.icon-plus')).toContainText('00:00:01');
// Verify url parameters persist after mode switch
await page.waitForNavigation({ waitUntil: 'networkidle' });