From e831b31494bb91af2b08c5bb7846dd8b86b2ea53 Mon Sep 17 00:00:00 2001 From: Ammar Ansari Date: Fri, 27 Dec 2024 15:39:54 +0500 Subject: [PATCH 1/9] Upgrade Playwright to the latest version --- internal/e2e-js/package.json | 2 +- internal/e2e-realtime-api/package.json | 2 +- package-lock.json | 81 ++++++++++++++++++-------- 3 files changed, 60 insertions(+), 25 deletions(-) diff --git a/internal/e2e-js/package.json b/internal/e2e-js/package.json index 1f5fafc6c..b1bc77e8c 100644 --- a/internal/e2e-js/package.json +++ b/internal/e2e-js/package.json @@ -13,7 +13,7 @@ "vite": "^5.4.10" }, "devDependencies": { - "@playwright/test": "^1.35.1", + "@playwright/test": "^1.49.1", "playwrigth-ws-inspector": "^1.0.0" } } diff --git a/internal/e2e-realtime-api/package.json b/internal/e2e-realtime-api/package.json index de6a11029..c4e5d2de0 100644 --- a/internal/e2e-realtime-api/package.json +++ b/internal/e2e-realtime-api/package.json @@ -10,7 +10,7 @@ "test": "" }, "devDependencies": { - "@playwright/test": "^1.35.1", + "@playwright/test": "^1.49.1", "@types/tap": "^15.0.8", "esbuild-register": "^3.4.2" }, diff --git a/package-lock.json b/package-lock.json index 6935d82a3..f2011631b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,7 @@ "vite": "^5.4.10" }, "devDependencies": { - "@playwright/test": "^1.35.1", + "@playwright/test": "^1.49.1", "playwrigth-ws-inspector": "^1.0.0" } }, @@ -63,6 +63,22 @@ "node": ">=12" } }, + "internal/e2e-js/node_modules/@playwright/test": { + "version": "1.49.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.49.1.tgz", + "integrity": "sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.49.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, "internal/e2e-js/node_modules/@types/estree": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", @@ -257,7 +273,7 @@ "ws": "^8.17.1" }, "devDependencies": { - "@playwright/test": "^1.35.1", + "@playwright/test": "^1.49.1", "@types/tap": "^15.0.8", "esbuild-register": "^3.4.2" } @@ -277,6 +293,22 @@ "node": ">=12" } }, + "internal/e2e-realtime-api/node_modules/@playwright/test": { + "version": "1.49.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.49.1.tgz", + "integrity": "sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.49.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, "internal/e2e-realtime-api/node_modules/@types/estree": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", @@ -5083,24 +5115,6 @@ "node": ">=14" } }, - "node_modules/@playwright/test": { - "version": "1.35.1", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@types/node": "*", - "playwright-core": "1.35.1" - }, - "bin": { - "playwright": "cli.js" - }, - "engines": { - "node": ">=16" - }, - "optionalDependencies": { - "fsevents": "2.3.2" - } - }, "node_modules/@protobufjs/aspromise": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", @@ -12522,15 +12536,36 @@ "node": ">=8" } }, - "node_modules/playwright-core": { - "version": "1.35.1", + "node_modules/playwright": { + "version": "1.49.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.49.1.tgz", + "integrity": "sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.49.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright/node_modules/playwright-core": { + "version": "1.49.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.49.1.tgz", + "integrity": "sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg==", "dev": true, "license": "Apache-2.0", "bin": { "playwright-core": "cli.js" }, "engines": { - "node": ">=16" + "node": ">=18" } }, "node_modules/playwrigth-ws-inspector": { From 57c5f65c74c8f86881c05894b778b33cdf14ecc6 Mon Sep 17 00:00:00 2001 From: Ammar Ansari Date: Fri, 27 Dec 2024 15:47:32 +0500 Subject: [PATCH 2/9] specify the latest version in the CI --- .github/workflows/browser-js-production.yml | 2 +- .github/workflows/browser-js-staging.yml | 2 +- .github/workflows/realtime-api-production-euswcom.yml | 2 +- .github/workflows/realtime-api-production.yml | 2 +- .github/workflows/realtime-api-staging.yml | 2 +- .github/workflows/v2-webrtc-calling.yml | 2 +- internal/playground-js/src/fabric/index.js | 7 +++++-- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/browser-js-production.yml b/.github/workflows/browser-js-production.yml index 7804d862c..fbf180e39 100644 --- a/.github/workflows/browser-js-production.yml +++ b/.github/workflows/browser-js-production.yml @@ -44,7 +44,7 @@ jobs: - name: Install Playwright uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: '1.35.1' # TODO: Read from deps ? + PLAYWRIGHT_VERSION: '1.49.1' # TODO: Read from deps ? - name: Test run: npm run -w=@sw-internal/e2e-js dev -- --project ${{ matrix.project }} env: diff --git a/.github/workflows/browser-js-staging.yml b/.github/workflows/browser-js-staging.yml index 39800b3f4..c11ccb243 100644 --- a/.github/workflows/browser-js-staging.yml +++ b/.github/workflows/browser-js-staging.yml @@ -43,7 +43,7 @@ jobs: - name: Install Playwright uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: '1.35.1' # TODO: Read from deps ? + PLAYWRIGHT_VERSION: '1.49.1' # TODO: Read from deps ? - name: Test run: npm run -w=@sw-internal/e2e-js dev -- --project ${{ matrix.project }} env: diff --git a/.github/workflows/realtime-api-production-euswcom.yml b/.github/workflows/realtime-api-production-euswcom.yml index dc769f263..d89660397 100644 --- a/.github/workflows/realtime-api-production-euswcom.yml +++ b/.github/workflows/realtime-api-production-euswcom.yml @@ -30,7 +30,7 @@ jobs: - name: Install Playwright uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: '1.35.1' # TODO: Read from deps ? + PLAYWRIGHT_VERSION: '1.49.1' # TODO: Read from deps ? - name: Test id: run-tests run: npm run -w=@sw-internal/e2e-realtime-api dev diff --git a/.github/workflows/realtime-api-production.yml b/.github/workflows/realtime-api-production.yml index 3daa08b91..4c5aadc16 100644 --- a/.github/workflows/realtime-api-production.yml +++ b/.github/workflows/realtime-api-production.yml @@ -33,7 +33,7 @@ jobs: if: matrix.test_command == 'dev:playwright' uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: '1.35.1' + PLAYWRIGHT_VERSION: '1.49.1' - name: Test run: 'npm run -w=@sw-internal/e2e-realtime-api ${{ matrix.test_command }}' env: diff --git a/.github/workflows/realtime-api-staging.yml b/.github/workflows/realtime-api-staging.yml index 34037eef9..3d2036d8f 100644 --- a/.github/workflows/realtime-api-staging.yml +++ b/.github/workflows/realtime-api-staging.yml @@ -33,7 +33,7 @@ jobs: if: matrix.test_command == 'dev:playwright' uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: '1.35.1' + PLAYWRIGHT_VERSION: '1.49.1' - name: Test run: 'npm run -w=@sw-internal/e2e-realtime-api ${{ matrix.test_command }}' env: diff --git a/.github/workflows/v2-webrtc-calling.yml b/.github/workflows/v2-webrtc-calling.yml index 4524bf119..804517a4f 100644 --- a/.github/workflows/v2-webrtc-calling.yml +++ b/.github/workflows/v2-webrtc-calling.yml @@ -76,7 +76,7 @@ jobs: - name: Install Playwright uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: '1.35.1' # TODO: Read from deps ? + PLAYWRIGHT_VERSION: '1.49.1' # TODO: Read from deps ? - name: Run test for ${{ matrix.region.name }} id: run-tests run: npm run -w=@sw-internal/e2e-js dev -- v2WebrtcFromRest.spec.ts webrtcCalling.spec.ts diff --git a/internal/playground-js/src/fabric/index.js b/internal/playground-js/src/fabric/index.js index d906418f3..93d5cc57f 100644 --- a/internal/playground-js/src/fabric/index.js +++ b/internal/playground-js/src/fabric/index.js @@ -413,13 +413,13 @@ window.connect = async ({ reattach = false } = {}) => { /** * Hangup the roomObj if present */ -window.hangup = () => { +window.hangup = async () => { if (micAnalyzer) { micAnalyzer.destroy() } if (roomObj) { - roomObj.hangup() + await roomObj.hangup() } restoreUI() @@ -428,6 +428,9 @@ window.hangup = () => { const url = new URL(window.location.href) url.searchParams.delete('room') window.history.pushState({}, '', url) + + console.log('>> disconnect') + client.disconnect() } window.saveInLocalStorage = (e) => { From e4f437aa70dd2fb5a94b488870582d01788c55bc Mon Sep 17 00:00:00 2001 From: Ammar Ansari Date: Fri, 27 Dec 2024 15:58:17 +0500 Subject: [PATCH 3/9] remove the ws-inspector --- internal/e2e-js/.gitignore | 4 ++++ internal/e2e-js/fixtures.ts | 13 +++---------- internal/e2e-js/package.json | 3 +-- internal/playground-js/src/fabric/index.js | 7 ++----- package-lock.json | 12 +----------- 5 files changed, 11 insertions(+), 28 deletions(-) diff --git a/internal/e2e-js/.gitignore b/internal/e2e-js/.gitignore index 4c49bd78f..9554a247f 100644 --- a/internal/e2e-js/.gitignore +++ b/internal/e2e-js/.gitignore @@ -1 +1,5 @@ .env +node_modules/ +/test-results/ +/playwright-report/ +/playwright/.cache/ diff --git a/internal/e2e-js/fixtures.ts b/internal/e2e-js/fixtures.ts index 3ac0adc3e..646311317 100644 --- a/internal/e2e-js/fixtures.ts +++ b/internal/e2e-js/fixtures.ts @@ -1,5 +1,4 @@ import type { Video } from '@signalwire/js' -import { PageWithWsInspector, intercepWsTraffic } from 'playwrigth-ws-inspector' import { test as baseTest, expect, type Page } from '@playwright/test' import { CreateRelayAppResourceParams, @@ -17,9 +16,7 @@ type CustomPage = Page & { swNetworkUp: () => Promise } type CustomFixture = { - createCustomPage(options: { - name: string - }): Promise> + createCustomPage(options: { name: string }): Promise createCustomVanillaPage(options: { name: string }): Promise resource: { createVideoRoomResource: typeof createVideoRoomResource @@ -31,13 +28,9 @@ type CustomFixture = { const test = baseTest.extend({ createCustomPage: async ({ context }, use) => { - const maker = async (options: { - name: string - }): Promise> => { - let page = await context.newPage() + const maker = async (options: { name: string }): Promise => { + const page = await context.newPage() enablePageLogs(page, options.name) - //@ts-ignore - page = await intercepWsTraffic(page) // @ts-expect-error page.swNetworkDown = () => { diff --git a/internal/e2e-js/package.json b/internal/e2e-js/package.json index b1bc77e8c..d0f93751c 100644 --- a/internal/e2e-js/package.json +++ b/internal/e2e-js/package.json @@ -13,7 +13,6 @@ "vite": "^5.4.10" }, "devDependencies": { - "@playwright/test": "^1.49.1", - "playwrigth-ws-inspector": "^1.0.0" + "@playwright/test": "^1.49.1" } } diff --git a/internal/playground-js/src/fabric/index.js b/internal/playground-js/src/fabric/index.js index 93d5cc57f..d906418f3 100644 --- a/internal/playground-js/src/fabric/index.js +++ b/internal/playground-js/src/fabric/index.js @@ -413,13 +413,13 @@ window.connect = async ({ reattach = false } = {}) => { /** * Hangup the roomObj if present */ -window.hangup = async () => { +window.hangup = () => { if (micAnalyzer) { micAnalyzer.destroy() } if (roomObj) { - await roomObj.hangup() + roomObj.hangup() } restoreUI() @@ -428,9 +428,6 @@ window.hangup = async () => { const url = new URL(window.location.href) url.searchParams.delete('room') window.history.pushState({}, '', url) - - console.log('>> disconnect') - client.disconnect() } window.saveInLocalStorage = (e) => { diff --git a/package-lock.json b/package-lock.json index f2011631b..a544fc303 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,8 +44,7 @@ "vite": "^5.4.10" }, "devDependencies": { - "@playwright/test": "^1.49.1", - "playwrigth-ws-inspector": "^1.0.0" + "@playwright/test": "^1.49.1" } }, "internal/e2e-js/node_modules/@esbuild/aix-ppc64": { @@ -12568,15 +12567,6 @@ "node": ">=18" } }, - "node_modules/playwrigth-ws-inspector": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/playwrigth-ws-inspector/-/playwrigth-ws-inspector-1.0.0.tgz", - "integrity": "sha512-Y6UUPvgBSnk+uPFjHmnc1CGzrJNoAsMFWNqVKvKVAdSoVH7HnlvfExEqNMJk2NJP47IxzzKUduH99y7lElcIdQ==", - "dev": true, - "dependencies": { - "lodash": "^4.17.21" - } - }, "node_modules/polite-json": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/polite-json/-/polite-json-4.0.1.tgz", From 6f24639e7591ac34dee2312d26ce289b64700d98 Mon Sep 17 00:00:00 2001 From: Ammar Ansari Date: Fri, 27 Dec 2024 16:54:47 +0500 Subject: [PATCH 4/9] specify playwright version via package.json --- .github/workflows/browser-js-production.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/browser-js-production.yml b/.github/workflows/browser-js-production.yml index fbf180e39..921dc78b9 100644 --- a/.github/workflows/browser-js-production.yml +++ b/.github/workflows/browser-js-production.yml @@ -41,10 +41,16 @@ jobs: uses: ./.github/actions/build with: NODE_VERSION: ${{ matrix.node-version }} + - name: Get Playwright version + id: playwright-version + run: | + PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-js/package.json) + PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^} + echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: '1.49.1' # TODO: Read from deps ? + PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.playwright_version }} - name: Test run: npm run -w=@sw-internal/e2e-js dev -- --project ${{ matrix.project }} env: From 30ee48c164cb005986e6a62d99906bffe5ede61a Mon Sep 17 00:00:00 2001 From: Ammar Ansari Date: Fri, 27 Dec 2024 17:03:58 +0500 Subject: [PATCH 5/9] specify playwright version for all the CI --- .github/workflows/browser-js-production.yml | 2 +- .github/workflows/browser-js-staging.yml | 8 +++++++- .github/workflows/realtime-api-production-euswcom.yml | 8 +++++++- .github/workflows/realtime-api-production.yml | 8 +++++++- .github/workflows/realtime-api-staging.yml | 8 +++++++- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/browser-js-production.yml b/.github/workflows/browser-js-production.yml index 921dc78b9..166eb1a2c 100644 --- a/.github/workflows/browser-js-production.yml +++ b/.github/workflows/browser-js-production.yml @@ -45,7 +45,7 @@ jobs: id: playwright-version run: | PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-js/package.json) - PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^} + echo "Playwright version: $PLAYWRIGHT_VERSION" echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright uses: ./.github/actions/playwright diff --git a/.github/workflows/browser-js-staging.yml b/.github/workflows/browser-js-staging.yml index c11ccb243..993972606 100644 --- a/.github/workflows/browser-js-staging.yml +++ b/.github/workflows/browser-js-staging.yml @@ -40,10 +40,16 @@ jobs: uses: ./.github/actions/build with: NODE_VERSION: ${{ matrix.node-version }} + - name: Get Playwright version + id: playwright-version + run: | + PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-js/package.json) + echo "Playwright version: $PLAYWRIGHT_VERSION" + echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: '1.49.1' # TODO: Read from deps ? + PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.playwright_version }} - name: Test run: npm run -w=@sw-internal/e2e-js dev -- --project ${{ matrix.project }} env: diff --git a/.github/workflows/realtime-api-production-euswcom.yml b/.github/workflows/realtime-api-production-euswcom.yml index d89660397..d6151409f 100644 --- a/.github/workflows/realtime-api-production-euswcom.yml +++ b/.github/workflows/realtime-api-production-euswcom.yml @@ -27,10 +27,16 @@ jobs: uses: ./.github/actions/build with: NODE_VERSION: ${{ matrix.node-version }} + - name: Get Playwright version + id: playwright-version + run: | + PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-realtime-api/package.json) + echo "Playwright version: $PLAYWRIGHT_VERSION" + echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: '1.49.1' # TODO: Read from deps ? + PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.playwright_version }} - name: Test id: run-tests run: npm run -w=@sw-internal/e2e-realtime-api dev diff --git a/.github/workflows/realtime-api-production.yml b/.github/workflows/realtime-api-production.yml index 4c5aadc16..062fc9162 100644 --- a/.github/workflows/realtime-api-production.yml +++ b/.github/workflows/realtime-api-production.yml @@ -29,11 +29,17 @@ jobs: uses: ./.github/actions/build with: NODE_VERSION: ${{ matrix.node-version }} + - name: Get Playwright version + id: playwright-version + run: | + PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-realtime-api/package.json) + echo "Playwright version: $PLAYWRIGHT_VERSION" + echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright if: matrix.test_command == 'dev:playwright' uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: '1.49.1' + PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.playwright_version }} - name: Test run: 'npm run -w=@sw-internal/e2e-realtime-api ${{ matrix.test_command }}' env: diff --git a/.github/workflows/realtime-api-staging.yml b/.github/workflows/realtime-api-staging.yml index 3d2036d8f..435b71bbb 100644 --- a/.github/workflows/realtime-api-staging.yml +++ b/.github/workflows/realtime-api-staging.yml @@ -29,11 +29,17 @@ jobs: uses: ./.github/actions/build with: NODE_VERSION: ${{ matrix.node-version }} + - name: Get Playwright version + id: playwright-version + run: | + PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-realtime-api/package.json) + echo "Playwright version: $PLAYWRIGHT_VERSION" + echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright if: matrix.test_command == 'dev:playwright' uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: '1.49.1' + PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.playwright_version }} - name: Test run: 'npm run -w=@sw-internal/e2e-realtime-api ${{ matrix.test_command }}' env: From 1f178b7e5de867b93a05d6f606496803506723bd Mon Sep 17 00:00:00 2001 From: Ammar Ansari Date: Fri, 27 Dec 2024 17:10:59 +0500 Subject: [PATCH 6/9] remove caret --- .github/workflows/browser-js-production.yml | 1 + .github/workflows/browser-js-staging.yml | 1 + .github/workflows/realtime-api-production-euswcom.yml | 1 + .github/workflows/realtime-api-production.yml | 1 + .github/workflows/realtime-api-staging.yml | 1 + 5 files changed, 5 insertions(+) diff --git a/.github/workflows/browser-js-production.yml b/.github/workflows/browser-js-production.yml index 166eb1a2c..f80e440ed 100644 --- a/.github/workflows/browser-js-production.yml +++ b/.github/workflows/browser-js-production.yml @@ -45,6 +45,7 @@ jobs: id: playwright-version run: | PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-js/package.json) + PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^} echo "Playwright version: $PLAYWRIGHT_VERSION" echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright diff --git a/.github/workflows/browser-js-staging.yml b/.github/workflows/browser-js-staging.yml index 993972606..aed875e15 100644 --- a/.github/workflows/browser-js-staging.yml +++ b/.github/workflows/browser-js-staging.yml @@ -44,6 +44,7 @@ jobs: id: playwright-version run: | PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-js/package.json) + PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^} echo "Playwright version: $PLAYWRIGHT_VERSION" echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright diff --git a/.github/workflows/realtime-api-production-euswcom.yml b/.github/workflows/realtime-api-production-euswcom.yml index d6151409f..75cb05655 100644 --- a/.github/workflows/realtime-api-production-euswcom.yml +++ b/.github/workflows/realtime-api-production-euswcom.yml @@ -31,6 +31,7 @@ jobs: id: playwright-version run: | PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-realtime-api/package.json) + PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^} echo "Playwright version: $PLAYWRIGHT_VERSION" echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright diff --git a/.github/workflows/realtime-api-production.yml b/.github/workflows/realtime-api-production.yml index 062fc9162..d08695f64 100644 --- a/.github/workflows/realtime-api-production.yml +++ b/.github/workflows/realtime-api-production.yml @@ -33,6 +33,7 @@ jobs: id: playwright-version run: | PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-realtime-api/package.json) + PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^} echo "Playwright version: $PLAYWRIGHT_VERSION" echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright diff --git a/.github/workflows/realtime-api-staging.yml b/.github/workflows/realtime-api-staging.yml index 435b71bbb..25e5a5678 100644 --- a/.github/workflows/realtime-api-staging.yml +++ b/.github/workflows/realtime-api-staging.yml @@ -33,6 +33,7 @@ jobs: id: playwright-version run: | PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-realtime-api/package.json) + PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^} echo "Playwright version: $PLAYWRIGHT_VERSION" echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright From 93ab24fc37b573eefc63994fd30f8d14c08139c5 Mon Sep 17 00:00:00 2001 From: Ammar Ansari Date: Fri, 27 Dec 2024 17:26:23 +0500 Subject: [PATCH 7/9] revert changes for the playwrigth-ws-inspector --- internal/e2e-js/fixtures.ts | 13 ++++++++++--- internal/e2e-js/package.json | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/e2e-js/fixtures.ts b/internal/e2e-js/fixtures.ts index 646311317..3ac0adc3e 100644 --- a/internal/e2e-js/fixtures.ts +++ b/internal/e2e-js/fixtures.ts @@ -1,4 +1,5 @@ import type { Video } from '@signalwire/js' +import { PageWithWsInspector, intercepWsTraffic } from 'playwrigth-ws-inspector' import { test as baseTest, expect, type Page } from '@playwright/test' import { CreateRelayAppResourceParams, @@ -16,7 +17,9 @@ type CustomPage = Page & { swNetworkUp: () => Promise } type CustomFixture = { - createCustomPage(options: { name: string }): Promise + createCustomPage(options: { + name: string + }): Promise> createCustomVanillaPage(options: { name: string }): Promise resource: { createVideoRoomResource: typeof createVideoRoomResource @@ -28,9 +31,13 @@ type CustomFixture = { const test = baseTest.extend({ createCustomPage: async ({ context }, use) => { - const maker = async (options: { name: string }): Promise => { - const page = await context.newPage() + const maker = async (options: { + name: string + }): Promise> => { + let page = await context.newPage() enablePageLogs(page, options.name) + //@ts-ignore + page = await intercepWsTraffic(page) // @ts-expect-error page.swNetworkDown = () => { diff --git a/internal/e2e-js/package.json b/internal/e2e-js/package.json index d0f93751c..6112c20fa 100644 --- a/internal/e2e-js/package.json +++ b/internal/e2e-js/package.json @@ -13,6 +13,7 @@ "vite": "^5.4.10" }, "devDependencies": { - "@playwright/test": "^1.49.1" + "@playwright/test": "^1.49.1", + "playwrigth-ws-inspector": "^1.1.0" } } From cc70ebffb24903c73082faf21794e83267ce65a2 Mon Sep 17 00:00:00 2001 From: Ammar Ansari Date: Fri, 27 Dec 2024 17:26:41 +0500 Subject: [PATCH 8/9] revert changes for the playwrigth-ws-inspector --- package-lock.json | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index a544fc303..80c287710 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,8 @@ "vite": "^5.4.10" }, "devDependencies": { - "@playwright/test": "^1.49.1" + "@playwright/test": "^1.49.1", + "playwrigth-ws-inspector": "^1.1.0" } }, "internal/e2e-js/node_modules/@esbuild/aix-ppc64": { @@ -12567,6 +12568,16 @@ "node": ">=18" } }, + "node_modules/playwrigth-ws-inspector": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/playwrigth-ws-inspector/-/playwrigth-ws-inspector-1.1.0.tgz", + "integrity": "sha512-vF6rT9ue1W9zALiC8YbCcGvTnTU+VFlR1tRrl7GKl8N1djEC7PINLti1A21fyZAHq3ZuxtGoNm81Af9wxlQ8GQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash": "^4.17.21" + } + }, "node_modules/polite-json": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/polite-json/-/polite-json-4.0.1.tgz", From 585e1f2ff576dfd38c30afde016c6da409c6014e Mon Sep 17 00:00:00 2001 From: Ammar Ansari Date: Mon, 30 Dec 2024 17:44:06 +0500 Subject: [PATCH 9/9] get the playwright version inside the action --- .github/actions/playwright/action.yml | 39 +++++++++++++++++-- .github/workflows/browser-js-production.yml | 9 +---- .github/workflows/browser-js-staging.yml | 9 +---- .../realtime-api-production-euswcom.yml | 9 +---- .github/workflows/realtime-api-production.yml | 9 +---- .github/workflows/realtime-api-staging.yml | 9 +---- .github/workflows/v2-webrtc-calling.yml | 2 +- 7 files changed, 42 insertions(+), 44 deletions(-) diff --git a/.github/actions/playwright/action.yml b/.github/actions/playwright/action.yml index 4939bbfbf..0eaa6876e 100644 --- a/.github/actions/playwright/action.yml +++ b/.github/actions/playwright/action.yml @@ -3,20 +3,53 @@ description: Install playwright and required browsers inputs: PLAYWRIGHT_VERSION: - required: true - description: Playwright version to use + description: If provided, the action will use this version directly + required: false + PACKAGE_JSON_PATH: + description: Path to package.json where '@playwright/test' is defined + required: false + default: './internal/e2e-js/package.json' runs: using: composite steps: + - name: Validate input + shell: bash + run: | + # Ensure at least one of PLAYWRIGHT_VERSION or PACKAGE_JSON_PATH is passed + if [ -z "${{ inputs.PLAYWRIGHT_VERSION }}" ] && [ -z "${{ inputs.PACKAGE_JSON_PATH }}" ]; then + echo "Error: You must provide either PLAYWRIGHT_VERSION or PACKAGE_JSON_PATH." + exit 1 + fi + + - name: Get Playwright version + id: playwright-version + shell: bash + run: | + # If a version is explicitly provided, use that + if [ -n "${{ inputs.PLAYWRIGHT_VERSION }}" ]; then + DETECTED_VERSION="${{ inputs.PLAYWRIGHT_VERSION }}" + echo "Using explicit Playwright version: $DETECTED_VERSION" + else + # Otherwise, read it from package.json + echo "Reading Playwright version from ${{ inputs.PACKAGE_JSON_PATH }}" + DETECTED_VERSION=$(jq -r '.devDependencies["@playwright/test"]' "${{ inputs.PACKAGE_JSON_PATH }}") + DETECTED_VERSION=${DETECTED_VERSION#^} # Remove ^ + echo "Detected Playwright version: $DETECTED_VERSION" + fi + + echo "PLAYWRIGHT_VERSION=$DETECTED_VERSION" >> $GITHUB_ENV + - name: Cache playwright binaries uses: actions/cache@v4 id: playwright-cache with: path: | ~/.cache/ms-playwright - key: ${{ runner.os }}-playwright-${{ inputs.PLAYWRIGHT_VERSION }} + key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} + - if: steps.playwright-cache.outputs.cache-hit != 'true' name: Install Playwright shell: bash run: npx playwright install --with-deps chromium + diff --git a/.github/workflows/browser-js-production.yml b/.github/workflows/browser-js-production.yml index f80e440ed..2c46180c6 100644 --- a/.github/workflows/browser-js-production.yml +++ b/.github/workflows/browser-js-production.yml @@ -41,17 +41,10 @@ jobs: uses: ./.github/actions/build with: NODE_VERSION: ${{ matrix.node-version }} - - name: Get Playwright version - id: playwright-version - run: | - PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-js/package.json) - PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^} - echo "Playwright version: $PLAYWRIGHT_VERSION" - echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.playwright_version }} + PACKAGE_JSON_PATH: ./internal/e2e-js/package.json - name: Test run: npm run -w=@sw-internal/e2e-js dev -- --project ${{ matrix.project }} env: diff --git a/.github/workflows/browser-js-staging.yml b/.github/workflows/browser-js-staging.yml index aed875e15..faebbab4d 100644 --- a/.github/workflows/browser-js-staging.yml +++ b/.github/workflows/browser-js-staging.yml @@ -40,17 +40,10 @@ jobs: uses: ./.github/actions/build with: NODE_VERSION: ${{ matrix.node-version }} - - name: Get Playwright version - id: playwright-version - run: | - PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-js/package.json) - PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^} - echo "Playwright version: $PLAYWRIGHT_VERSION" - echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.playwright_version }} + PACKAGE_JSON_PATH: ./internal/e2e-js/package.json - name: Test run: npm run -w=@sw-internal/e2e-js dev -- --project ${{ matrix.project }} env: diff --git a/.github/workflows/realtime-api-production-euswcom.yml b/.github/workflows/realtime-api-production-euswcom.yml index 75cb05655..047a5abd1 100644 --- a/.github/workflows/realtime-api-production-euswcom.yml +++ b/.github/workflows/realtime-api-production-euswcom.yml @@ -27,17 +27,10 @@ jobs: uses: ./.github/actions/build with: NODE_VERSION: ${{ matrix.node-version }} - - name: Get Playwright version - id: playwright-version - run: | - PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-realtime-api/package.json) - PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^} - echo "Playwright version: $PLAYWRIGHT_VERSION" - echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.playwright_version }} + PACKAGE_JSON_PATH: ./internal/e2e-realtime-api/package.json - name: Test id: run-tests run: npm run -w=@sw-internal/e2e-realtime-api dev diff --git a/.github/workflows/realtime-api-production.yml b/.github/workflows/realtime-api-production.yml index d08695f64..b7312fc81 100644 --- a/.github/workflows/realtime-api-production.yml +++ b/.github/workflows/realtime-api-production.yml @@ -29,18 +29,11 @@ jobs: uses: ./.github/actions/build with: NODE_VERSION: ${{ matrix.node-version }} - - name: Get Playwright version - id: playwright-version - run: | - PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-realtime-api/package.json) - PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^} - echo "Playwright version: $PLAYWRIGHT_VERSION" - echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright if: matrix.test_command == 'dev:playwright' uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.playwright_version }} + PACKAGE_JSON_PATH: ./internal/e2e-realtime-api/package.json - name: Test run: 'npm run -w=@sw-internal/e2e-realtime-api ${{ matrix.test_command }}' env: diff --git a/.github/workflows/realtime-api-staging.yml b/.github/workflows/realtime-api-staging.yml index 25e5a5678..72aecd718 100644 --- a/.github/workflows/realtime-api-staging.yml +++ b/.github/workflows/realtime-api-staging.yml @@ -29,18 +29,11 @@ jobs: uses: ./.github/actions/build with: NODE_VERSION: ${{ matrix.node-version }} - - name: Get Playwright version - id: playwright-version - run: | - PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-realtime-api/package.json) - PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^} - echo "Playwright version: $PLAYWRIGHT_VERSION" - echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - name: Install Playwright if: matrix.test_command == 'dev:playwright' uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.playwright_version }} + PACKAGE_JSON_PATH: ./internal/e2e-realtime-api/package.json - name: Test run: 'npm run -w=@sw-internal/e2e-realtime-api ${{ matrix.test_command }}' env: diff --git a/.github/workflows/v2-webrtc-calling.yml b/.github/workflows/v2-webrtc-calling.yml index 804517a4f..5b7b402c3 100644 --- a/.github/workflows/v2-webrtc-calling.yml +++ b/.github/workflows/v2-webrtc-calling.yml @@ -76,7 +76,7 @@ jobs: - name: Install Playwright uses: ./.github/actions/playwright with: - PLAYWRIGHT_VERSION: '1.49.1' # TODO: Read from deps ? + PACKAGE_JSON_PATH: ./internal/e2e-js/package.json - name: Run test for ${{ matrix.region.name }} id: run-tests run: npm run -w=@sw-internal/e2e-js dev -- v2WebrtcFromRest.spec.ts webrtcCalling.spec.ts