From dbbd291e20291e7a0486d6c39a18d426e2fe444e Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Thu, 9 Nov 2023 10:24:29 +0100 Subject: [PATCH] Support user journeys for WebPageReplay (#4005) * Support user journeys for WebPageReplay * Add missing params --- .github/workflows/docker.yml | 4 +++- bin/browsertimeWebPageReplay.js | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 446e878f34..6861202965 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -28,8 +28,10 @@ jobs: run: docker run --rm -v "$(pwd)":/sitespeed.io --network=host sitespeedio/sitespeed.io http://127.0.0.1:3001 -n 1 -b edge - name: Run test on slim container run: docker run --rm -v "$(pwd)":/sitespeed.io --network=host sitespeedio/sitespeed.io:slim http://127.0.0.1:3001 -n 1 --browsertime.firefox.preference "devtools.netmonitor.persistlog:true" - - name: Test WebPageReplay with Chrome + - name: Test WebPageReplay with Chrome run: docker run --cap-add=NET_ADMIN --rm -v "$(pwd)":/sitespeed.io -e REPLAY=true -e LATENCY=100 sitespeedio/sitespeed.io https://www.sitespeed.io -n 3 -b chrome + - name: Test WebPageReplay user journey with Chrome + run: docker run --cap-add=NET_ADMIN --rm -v "$(pwd)":/sitespeed.io -e REPLAY=true -e LATENCY=100 sitespeedio/sitespeed.io test/prepostscripts/multiWindows.cjs -n 1 -b chrome --multi - name: Test WebPageReplay with Firefox run: docker run --cap-add=NET_ADMIN --rm -v "$(pwd)":/sitespeed.io --network=host -e REPLAY=true -e LATENCY=100 sitespeedio/sitespeed.io https://www.sitespeed.io -n 3 -b firefox --browsertime.firefox.acceptInsecureCerts true - name: Run Chrome test with config diff --git a/bin/browsertimeWebPageReplay.js b/bin/browsertimeWebPageReplay.js index 76651cbc35..e05942fddb 100755 --- a/bin/browsertimeWebPageReplay.js +++ b/bin/browsertimeWebPageReplay.js @@ -36,9 +36,18 @@ try { throw e; } -async function testURLs(engine, urls) { +async function testURLs(engine, urls, isMulti) { try { await engine.start(); + + if(isMulti) { + const result = await engine.runMultiple(urls); + for (let errors of result[0].errors) { + if (errors.length > 0) { + process.exitCode = 1; + } + } + } else { for (let url of urls) { const result = await engine.run(url); for (let errors of result[0].errors) { @@ -47,6 +56,7 @@ async function testURLs(engine, urls) { } } } + } } finally { engine.stop(); } @@ -203,11 +213,12 @@ async function runBrowsertime() { ); } } + const engine = new BrowsertimeEngine(btOptions); - const urls = getURLs(parsed.argv._); + const urls = parsed.argv.multi ? parsed.argv._ : getURLs(parsed.argv._); try { - await testURLs(engine, urls); + await testURLs(engine, urls, parsed.argv.multi); } catch (e) { console.error('Could not run ' + e); process.exit(1);