From ac37b89f658c86650c61f8b708247c72ee72b951 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 8 Jan 2024 09:50:06 +0000 Subject: [PATCH 1/3] test(browser-integration-tests): Un-skip test and bump playwright --- .../browser-integration-tests/package.json | 4 +- .../Breadcrumbs/dom/click/test.ts | 105 +++++++++--------- yarn.lock | 27 +++-- 3 files changed, 71 insertions(+), 65 deletions(-) diff --git a/dev-packages/browser-integration-tests/package.json b/dev-packages/browser-integration-tests/package.json index 5c880aa59b8c..05f198cdf7cf 100644 --- a/dev-packages/browser-integration-tests/package.json +++ b/dev-packages/browser-integration-tests/package.json @@ -44,7 +44,7 @@ }, "dependencies": { "@babel/preset-typescript": "^7.16.7", - "@playwright/test": "^1.31.1", + "@playwright/test": "^1.40.1", "@sentry-internal/rrweb": "2.6.0", "@sentry/browser": "7.92.0", "@sentry/tracing": "7.92.0", @@ -52,7 +52,7 @@ "babel-loader": "^8.2.2", "html-webpack-plugin": "^5.5.0", "pako": "^2.1.0", - "playwright": "^1.31.1", + "playwright": "^1.40.1", "webpack": "^5.52.0" }, "devDependencies": { diff --git a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/click/test.ts b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/click/test.ts index 37ac97c633ca..93ceb1e70001 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/click/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/click/test.ts @@ -4,62 +4,57 @@ import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../../utils/fixtures'; import { getFirstSentryEnvelopeRequest } from '../../../../../utils/helpers'; -sentryTest( - 'captures Breadcrumb for clicks & debounces them for a second', - async ({ getLocalTestUrl, page, browserName }) => { - sentryTest.skip(browserName === 'chromium', 'This consistently flakes on chrome.'); - - const url = await getLocalTestUrl({ testDir: __dirname }); - - await page.route('**/foo', route => { - return route.fulfill({ - status: 200, - body: JSON.stringify({ - userNames: ['John', 'Jane'], - }), - headers: { - 'Content-Type': 'application/json', - }, - }); - }); - - const promise = getFirstSentryEnvelopeRequest(page); - - await page.goto(url); - - await page.click('#button1'); - // not debounced because other target - await page.click('#button2'); - // This should be debounced - await page.click('#button2'); - - // Wait a second for the debounce to finish - await page.waitForTimeout(1000); - await page.click('#button2'); - - const [eventData] = await Promise.all([promise, page.evaluate('Sentry.captureException("test exception")')]); - - expect(eventData.exception?.values).toHaveLength(1); - - expect(eventData.breadcrumbs).toEqual([ - { - timestamp: expect.any(Number), - category: 'ui.click', - message: 'body > button#button1[type="button"]', - }, - { - timestamp: expect.any(Number), - category: 'ui.click', - message: 'body > button#button2[type="button"]', - }, - { - timestamp: expect.any(Number), - category: 'ui.click', - message: 'body > button#button2[type="button"]', +sentryTest('captures Breadcrumb for clicks & debounces them for a second', async ({ getLocalTestUrl, page }) => { + const url = await getLocalTestUrl({ testDir: __dirname }); + + await page.route('**/foo', route => { + return route.fulfill({ + status: 200, + body: JSON.stringify({ + userNames: ['John', 'Jane'], + }), + headers: { + 'Content-Type': 'application/json', }, - ]); - }, -); + }); + }); + + const promise = getFirstSentryEnvelopeRequest(page); + + await page.goto(url); + + await page.click('#button1'); + // not debounced because other target + await page.click('#button2'); + // This should be debounced + await page.click('#button2'); + + // Wait a second for the debounce to finish + await page.waitForTimeout(1000); + await page.click('#button2'); + + const [eventData] = await Promise.all([promise, page.evaluate('Sentry.captureException("test exception")')]); + + expect(eventData.exception?.values).toHaveLength(1); + + expect(eventData.breadcrumbs).toEqual([ + { + timestamp: expect.any(Number), + category: 'ui.click', + message: 'body > button#button1[type="button"]', + }, + { + timestamp: expect.any(Number), + category: 'ui.click', + message: 'body > button#button2[type="button"]', + }, + { + timestamp: expect.any(Number), + category: 'ui.click', + message: 'body > button#button2[type="button"]', + }, + ]); +}); sentryTest( 'uses the annotated component name in the breadcrumb messages and adds it to the data object', diff --git a/yarn.lock b/yarn.lock index 48857bd5a97d..d022af682067 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4811,15 +4811,12 @@ resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== -"@playwright/test@^1.31.1": - version "1.31.1" - resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.31.1.tgz#39d6873dc46af135f12451d79707db7d1357455d" - integrity sha512-IsytVZ+0QLDh1Hj83XatGp/GsI1CDJWbyDaBGbainsh0p2zC7F4toUocqowmjS6sQff2NGT3D9WbDj/3K2CJiA== +"@playwright/test@^1.40.1": + version "1.40.1" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.40.1.tgz#9e66322d97b1d74b9f8718bacab15080f24cde65" + integrity sha512-EaaawMTOeEItCRvfmkI9v6rBkF1svM8wjl/YPRrg2N2Wmp+4qJYkWtJsbew1szfKKDm6fPLy4YAanBhIlf9dWw== dependencies: - "@types/node" "*" - playwright-core "1.31.1" - optionalDependencies: - fsevents "2.3.2" + playwright "1.40.1" "@polka/url@^1.0.0-next.20": version "1.0.0-next.21" @@ -24461,6 +24458,20 @@ playwright-core@1.31.1, playwright-core@^1.29.1: resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.31.1.tgz#4deeebbb8fb73b512593fe24bea206d8fd85ff7f" integrity sha512-JTyX4kV3/LXsvpHkLzL2I36aCdml4zeE35x+G5aPc4bkLsiRiQshU5lWeVpHFAuC8xAcbI6FDcw/8z3q2xtJSQ== +playwright-core@1.40.1: + version "1.40.1" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.40.1.tgz#442d15e86866a87d90d07af528e0afabe4c75c05" + integrity sha512-+hkOycxPiV534c4HhpfX6yrlawqVUzITRKwHAmYfmsVreltEl6fAZJ3DPfLMOODw0H3s1Itd6MDCWmP1fl/QvQ== + +playwright@1.40.1, playwright@^1.40.1: + version "1.40.1" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.40.1.tgz#a11bf8dca15be5a194851dbbf3df235b9f53d7ae" + integrity sha512-2eHI7IioIpQ0bS1Ovg/HszsN/XKNwEG1kbzSDDmADpclKc7CyqkHw7Mg2JCz/bbCxg25QUPcjksoMW7JcIFQmw== + dependencies: + playwright-core "1.40.1" + optionalDependencies: + fsevents "2.3.2" + playwright@^1.31.1: version "1.31.1" resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.31.1.tgz#66164cdc1506bc883c7a98b44714dfea50b22d50" From 804d0aaba9e501d43ab7ba3ae4ce2baaebae3f48 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 8 Jan 2024 10:44:10 +0000 Subject: [PATCH 2/3] .... --- .github/workflows/build.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 413dd3d88aa3..b8c72da7cd85 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -526,12 +526,18 @@ jobs: path: ${{ steps.npm-cache-dir.outputs.dir }} key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}} - name: Install Playwright browser if not cached - if: steps.playwright-cache.outputs.cache-hit != 'true' && matrix.node >= 14 + if: | + matrix.node >= 14 && + (steps.playwright-cache.outputs.cache-hit != 'true' || + (needs.job_get_metadata.outputs.is_release == 'false' && needs.job_get_metadata.outputs.force_skip_cache == 'false')) run: npx playwright install --with-deps env: PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}} - name: Install OS dependencies of Playwright if cache hit - if: steps.playwright-cache.outputs.cache-hit == 'true' && matrix.node >= 14 + if: | + matrix.node >= 14 && + (steps.playwright-cache.outputs.cache-hit != 'true' || + (needs.job_get_metadata.outputs.is_release == 'false' && needs.job_get_metadata.outputs.force_skip_cache == 'false')) run: npx playwright install-deps - name: Run tests env: @@ -591,12 +597,16 @@ jobs: path: ${{ steps.npm-cache-dir.outputs.dir }} key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}} - name: Install Playwright browser if not cached - if: steps.playwright-cache.outputs.cache-hit != 'true' + if: | + steps.playwright-cache.outputs.cache-hit != 'true' || + (needs.job_get_metadata.outputs.is_release == 'false' && needs.job_get_metadata.outputs.force_skip_cache == 'false') run: npx playwright install --with-deps env: PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}} - name: Install OS dependencies of Playwright if cache hit - if: steps.playwright-cache.outputs.cache-hit == 'true' + if: | + steps.playwright-cache.outputs.cache-hit != 'true' || + (needs.job_get_metadata.outputs.is_release == 'false' && needs.job_get_metadata.outputs.force_skip_cache == 'false') run: npx playwright install-deps - name: Run Playwright tests env: @@ -648,12 +658,16 @@ jobs: path: ${{ steps.npm-cache-dir.outputs.dir }} key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}} - name: Install Playwright browser if not cached - if: steps.playwright-cache.outputs.cache-hit != 'true' + if: | + steps.playwright-cache.outputs.cache-hit != 'true' || + (needs.job_get_metadata.outputs.is_release == 'false' && needs.job_get_metadata.outputs.force_skip_cache == 'false') run: npx playwright install --with-deps env: PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}} - name: Install OS dependencies of Playwright if cache hit - if: steps.playwright-cache.outputs.cache-hit == 'true' + if: | + steps.playwright-cache.outputs.cache-hit != 'true' || + (needs.job_get_metadata.outputs.is_release == 'false' && needs.job_get_metadata.outputs.force_skip_cache == 'false') run: npx playwright install-deps - name: Run Playwright Loader tests env: From 6d7938b6047886723d20e80e0aec0f1f4a2a36b7 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 8 Jan 2024 10:58:06 +0000 Subject: [PATCH 3/3] ... --- .github/workflows/build.yml | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b8c72da7cd85..5016dbc7dceb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -522,22 +522,17 @@ jobs: - uses: actions/cache@v3 name: Check if Playwright browser is cached id: playwright-cache + if: needs.job_get_metadata.outputs.force_skip_cache == 'false' with: path: ${{ steps.npm-cache-dir.outputs.dir }} key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}} - name: Install Playwright browser if not cached - if: | - matrix.node >= 14 && - (steps.playwright-cache.outputs.cache-hit != 'true' || - (needs.job_get_metadata.outputs.is_release == 'false' && needs.job_get_metadata.outputs.force_skip_cache == 'false')) + if: steps.playwright-cache.outputs.cache-hit != 'true' && matrix.node >= 14 run: npx playwright install --with-deps env: PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}} - name: Install OS dependencies of Playwright if cache hit - if: | - matrix.node >= 14 && - (steps.playwright-cache.outputs.cache-hit != 'true' || - (needs.job_get_metadata.outputs.is_release == 'false' && needs.job_get_metadata.outputs.force_skip_cache == 'false')) + if: steps.playwright-cache.outputs.cache-hit == 'true' && matrix.node >= 14 run: npx playwright install-deps - name: Run tests env: @@ -593,20 +588,17 @@ jobs: - uses: actions/cache@v3 name: Check if Playwright browser is cached id: playwright-cache + if: needs.job_get_metadata.outputs.force_skip_cache == 'false' with: path: ${{ steps.npm-cache-dir.outputs.dir }} key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}} - name: Install Playwright browser if not cached - if: | - steps.playwright-cache.outputs.cache-hit != 'true' || - (needs.job_get_metadata.outputs.is_release == 'false' && needs.job_get_metadata.outputs.force_skip_cache == 'false') + if: steps.playwright-cache.outputs.cache-hit != 'true' run: npx playwright install --with-deps env: PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}} - name: Install OS dependencies of Playwright if cache hit - if: | - steps.playwright-cache.outputs.cache-hit != 'true' || - (needs.job_get_metadata.outputs.is_release == 'false' && needs.job_get_metadata.outputs.force_skip_cache == 'false') + if: steps.playwright-cache.outputs.cache-hit == 'true' run: npx playwright install-deps - name: Run Playwright tests env: @@ -654,20 +646,17 @@ jobs: - uses: actions/cache@v3 name: Check if Playwright browser is cached id: playwright-cache + if: needs.job_get_metadata.outputs.force_skip_cache == 'false' with: path: ${{ steps.npm-cache-dir.outputs.dir }} key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}} - name: Install Playwright browser if not cached - if: | - steps.playwright-cache.outputs.cache-hit != 'true' || - (needs.job_get_metadata.outputs.is_release == 'false' && needs.job_get_metadata.outputs.force_skip_cache == 'false') + if: steps.playwright-cache.outputs.cache-hit != 'true' run: npx playwright install --with-deps env: PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}} - name: Install OS dependencies of Playwright if cache hit - if: | - steps.playwright-cache.outputs.cache-hit != 'true' || - (needs.job_get_metadata.outputs.is_release == 'false' && needs.job_get_metadata.outputs.force_skip_cache == 'false') + if: steps.playwright-cache.outputs.cache-hit == 'true' run: npx playwright install-deps - name: Run Playwright Loader tests env: