diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 0bb5d08c45..e2835b810f 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -55,7 +55,8 @@ jobs: BROWSERSTACK_ACCESS_KEY : ${{ secrets.BROWSERSTACK_ACCESS_KEY }} - name: Upload screenshots as artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 + if: always() with: name: screenshots path: frontend/javascripts/test/screenshots diff --git a/.github/workflows/wkorg-nightly.yaml b/.github/workflows/wkorg-nightly.yaml index 532196e477..726be72e33 100644 --- a/.github/workflows/wkorg-nightly.yaml +++ b/.github/workflows/wkorg-nightly.yaml @@ -33,7 +33,8 @@ jobs: BROWSERSTACK_ACCESS_KEY : ${{ secrets.BROWSERSTACK_ACCESS_KEY }} - name: Upload screenshots as artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 + if: always() with: name: screenshots path: frontend/javascripts/test/screenshots-wkorg diff --git a/frontend/javascripts/test/puppeteer/dataset_rendering_helpers.ts b/frontend/javascripts/test/puppeteer/dataset_rendering_helpers.ts index 2c8cdd456e..d10fbe67d9 100644 --- a/frontend/javascripts/test/puppeteer/dataset_rendering_helpers.ts +++ b/frontend/javascripts/test/puppeteer/dataset_rendering_helpers.ts @@ -374,16 +374,19 @@ export function setupBeforeEachAndAfterEach() { browser_version: "latest", os: "os x", os_version: "mojave", + name: t.title, // add test name to BrowserStack session "browserstack.username": process.env.BROWSERSTACK_USERNAME, "browserstack.accessKey": process.env.BROWSERSTACK_ACCESS_KEY, }; - t.context.browser = await puppeteer.connect({ + const browser = await puppeteer.connect({ browserWSEndpoint: `ws://cdp.browserstack.com/puppeteer?caps=${encodeURIComponent( JSON.stringify(caps), )}`, }); + t.context.browser = browser; console.log(`\nRunning chrome version ${await t.context.browser.version()}\n`); + console.log(`\nBrowserStack Session Id ${await getBrowserstackSessionId(browser)}\n`); global.Headers = Headers; global.fetch = fetch; global.Request = Request; @@ -397,6 +400,17 @@ export function setupBeforeEachAndAfterEach() { }); } +async function getBrowserstackSessionId(browser: Browser) { + const page = await browser.newPage(); + const response = (await page.evaluate( + (_) => {}, + `browserstack_executor: ${JSON.stringify({ action: "getSessionDetails" })}`, + )) as unknown as string; + + const sessionDetails = await JSON.parse(response); + return sessionDetails.hashed_id; +} + export function checkBrowserstackCredentials() { if (process.env.BROWSERSTACK_USERNAME == null || process.env.BROWSERSTACK_ACCESS_KEY == null) { throw new Error(