|
1 | | -const { chromium } = require('playwright'); |
2 | | - |
3 | | - |
4 | | -let headless = false, host = 'localhost', port = '8080', mode = 'prod'; |
5 | | -process.argv.forEach(a => { |
6 | | - if (/^--headless/.test(a)) { |
7 | | - headless = true; |
8 | | - } else if (/^--port=/.test(a)) { |
9 | | - port = a.split('=')[1]; |
10 | | - } else if (/^--mode=/.test(a)) { |
11 | | - mode = a.split('=')[1]; |
12 | | - } |
13 | | -}); |
| 1 | +const { log, args, createPage, closePage, takeScreenshot, waitForServerReady, dismissDevmode } = require('./test-utils'); |
14 | 2 |
|
15 | 3 | (async () => { |
16 | | - const browser = await chromium.launch({ |
17 | | - headless: headless, |
18 | | - chromiumSandbox: false |
19 | | - }); |
20 | | - const log = s => process.stderr.write(` ${s}`); |
| 4 | + const arg = args(); |
21 | 5 |
|
22 | | - const context = await browser.newContext(); |
23 | | - // context.setDefaultTimeout(90000); |
24 | | - // context.setDefaultNavigationTimeout(90000) |
| 6 | + const page = await createPage(arg.headless); |
| 7 | + page.setViewportSize({width: 811, height: 1224}); |
25 | 8 |
|
26 | | - const page = await context.newPage(); |
27 | | - page.setViewportSize({width: 811, height: 1224}); |
| 9 | + await waitForServerReady(page, arg.url); |
| 10 | + await takeScreenshot(page, __filename, 'wizard-loaded'); |
28 | 11 |
|
29 | | - page.on('console', msg => console.log("> CONSOLE:", (msg.text() + ' - ' + msg.location().url).replace(/\s+/g, ' '))); |
30 | | - page.on('pageerror', err => console.log("> PAGEERROR:", ('' + err).replace(/\s+/g, ' '))); |
31 | | - |
32 | | - await page.goto(`http://${host}:${port}/`); |
33 | | - |
34 | | - // Start a new project |
35 | | - log(`Starting new project\n`); |
36 | | - await page.getByText(/Start (a Project|Playing)/).click(); |
37 | | - await page.keyboard.press('Escape'); |
| 12 | + // Start a new project |
| 13 | + log(`Starting new project`); |
| 14 | + await page.getByText(/Start (a Project|Playing)/).click(); |
| 15 | + await page.keyboard.press('Escape'); |
| 16 | + await takeScreenshot(page, __filename, 'project-started'); |
38 | 17 |
|
39 | 18 | // No demo view anymore |
40 | 19 | // Test example views |
@@ -91,7 +70,7 @@ process.argv.forEach(a => { |
91 | 70 | log(`let's see if fails ....`) |
92 | 71 | } |
93 | 72 | } |
94 | | - |
| 73 | + |
95 | 74 | await page.waitForTimeout(1000); |
96 | 75 | log(`Created view ${label}\n`); |
97 | 76 | } |
@@ -138,12 +117,13 @@ process.argv.forEach(a => { |
138 | 117 | await page.getByRole('button', { name: 'Download', exact: true }).click(); |
139 | 118 | const download = await downloadPromise; |
140 | 119 | await download.saveAs(fname); |
141 | | - log(`Downloaded file ${fname}\n`); |
| 120 | + log(`Downloaded file ${fname}`); |
142 | 121 | await page.getByLabel('Close download dialog').click(); |
| 122 | + await takeScreenshot(page, __filename, 'download-completed'); |
143 | 123 | } else { |
144 | | - log(`Skipped download of file ${fname} in Windows\n`); |
| 124 | + log(`Skipped download of file ${fname} in Windows`); |
145 | 125 | } |
146 | 126 |
|
147 | | - await context.close(); |
148 | | - await browser.close(); |
| 127 | + log('Wizard testing completed successfully'); |
| 128 | + await closePage(page); |
149 | 129 | })(); |
0 commit comments