Skip to content

Commit

Permalink
[skip ci] simple integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
iBicha committed Jan 16, 2025
1 parent f6d8afc commit 57cdb59
Show file tree
Hide file tree
Showing 4 changed files with 1,299 additions and 11 deletions.
43 changes: 43 additions & 0 deletions integration-tests/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const dotenv = require('dotenv');
const fs = require('fs');
const path = require('path');
import { utils } from 'roku-test-automation';

const envFile = path.join(__dirname, '../.env');
const config = getEnvVars(['ROKU_DEV_TARGET', 'ROKU_DEVPASSWORD']);

export function setupEnvironment() {
utils.setupEnvironmentFromConfig({
RokuDevice: {
devices: [{
host: config.ROKU_DEV_TARGET,
password: config.ROKU_DEVPASSWORD
}]
},
ECP: {
default: {
launchChannelId: 'dev'
}
},
OnDeviceComponent: {
logLevel: 'info'
}
})
}

function getEnvVars(requiredVars = undefined) {
let envVars = process.env;
if (fs.existsSync(envFile)) {
const envConfig = dotenv.parse(fs.readFileSync(envFile));
envVars = { ...envVars, ...envConfig };
}
if (requiredVars) {
const missingVars = requiredVars.filter((key) => !envVars[key]);
if (missingVars.length) {
throw new Error(`Missing environment variables: ${missingVars.join(', ')}`);
}
}

return envVars;
}

21 changes: 21 additions & 0 deletions integration-tests/play-video.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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';

setupEnvironment();

(async () => {
await ecp.sendInput({ params: { contentId: "jNQXAC9IVRw" } });

await odc.onFieldChangeOnce({
base: "scene",
keyPath: "#VideoQueue.player.state",
match: "playing",
});

console.log("Video started playing");

await odc.shutdown();
})();
Loading

0 comments on commit 57cdb59

Please sign in to comment.