diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index f614340..d776e10 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -82,6 +82,15 @@ jobs: - run: npm run generate electriccinema.co.uk-portobello - run: npm run generate electriccinema.co.uk-white-city + - name: Save any test failure artifacts + if: failure() + uses: actions/upload-artifact@v4 + with: + name: playwright-failures + path: ./playwright-failures + if-no-files-found: ignore + retention-days: 7 + # Run post-data scripts - run: npm run output:highlight-hydration-misses-for-review diff --git a/.gitignore b/.gitignore index 186a004..e314b4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # output files output/* cache/* +playwright-failures/* # Logs logs diff --git a/common/bfi.org.uk/retrieve.js b/common/bfi.org.uk/retrieve.js index 8278b9b..ccda973 100644 --- a/common/bfi.org.uk/retrieve.js +++ b/common/bfi.org.uk/retrieve.js @@ -11,10 +11,17 @@ async function getPageWithPlaywright(url, cacheKey, callback) { const browser = await chromium.launch({ headless: false }); const context = await browser.newContext(); const page = await context.newPage(); - await page.goto(url); - const result = await callback(page); - await browser.close(); - return result; + try { + await page.goto(url); + const result = await callback(page); + await browser.close(); + return result; + } catch (error) { + await page.screenshot({ + path: `./playwright-failures/error--${cacheKey}.png`, + }); + throw error; + } }); } @@ -49,9 +56,14 @@ async function processSearchResultPage( await page.waitForLoadState("networkidle"); // Make sure there's information showing. Not all pages have film info // (that we care about), so check for the rich text or media areas too - await page - .locator(".Film-info__information,.Rich-text,.Media") - .waitFor({ strict: false }); + try { + await page + .locator(".Film-info__information,.Rich-text,.Media") + .waitFor({ strict: false }); + } catch (error) { + console.error(`Page data not available at ${domain}${showUrl}`); + throw error; + } return await page.content(); },