From 6fd99afd8ad1c05ab07aeb3e45968c204ab57bcc Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Wed, 22 Jan 2025 17:40:12 -0500 Subject: [PATCH] [skip ci] test tweak --- integration-tests/common.ts | 9 +++++-- integration-tests/play-video.ts | 44 +++++++++++++++++++++++++++------ 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/integration-tests/common.ts b/integration-tests/common.ts index 326a9433..f059cabe 100644 --- a/integration-tests/common.ts +++ b/integration-tests/common.ts @@ -6,7 +6,12 @@ import { utils } from 'roku-test-automation'; const envFile = path.join(__dirname, '../.env'); const config = getEnvVars(['ROKU_DEV_TARGET', 'ROKU_DEVPASSWORD']); -export function setupEnvironment() { +export enum AppId { + DEV = 'dev', + PROD = '693751', +} + +export function setupEnvironment(appId = AppId.DEV) { utils.setupEnvironmentFromConfig({ RokuDevice: { devices: [{ @@ -16,7 +21,7 @@ export function setupEnvironment() { }, ECP: { default: { - launchChannelId: 'dev' + launchChannelId: appId, } }, OnDeviceComponent: { diff --git a/integration-tests/play-video.ts b/integration-tests/play-video.ts index 110b6447..36b00a8f 100644 --- a/integration-tests/play-video.ts +++ b/integration-tests/play-video.ts @@ -1,14 +1,14 @@ // integration test to play a video on the Roku device -// 1. Run dev channel on the Roku device (Playlet (dev)) -// 2. npm run restart-app && npm run test:integration + import { ecp, odc } from 'roku-test-automation'; -import { setupEnvironment } from './common'; +import { AppId, setupEnvironment } from './common'; import { Key } from 'roku-test-automation/client/dist/ECP'; -setupEnvironment(); +async function playVideoDev() { + setupEnvironment(AppId.DEV); -(async () => { - await ecp.sendInput({ params: { contentId: "jNQXAC9IVRw" } }); + await ecp.sendLaunchChannel({ params: { contentId: "jNQXAC9IVRw" } }); + await ecp.sleep(5000); await odc.onFieldChangeOnce({ base: "scene", @@ -18,7 +18,35 @@ setupEnvironment(); console.log("Video started playing"); - await ecp.sendKeypress(Key.Back); - await odc.shutdown(); + await ecp.sendKeypress(Key.Home); +} + +async function playVideoProd() { + setupEnvironment(AppId.PROD); + + let playerState = (await ecp.getMediaPlayer()).state; + await ecp.sendLaunchChannel({ params: { contentId: "jNQXAC9IVRw" } }); + + const TIMEOUT = 20000; + const start = Date.now(); + while (Date.now() - start < TIMEOUT) { + const newPlayerState = (await ecp.getMediaPlayer()).state; + if (newPlayerState !== playerState) { + console.log("Player state changed: ", newPlayerState); + playerState = newPlayerState; + } + if (playerState === "play") { + console.log("Video started playing"); + break; + } + await ecp.sleep(1000); + } + + await ecp.sendKeypress(Key.Home); +} + +(async () => { + await playVideoDev(); + await playVideoProd(); })();