2121 *****************************************************************************/
2222import percySnapshot from '@percy/playwright' ;
2323
24- import { createDomainObjectWithDefaults , setRealTimeMode } from '../../appActions.js' ;
25- import { waitForAnimations } from '../../baseFixtures.js' ;
26- import { VISUAL_FIXED_URL } from '../../constants.js' ;
24+ import { createDomainObjectWithDefaults } from '../../appActions.js' ;
25+ import { MISSION_TIME , VISUAL_FIXED_URL } from '../../constants.js' ;
2726import { expect , test } from '../../pluginFixtures.js' ;
27+ const TEN_MINUTES = 10 * 60 * 1000 ;
2828
2929test . describe ( 'Visual - Example Imagery' , ( ) => {
3030 let exampleImagery ;
3131 let parentLayout ;
3232
3333 test . beforeEach ( async ( { page } ) => {
34+ //Start at UNIX epoch time while initializing. The clock needs to run so that debounce functions etc. work.
35+ await page . clock . install ( { time : 0 } ) ;
3436 await page . goto ( VISUAL_FIXED_URL , { waitUntil : 'domcontentloaded' } ) ;
3537
3638 parentLayout = await createDomainObjectWithDefaults ( page , {
@@ -54,6 +56,7 @@ test.describe('Visual - Example Imagery', () => {
5456 'https://raw.githubusercontent.com/nasa/openmct/554f77c42fec81cf0f63e62b278012cb08d82af9/e2e/test-data/rick.jpg,https://raw.githubusercontent.com/nasa/openmct/554f77c42fec81cf0f63e62b278012cb08d82af9/e2e/test-data/rick.jpg'
5557 ) ;
5658 await page . getByRole ( 'button' , { name : 'Save' } ) . click ( ) ;
59+ await page . clock . pauseAt ( MISSION_TIME ) ;
5760 await page . reload ( { waitUntil : 'domcontentloaded' } ) ;
5861
5962 //Hide the Browse and Inspect panes to make the image more stable
@@ -63,10 +66,10 @@ test.describe('Visual - Example Imagery', () => {
6366
6467 test ( 'Example Imagery in Fixed Time' , async ( { page, theme } ) => {
6568 await page . goto ( exampleImagery . url , { waitUntil : 'domcontentloaded' } ) ;
66-
67- // Wait for the thumbnails to finish their scroll animation
68- // (Wait until the rightmost thumbnail is in view)
69- await expect ( page . getByLabel ( 'Image Thumbnail from' ) . last ( ) ) . toBeInViewport ( ) ;
69+ // Scroll the rightmost thumbnail into view
70+ const lastImageThumbnail = page . getByLabel ( 'Image Thumbnail from' ) . last ( ) ;
71+ await lastImageThumbnail . scrollIntoViewIfNeeded ( ) ;
72+ await expect ( lastImageThumbnail ) . toBeInViewport ( ) ;
7073
7174 await expect ( page . getByLabel ( 'Image Wrapper' ) ) . toBeVisible ( ) ;
7275
@@ -80,22 +83,31 @@ test.describe('Visual - Example Imagery', () => {
8083 test ( 'Example Imagery in Real Time' , async ( { page, theme } ) => {
8184 await page . goto ( exampleImagery . url , { waitUntil : 'domcontentloaded' } ) ;
8285
83- // Wait for the thumbnails to finish their scroll animation
84- // (Wait until the rightmost thumbnail is in view)
85- await expect ( page . getByLabel ( 'Image Thumbnail from' ) . last ( ) ) . toBeInViewport ( ) ;
86- await setRealTimeMode ( page , true ) ;
86+ // Scroll the rightmost thumbnail into view
87+ await scrollLastThumbnailIntoView ( page ) ;
8788
88- await expect ( page . getByLabel ( 'Image Wrapper' ) ) . toBeVisible ( ) ;
89+ await page . getByRole ( 'button' , { name : 'Time Conductor Mode' , exact : true } ) . click ( ) ;
90+ await page . getByRole ( 'button' , { name : 'Time Conductor Mode Menu' } ) . click ( ) ;
91+ await page . getByRole ( 'menuitem' , { name : / R e a l - T i m e / } ) . click ( ) ;
92+ //dismiss the time conductor popup
93+ await page . getByLabel ( 'Submit time offsets' ) . click ( ) ;
94+ await page . clock . pauseAt ( MISSION_TIME + TEN_MINUTES ) ;
95+ await page . waitForURL ( / t c \. m o d e = l o c a l / ) ;
96+ await scrollLastThumbnailIntoView ( page ) ;
8997
90- await waitForAnimations ( page . locator ( '.animate-scroll' ) ) ;
9198 await percySnapshot ( page , `Example Imagery in Real Time (theme: ${ theme } )` ) ;
9299 } ) ;
93100
94101 test ( 'Example Imagery in Display Layout' , async ( { page, theme } ) => {
95102 await page . goto ( parentLayout . url , { waitUntil : 'domcontentloaded' } ) ;
96103
97104 await expect ( page . getByLabel ( 'Image Wrapper' ) ) . toBeVisible ( ) ;
98-
99105 await percySnapshot ( page , `Example Imagery in Display Layout (theme: ${ theme } )` ) ;
100106 } ) ;
101107} ) ;
108+
109+ async function scrollLastThumbnailIntoView ( page ) {
110+ const lastImageThumbnail = page . getByLabel ( 'Image Thumbnail from' ) . last ( ) ;
111+ await lastImageThumbnail . scrollIntoViewIfNeeded ( ) ;
112+ await expect ( lastImageThumbnail ) . toBeInViewport ( ) ;
113+ }
0 commit comments