|
| 1 | +import * as puppeteer from 'puppeteer-core'; |
| 2 | +import * as path from 'path'; |
| 3 | +import * as wbnSign from 'wbn-sign'; |
| 4 | +import * as fs from 'fs'; |
| 5 | + |
| 6 | +/* |
| 7 | + If you want to debug E2E tests, you will need to either create a custom debug launch configuration |
| 8 | + https://code.visualstudio.com/docs/debugtest/debugging-configuration |
| 9 | +
|
| 10 | + Alternatively, you can use a test runner extension. |
| 11 | + https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner |
| 12 | +*/ |
| 13 | +describe('E2E Tests', () => { |
| 14 | + let browser: puppeteer.Browser; |
| 15 | + let session: puppeteer.CDPSession; |
| 16 | + let manifestID: string; |
| 17 | + |
| 18 | + const bundlePath = path.join(process.cwd(), 'dist', 'iwa-template.swbn'); |
| 19 | + const flags = "--enable-features=IsolatedWebApps,IsolatedWebAppDevMode"; |
| 20 | + test("IWA Should be installed and launched correctly",async () => { |
| 21 | + const bundleContent = new Uint8Array(await fs.promises.readFile(bundlePath)); |
| 22 | + manifestID = wbnSign.getBundleId(bundleContent); |
| 23 | + |
| 24 | + browser = await puppeteer.launch({ |
| 25 | + executablePath: '/usr/bin/google-chrome', |
| 26 | + headless: false, |
| 27 | + pipe: true, |
| 28 | + args: [flags] |
| 29 | + }); |
| 30 | + |
| 31 | + session = await browser.target().createCDPSession(); |
| 32 | + |
| 33 | + await session.send("PWA.install", { |
| 34 | + manifestId: `isolated-app://${manifestID}`, |
| 35 | + installUrlOrBundleUrl: `file://${bundlePath}` |
| 36 | + }); |
| 37 | + |
| 38 | + await session.send("PWA.launch", { |
| 39 | + manifestId: `isolated-app://${manifestID}` |
| 40 | + }) |
| 41 | + |
| 42 | + await browser.close(); |
| 43 | + |
| 44 | + }, 300000 ); |
| 45 | + |
| 46 | +}); |
0 commit comments