diff --git a/e2e/basic.test.ts b/e2e/basic.test.ts index 520f267c8..568efbdb3 100644 --- a/e2e/basic.test.ts +++ b/e2e/basic.test.ts @@ -1,4 +1,4 @@ -import { expect, test } from '@playwright/test'; +import { Browser, chromium, expect, test } from '@playwright/test'; import { BrowserContext, ElectronApplication, @@ -7,31 +7,31 @@ import { } from 'playwright'; const PATH = require('path'); -test.describe('Check Home Page', async () => { +test.describe('Check Home Page', () => { let app: ElectronApplication; - let firstWindow: Page; + let page: Page; let context: BrowserContext; + let browser: Browser; test.beforeAll(async () => { app = await electron.launch({ - args: [ - PATH.join(__dirname, '../electron/main.js'), - PATH.join(__dirname, '../electron/package.json'), - ], + args: [PATH.join(__dirname, '../electron/main.js')], }); - context = app.context(); - //await context.tracing.start({ screenshots: true, snapshots: true }); - firstWindow = await app.windows()[0]; - const isMainWindow = (await firstWindow.title()) === 'IPTVnator'; + browser = await chromium.launch(); + context = await browser.newContext(); + await context.tracing.start({ screenshots: true }); + + page = app.windows()[0]; + const isMainWindow = (await page.title()) === 'IPTVnator'; if (!isMainWindow) { - firstWindow = await app.windows()[1]; + page = app.windows()[1]; } - await firstWindow.waitForLoadState('domcontentloaded'); + await page.waitForLoadState('domcontentloaded'); }); test('Launch electron app', async () => { - const windowState = await app.evaluate(async (process) => { + const windowState = await app.evaluate((process) => { let mainWindow = process.BrowserWindow.getAllWindows()[0]; const isMainWindow = mainWindow.title === 'IPTVnator'; if (!isMainWindow) { @@ -50,9 +50,16 @@ test.describe('Check Home Page', async () => { expect(app.windows()).toHaveLength(2); }); - test('Check title', async ({ page }) => { - const title = await firstWindow.title(); - await firstWindow.screenshot({ path: 'e2e/screenshots/intro.png' }); + // eslint-disable-next-line no-empty-pattern + test('Check title of the application', async ({}, testInfo) => { + const title = await page.title(); + const screenshot = await page.screenshot({ + path: './e2e/screenshots/home/no-playlists.png', + }); + await testInfo.attach('screenshot', { + body: screenshot, + contentType: 'image/png', + }); expect(title).toBe('IPTVnator'); }); }); diff --git a/e2e/playwright.config.ts b/e2e/playwright.config.ts index ca5aeefa5..ea7a1e996 100644 --- a/e2e/playwright.config.ts +++ b/e2e/playwright.config.ts @@ -1,8 +1,35 @@ -import { PlaywrightTestConfig } from '@playwright/test'; +import { devices, PlaywrightTestConfig } from '@playwright/test'; const config: PlaywrightTestConfig = { testDir: '.', maxFailures: 2, + projects: [ + { + name: 'chromium', + use: { + ...devices['Desktop Chrome'], + serviceWorkers: 'block', + }, + }, + /* { + name: 'firefox', + use: { + ...devices['Desktop Firefox'], + ignoreHTTPSErrors: true, + serviceWorkers: 'block', + }, + }, + { + name: 'webkit', + use: { + ...devices['Desktop Safari'], + serviceWorkers: 'block', + }, + }, */ + ], + use: { + screenshot: 'only-on-failure', + }, }; export default config; diff --git a/electron/package.json b/electron/package.json deleted file mode 100644 index 182375fba..000000000 --- a/electron/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "iptvnator-electron", - "version": "0.10.0", - "main": "main.js", - "private": true, - "dependencies": {} - } \ No newline at end of file diff --git a/package.json b/package.json index b142f26ae..3e404c388 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,9 @@ "test": "jest", "test:watch": "jest --watch", "e2e": "npm run build:electron && npx playwright test -c e2e/playwright.config.ts e2e/", - "e2e:debug": "npm run build:electron && PWDEBUG=1 npx playwright test -c e2e/playwright.config.ts e2e/", + "e2e:debug": "npm run build:electron && PWDEBUG=1 npx playwright test -c e2e/playwright.config.ts e2e/ /", + "e2e:html-report": "npm run build:electron && npm run e2e -- --reporter=html", + "e2e:show-report": "npx playwright show-report", "version": "conventional-changelog -i CHANGELOG.md -p angular -s -r 0 && git add CHANGELOG.md", "lint": "ng lint", "build-pwa": "ng build -c production --base-href /iptvnator --deploy-url /iptvnator/" @@ -104,7 +106,7 @@ "@ngrx/eslint-plugin": "^14.3.2", "@ngx-translate/core": "14.0.0", "@ngx-translate/http-loader": "7.0.0", - "@playwright/test": "1.26.0", + "@playwright/test": "1.29.1", "@semantic-release/changelog": "6.0.1", "@semantic-release/git": "10.0.1", "@semantic-release/npm": "9.0.0", @@ -131,8 +133,8 @@ "ng-mocks": "14.0.2", "node-polyfill-webpack-plugin": "1.1.4", "npm-run-all": "4.1.5", - "playwright": "1.26.0", - "playwright-core": "1.26.0", + "playwright": "1.29.1", + "playwright-core": "1.29.1", "prettier": "2.5.1", "semantic-release": "19.0.3", "stylelint": "14.2.0",