diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 54ebce92e..2cddf55fa 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -4,11 +4,11 @@ on: push: paths: - "apps/pwabuilder/**" - branches: [ main, dev ] + branches: [ tests-final, staging, main ] pull_request: paths: - "apps/pwabuilder/**" - branches: [ main, dev ] + branches: [ tests-final, staging, main ] jobs: test: timeout-minutes: 60 @@ -20,13 +20,17 @@ jobs: node-version: 16 - name: Install dependencies run: npm ci + - name: Install Playwright Test Globally + run: npm install -g @playwright/test - name: Install Playwright Browsers run: npx playwright install --with-deps + - name: Install Playwright Test Locally + run: npm install @playwright/test --save-dev - name: Run Playwright tests - run: npx playwright test + run: npx playwright test tests/basic.spec.ts tests/packaging.spec.ts tests/report-card.spec.ts - uses: actions/upload-artifact@v3 if: always() with: name: playwright-report path: playwright-report/ - retention-days: 30 \ No newline at end of file + retention-days: 30 diff --git a/apps/pwabuilder/package-lock.json b/apps/pwabuilder/package-lock.json index bbe70a145..50885e8d1 100644 --- a/apps/pwabuilder/package-lock.json +++ b/apps/pwabuilder/package-lock.json @@ -27,7 +27,7 @@ "devDependencies": { "@azure/msal-browser": "^2.37.0", "@istanbuljs/nyc-config-typescript": "^1.0.1", - "@playwright/test": "^1.32.3", + "@playwright/test": "^1.37.1", "@types/chai": "^4.2.21", "@types/lodash-es": "^4.17.4", "@types/mocha": "^8.2.3", @@ -1115,34 +1115,34 @@ "dev": true }, "node_modules/@playwright/test": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.33.0.tgz", - "integrity": "sha512-YunBa2mE7Hq4CfPkGzQRK916a4tuZoVx/EpLjeWlTVOnD4S2+fdaQZE0LJkbfhN5FTSKNLdcl7MoT5XB37bTkg==", + "version": "1.37.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.37.1.tgz", + "integrity": "sha512-bq9zTli3vWJo8S3LwB91U0qDNQDpEXnw7knhxLM0nwDvexQAwx9tO8iKDZSqqneVq+URd/WIoz+BALMqUTgdSg==", "dev": true, "dependencies": { "@types/node": "*", - "playwright-core": "1.33.0" + "playwright-core": "1.37.1" }, "bin": { "playwright": "cli.js" }, "engines": { - "node": ">=14" + "node": ">=16" }, "optionalDependencies": { "fsevents": "2.3.2" } }, "node_modules/@playwright/test/node_modules/playwright-core": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.33.0.tgz", - "integrity": "sha512-aizyPE1Cj62vAECdph1iaMILpT0WUDCq3E6rW6I+dleSbBoGbktvJtzS6VHkZ4DKNEOG9qJpiom/ZxO+S15LAw==", + "version": "1.37.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.37.1.tgz", + "integrity": "sha512-17EuQxlSIYCmEMwzMqusJ2ztDgJePjrbttaefgdsiqeLWidjYz9BxXaTaZWxH1J95SHGk6tjE+dwgWILJoUZfA==", "dev": true, "bin": { - "playwright": "cli.js" + "playwright-core": "cli.js" }, "engines": { - "node": ">=14" + "node": ">=16" } }, "node_modules/@pwabuilder/code-editor": { @@ -12587,20 +12587,20 @@ "dev": true }, "@playwright/test": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.33.0.tgz", - "integrity": "sha512-YunBa2mE7Hq4CfPkGzQRK916a4tuZoVx/EpLjeWlTVOnD4S2+fdaQZE0LJkbfhN5FTSKNLdcl7MoT5XB37bTkg==", + "version": "1.37.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.37.1.tgz", + "integrity": "sha512-bq9zTli3vWJo8S3LwB91U0qDNQDpEXnw7knhxLM0nwDvexQAwx9tO8iKDZSqqneVq+URd/WIoz+BALMqUTgdSg==", "dev": true, "requires": { "@types/node": "*", "fsevents": "2.3.2", - "playwright-core": "1.33.0" + "playwright-core": "1.37.1" }, "dependencies": { "playwright-core": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.33.0.tgz", - "integrity": "sha512-aizyPE1Cj62vAECdph1iaMILpT0WUDCq3E6rW6I+dleSbBoGbktvJtzS6VHkZ4DKNEOG9qJpiom/ZxO+S15LAw==", + "version": "1.37.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.37.1.tgz", + "integrity": "sha512-17EuQxlSIYCmEMwzMqusJ2ztDgJePjrbttaefgdsiqeLWidjYz9BxXaTaZWxH1J95SHGk6tjE+dwgWILJoUZfA==", "dev": true } } diff --git a/apps/pwabuilder/package.json b/apps/pwabuilder/package.json index eaa22b2e7..36fcae8fa 100644 --- a/apps/pwabuilder/package.json +++ b/apps/pwabuilder/package.json @@ -14,8 +14,7 @@ "start-remote": "vite --host", "postinstall": "npm run copy-sl-assets", "copy-sl-assets": "mkdirp ./public/assets/sl-icons/assets/icons && ncp ./node_modules/@shoelace-style/shoelace/dist/assets/icons ./public/assets/sl-icons/assets/icons", - "test": "npx nyc@latest playwright test", - "coverage": "cd coverage/lcov-report && npx http-server -p 3001" + "test": "playwright test" }, "author": "", "license": "ISC", @@ -37,7 +36,7 @@ "devDependencies": { "@azure/msal-browser": "^2.37.0", "@istanbuljs/nyc-config-typescript": "^1.0.1", - "@playwright/test": "^1.32.3", + "@playwright/test": "^1.37.1", "@types/chai": "^4.2.21", "@types/lodash-es": "^4.17.4", "@types/mocha": "^8.2.3", diff --git a/apps/pwabuilder/playwright-report/index.html b/apps/pwabuilder/playwright-report/index.html index 8baac694b..bb75c067e 100644 --- a/apps/pwabuilder/playwright-report/index.html +++ b/apps/pwabuilder/playwright-report/index.html @@ -7,7 +7,7 @@ Playwright Test Report - - @@ -59,4 +59,4 @@ \ No newline at end of file +window.playwrightReportBase64 = "data:application/zip;base64,UEsDBBQAAAgIAC9mFVdh3J1PxQMAAJ8ZAAAZAAAAODk0Njc0MWM1NTVhMGM0NTE1ZDguanNvbu1YTW/bOBD9K4RODuAo/NB3sQtsigV2Dy16CHpomgIyTcfalUSBojYJvP7vS0pqJTOKLbtKsAf7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Ok8iVZ0qInOXKWa4gbMoVNMjkieQKgu6ryxVsdL94X4d/rFwxAkInhjNWrjieGcvUcsXUQ/0C+TZyxfONGu0G2DvLlbNc+Z/IFXKWK2e58kZyhRhdmu53J5Ar5r9eryNXRlqZTK7cbf8DUEsDBBQAAAgIAC9mFVfeUlkMZAEAALoDAAALAAAAcmVwb3J0Lmpzb261U81OhDAQfpVNz7ihQEvh6smDnkw8mD3MlpKtFEroNNFseHdblrhr1JgYl9O0M3x/mR5JrxAaQCD1kYBED+bJTp2aHKmzhKBFMI+6V6SmKa3Ytiiyav34nJBWGxUmn49LddeQmoiq4GVBJWMMUlkwyhpBTpMPEIHIHpyWWzcquUUXWqgcnkBi9SPIDSsbXhW0lRxSWqZtWtCIjBpNhFWD85PawDgaLQG1HTbGQhMZxsm+KIkrvzxMtte+Dw1jT5PRfVT4jTqjh+g+T4i0xvdhlAXjjZ/WH3mW0oTAMISo4k10skuI9SjtQqdeAxaqJuoAPKztjtQ4eZWQSTlvVv+ACPLQq2E57+bdnPwWCq0EE7ngXIpM5iVt84b/JZR7uw/+N7cxG/VPyVBxxWTCqAu4Lgpc1nRZ2A/IePDD+ZiGFTTQvS2V6/Q4rrdnvrNymuUimyPFRUiR+HJ3Pid2VTlfn978DlBLAQI/AxQAAAgIAC9mFVdh3J1PxQMAAJ8ZAAAZAAAAAAAAAAAAAAC0gQAAAAA4OTQ2NzQxYzU1NWEwYzQ1MTVkOC5qc29uUEsBAj8DFAAACAgAL2YVV95SWQxkAQAAugMAAAsAAAAAAAAAAAAAALSB/AMAAHJlcG9ydC5qc29uUEsFBgAAAAACAAIAgAAAAIkFAAAAAA=="; \ No newline at end of file diff --git a/apps/pwabuilder/tests/basic.spec.ts b/apps/pwabuilder/tests/basic.spec.ts index 918cd32ed..cbfbc1529 100644 --- a/apps/pwabuilder/tests/basic.spec.ts +++ b/apps/pwabuilder/tests/basic.spec.ts @@ -1,47 +1,13 @@ -import { test, expect, chromium, Page } from '@playwright/test'; +import { test, expect } from '@playwright/test'; -const url = 'http://localhost:3000'; - -const v8toIstanbul = require('v8-to-istanbul'); - -let currentPage: Page | null = null; +const url = 'https://preview.pwabuilder.com/'; // before each test test.beforeEach(async ({ page }) => { - currentPage = page; - - await page.coverage.startJSCoverage(); await page.goto(url); }); -test.afterEach(async () => { - const coverage = await currentPage?.coverage.stopJSCoverage(); - if (coverage) { - for (const entry of coverage) { - const converter = v8toIstanbul('', 0, { source: entry.source }); - try { - await converter.load(); - converter.applyCoverage(entry.functions); - const coverageData = converter.toIstanbul(); - - - // write the coverage data to a json file - const { writeFile, mkdir } = await import("fs/promises"); - - // make coverage folder if it doesn't exist - await mkdir('coverage', { recursive: true }) - - await writeFile(`coverage/coverage-${entry.url.split('/').pop()}.json`, JSON.stringify(coverageData, null, 2)); - - } - catch (err) { - - } - } - } -}) - -test('ensure application loads', async ({ page }) => { +test('ensure application loads home page', async ({ page }) => { // find the button with the text "Login" const loginButton = page.locator('id=start-button'); diff --git a/apps/pwabuilder/tests/packaging.spec.ts b/apps/pwabuilder/tests/packaging.spec.ts index 31c7db61b..7f73cc373 100644 --- a/apps/pwabuilder/tests/packaging.spec.ts +++ b/apps/pwabuilder/tests/packaging.spec.ts @@ -1,45 +1,14 @@ import { test, expect, Page } from '@playwright/test'; -const v8toIstanbul = require('v8-to-istanbul'); - let currentPage: Page | undefined; -const url = 'http://localhost:3000'; +const url = 'https://preview.pwabuilder.com/'; // before each test test.beforeEach(async ({ page }) => { currentPage = page; - - await page.coverage.startJSCoverage(); await page.goto(url); }); -test.afterEach(async () => { - const coverage = await currentPage?.coverage.stopJSCoverage(); - if (coverage) { - for (const entry of coverage) { - const converter = v8toIstanbul('', 0, { source: entry.source }); - try { - await converter.load(); - converter.applyCoverage(entry.functions); - const coverageData = converter.toIstanbul(); - - - // write the coverage data to a json file - const { writeFile, mkdir } = await import("fs/promises"); - - // make coverage folder if it doesn't exist - await mkdir('coverage', { recursive: true }) - - await writeFile(`coverage/coverage-${entry.url.split('/').pop()}.json`, JSON.stringify(coverageData, null, 2)); - - } - catch (err) { - - } - } - } -}) - // only run this test once test('Ensure demo app can be packaged for Windows', async ({ page }) => { diff --git a/apps/pwabuilder/tests/report-card.spec.ts b/apps/pwabuilder/tests/report-card.spec.ts index 56eb7f4b8..6da62bdbf 100644 --- a/apps/pwabuilder/tests/report-card.spec.ts +++ b/apps/pwabuilder/tests/report-card.spec.ts @@ -1,45 +1,14 @@ import { test, expect, Page } from '@playwright/test'; -const v8toIstanbul = require('v8-to-istanbul'); - let currentPage: Page | undefined; -const url = 'http://localhost:3000'; +const url = 'https://preview.pwabuilder.com'; // before each test test.beforeEach(async ({ page }) => { currentPage = page; - - await page.coverage.startJSCoverage(); await page.goto(url); }); -test.afterEach(async () => { - const coverage = await currentPage?.coverage.stopJSCoverage(); - if (coverage) { - for (const entry of coverage) { - const converter = v8toIstanbul('', 0, { source: entry.source }); - try { - await converter.load(); - converter.applyCoverage(entry.functions); - const coverageData = converter.toIstanbul(); - - - // write the coverage data to a json file - const { writeFile, mkdir } = await import("fs/promises"); - - // make coverage folder if it doesn't exist - await mkdir('coverage', { recursive: true }) - - await writeFile(`coverage/coverage-${entry.url.split('/').pop()}.json`, JSON.stringify(coverageData, null, 2)); - - } - catch (err) { - - } - } - } -}) - test('ensure demo app is testable', async ({ page }) => { // find the button with the text "Login" @@ -90,7 +59,7 @@ test('ensure scores are correct for demo app', async ({ page }) => { const selector = document.querySelector("body > app-index")?.shadowRoot?.querySelector("#router-outlet > app-report")?.shadowRoot?.querySelector("#manifestProgressRing") return selector?.textContent; }); - await expect(manifestScore).toContain('23'); + await expect(manifestScore).toContain('22 / 29'); // test service worker score const serviceWorkerScore = await page.evaluate(() => {