[skip ci] test tweak
This commit is contained in:
1 parent
23401e7841
commit
6fd99afd8a
2 files changed
+43
-10
No files matched your search
@@ -6,7 +6,12 @@ import { utils } from 'roku-test-automation';
|
|||||||
const envFile = path.join(__dirname, '../.env');
|
const envFile = path.join(__dirname, '../.env');
|
||||||
const config = getEnvVars(['ROKU_DEV_TARGET', 'ROKU_DEVPASSWORD']);
|
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({
|
utils.setupEnvironmentFromConfig({
|
||||||
RokuDevice: {
|
RokuDevice: {
|
||||||
devices: [{
|
devices: [{
|
||||||
@@ -16,7 +21,7 @@ export function setupEnvironment() {
|
|||||||
},
|
},
|
||||||
ECP: {
|
ECP: {
|
||||||
default: {
|
default: {
|
||||||
launchChannelId: 'dev'
|
launchChannelId: appId,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
OnDeviceComponent: {
|
OnDeviceComponent: {
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
// integration test to play a video on the Roku device
|
// 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 { ecp, odc } from 'roku-test-automation';
|
||||||
import { setupEnvironment } from './common';
|
import { AppId, setupEnvironment } from './common';
|
||||||
import { Key } from 'roku-test-automation/client/dist/ECP';
|
import { Key } from 'roku-test-automation/client/dist/ECP';
|
||||||
|
|
||||||
setupEnvironment();
|
async function playVideoDev() {
|
||||||
|
setupEnvironment(AppId.DEV);
|
||||||
|
|
||||||
(async () => {
|
await ecp.sendLaunchChannel({ params: { contentId: "jNQXAC9IVRw" } });
|
||||||
await ecp.sendInput({ params: { contentId: "jNQXAC9IVRw" } });
|
await ecp.sleep(5000);
|
||||||
|
|
||||||
await odc.onFieldChangeOnce({
|
await odc.onFieldChangeOnce({
|
||||||
base: "scene",
|
base: "scene",
|
||||||
@@ -18,7 +18,35 @@ setupEnvironment();
|
|||||||
|
|
||||||
console.log("Video started playing");
|
console.log("Video started playing");
|
||||||
|
|
||||||
await ecp.sendKeypress(Key.Back);
|
|
||||||
|
|
||||||
await odc.shutdown();
|
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();
|
||||||
})();
|
})();
|
||||||
Reference in new issue
Block a user