diff --git a/.github/workflows/guardoni_pull_request.yml b/.github/workflows/guardoni_pull_request.yml index de201264b..91257a5b0 100644 --- a/.github/workflows/guardoni_pull_request.yml +++ b/.github/workflows/guardoni_pull_request.yml @@ -123,23 +123,27 @@ jobs: platforms/guardoni/dist platforms/ycai/studio/build + # - name: Install Xvfb + # run: sudo apt install xvfb + - name: Install dependencies run: yarn - name: Start PM2 - run: | - yarn pm2 start --env test ./platforms/ecosystem.config.js - sleep 5 + run: yarn pm2 start --env test ./platforms/ecosystem.config.js - name: Build Guardoni for ${{ matrix.config.os }} working-directory: ./platforms/guardoni run: ./scripts/cli-build.mjs - # - name: Test CLI - YT Home - # run: yarn guardoni cli-yt-test-home + - name: Test CLI - YT Home + working-directory: ./platforms/guardoni + env: + DISPLAY: ':99.0' + run: xvfb-run --auto-servernum ./scripts/cli-yt-test-home.mjs - # - name: Test CLI - YT Videos - # run: yarn guardoni cli-yt-test-videos + - name: Test CLI - YT Videos + run: yarn guardoni cli-yt-test-videos - name: Stop PM2 run: yarn pm2 stop all diff --git a/.yarn/cache/sleep-npm-6.1.0-aadd96e7a0-607465cdcf.zip b/.yarn/cache/sleep-npm-6.1.0-aadd96e7a0-607465cdcf.zip new file mode 100644 index 000000000..dd16e2bbb Binary files /dev/null and b/.yarn/cache/sleep-npm-6.1.0-aadd96e7a0-607465cdcf.zip differ diff --git a/.yarn/cache/xvfb-npm-0.4.0-70ab42b6f9-d8c446dd6e.zip b/.yarn/cache/xvfb-npm-0.4.0-70ab42b6f9-d8c446dd6e.zip new file mode 100644 index 000000000..4e36d9d54 Binary files /dev/null and b/.yarn/cache/xvfb-npm-0.4.0-70ab42b6f9-d8c446dd6e.zip differ diff --git a/platforms/guardoni/package.json b/platforms/guardoni/package.json index 3dfa37a79..1bd460f5e 100644 --- a/platforms/guardoni/package.json +++ b/platforms/guardoni/package.json @@ -130,7 +130,8 @@ "webpack": "^5.73.0", "webpack-bundle-analyzer": "^4.5.0", "webpack-cli": "^4.10.0", - "webpack-node-externals": "^3.0.0" + "webpack-node-externals": "^3.0.0", + "xvfb": "^0.4.0" }, "pkg": { "scripts": [ diff --git a/platforms/guardoni/scripts/cli-yt-test-home.mjs b/platforms/guardoni/scripts/cli-yt-test-home.mjs index 7a007dad8..4fb41172e 100755 --- a/platforms/guardoni/scripts/cli-yt-test-home.mjs +++ b/platforms/guardoni/scripts/cli-yt-test-home.mjs @@ -5,6 +5,7 @@ import { $, os, fetch } from 'zx'; import { normalizePlatform, getGuardoniCliPkgName } from './utils.mjs'; import dotenv from 'dotenv'; import assert from 'assert'; +// import Xvfb from 'xvfb'; dotenv.config({ path: '.env.development' }); @@ -30,6 +31,20 @@ void (async function () { `--secretKey=${process.env.SECRET_KEY}`, ]; + // start xvfb + // const xvfb = new Xvfb({ + // silent: true, + // reuse: true, + // xvfb_args: [':95'], + // }); + + // process.env.DISPLAY = ':95'; + + // xvfb.start((err) => { + // // eslint-disable-next-line no-console + // if (err) console.error(err); + // }); + // reject cookie modal await $`${cli} ${flags} yt-navigate --cookie-modal=reject --exit --headless=false`; @@ -54,6 +69,9 @@ void (async function () { await $`echo ${yt_home_experiment_public_key}`; + // wait the parser to finish process metadata + await $`sleep 5`; + assert.strictEqual(yt_home_experiment_public_key, process.env.PUBLIC_KEY); const metadata = await fetch( `http://localhost:9000/api/v2/metadata?experimentId=${yt_home_experiment_id}` @@ -61,4 +79,6 @@ void (async function () { assert.strictEqual(metadata[0].experimentId, yt_home_experiment_id); assert.strictEqual(metadata[0].type, 'home'); + + // xvfb.stop(); })(); diff --git a/platforms/guardoni/scripts/cli-yt-test-videos.mjs b/platforms/guardoni/scripts/cli-yt-test-videos.mjs index a6dda35bf..33df4e09e 100755 --- a/platforms/guardoni/scripts/cli-yt-test-videos.mjs +++ b/platforms/guardoni/scripts/cli-yt-test-videos.mjs @@ -54,6 +54,9 @@ void (async function () { assert.strictEqual(ytVideoExperimentPubKey, process.env.PUBLIC_KEY); + // wait the parser to finish process metadata + await $`sleep 5`; + const metadata = await fetch( `http://localhost:9000/api/v2/metadata?experimentId=${yt_video_experiment_id}` ).then((r) => r.json()); diff --git a/yarn.lock b/yarn.lock index 22c94f854..909dbfe1f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14656,6 +14656,7 @@ __metadata: webpack-cli: ^4.10.0 webpack-node-externals: ^3.0.0 ws: ^8.5.0 + xvfb: ^0.4.0 yaml: ^1.10.2 yargs: ^17.5.1 bin: @@ -24592,6 +24593,16 @@ __metadata: languageName: node linkType: hard +"sleep@npm:6.1.0": + version: 6.1.0 + resolution: "sleep@npm:6.1.0" + dependencies: + nan: ^2.13.2 + node-gyp: latest + checksum: 607465cdcfd630a80effcd44c887b29af7de061c5341ef99af064d6c08154d61bbb865626eb84868939cbcd668e9eb301a0ba320f5c2f5bc3f4b459492c6259e + languageName: node + linkType: hard + "slice-ansi@npm:^3.0.0": version: 3.0.0 resolution: "slice-ansi@npm:3.0.0" @@ -28296,6 +28307,18 @@ __metadata: languageName: node linkType: hard +"xvfb@npm:^0.4.0": + version: 0.4.0 + resolution: "xvfb@npm:0.4.0" + dependencies: + sleep: 6.1.0 + dependenciesMeta: + sleep: + optional: true + checksum: d8c446dd6e31a19067692b7ccd562758c855483b8e77275f95d77da136b5f94a1606b1b3f4e97fe85218f6a3ff8a39af05641c050c5396f4269f5914bd41eb65 + languageName: node + linkType: hard + "y18n@npm:^4.0.0": version: 4.0.3 resolution: "y18n@npm:4.0.3"