2026-10-02 13:42:26 -04:00
// Read-only: opens Staging with the pre-built non-air playlist selected (via localStorage). No transport clicks.
const { chromium } = require ( 'playwright' ) ;
const OUT = '/home/zgaetano/media-command-guide/screenshots' ;
2026-10-06 10:09:45 -04:00
if ( ! process . env . DF _SESSION _COOKIE ) { console . error ( 'DF_SESSION_COOKIE env var not set — grab the dragonflight.sid cookie value from your browser devtools, export it, rerun.' ) ; process . exit ( 1 ) ; }
const COOKIE = process . env . DF _SESSION _COOKIE ;
2026-10-02 13:42:26 -04:00
const CH = 'ccea5e02-2c7e-4154-953b-1f9621336ceb' , PL = process . argv [ 2 ] ;
( async ( ) => {
const b = await chromium . launch ( { args : [ '--no-sandbox' ] } ) ;
const c = await b . newContext ( { viewport : { width : 1920 , height : 1080 } } ) ;
await c . addCookies ( [ { name : 'dragonflight.sid' , value : COOKIE , domain : 'mediacmdr.com' , path : '/' , httpOnly : true , secure : true } ] ) ;
await c . addInitScript ( ( [ k , v ] ) => localStorage . setItem ( k , v ) , [ 'df.staging.' + CH , PL ] ) ;
const p = await c . newPage ( ) ;
p . on ( 'request' , r => { if ( r . url ( ) . includes ( '/api/' ) && r . method ( ) !== 'GET' ) console . log ( 'WRITE' , r . method ( ) , r . url ( ) ) } ) ;
await p . goto ( 'https://mediacmdr.com/#playout' , { waitUntil : 'networkidle' } ) ; await p . waitForTimeout ( 8000 ) ;
await p . locator ( 'button' , { hasText : /^Staging$/ } ) . first ( ) . click ( ) ; await p . waitForTimeout ( 6000 ) ;
await p . screenshot ( { path : ` ${ OUT } /16g-playout-staging.png ` } ) ;
console . log ( ( await p . evaluate ( ( ) => document . body . innerText ) ) . match ( /STAGING[\s\S]{0,700}/ ) ? . [ 0 ] ) ;
await b . close ( ) ; } ) ( ) ;