Skip to content

Commit b36d671

Browse files
committed
migrate scripts/pit/its/start.js to use test-utils
1 parent 986bc0c commit b36d671

File tree

1 file changed

+25
-37
lines changed

1 file changed

+25
-37
lines changed

scripts/pit/its/start.js

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,33 @@
1-
const { chromium } = require('playwright');
2-
3-
let headless = false, host = 'localhost', port = '8080', hub = false;
4-
process.argv.forEach(a => {
5-
if (/^--headless/.test(a)) {
6-
headless = true;
7-
} else if (/^--ip=/.test(a)) {
8-
ip = a.split('=')[1];
9-
} else if (/^--port=/.test(a)) {
10-
port = a.split('=')[1];
11-
}
12-
});
1+
const { log, args, createPage, closePage, takeScreenshot, waitForServerReady, dismissDevmode } = require('./test-utils');
132

143
(async () => {
15-
const browser = await chromium.launch({
16-
headless: headless,
17-
chromiumSandbox: false
18-
});
19-
20-
// TODO: should work with smaller viewport too like in 24.9
21-
const context = await browser.newContext({
22-
viewport: { width: 1920, height: 1080 }
23-
});
4+
const arg = args();
5+
6+
const page = await createPage(arg.headless);
7+
// TODO: should work with smaller viewport too like in 24.9
8+
page.setViewportSize({ width: 1920, height: 1080 });
249

25-
const page = await context.newPage();
26-
page.on('console', msg => console.log("> CONSOLE:", (msg.text() + ' - ' + msg.location().url).replace(/\s+/g, ' ')));
27-
page.on('pageerror', err => console.log("> PAGEERROR:", ('' + err).replace(/\s+/g, ' ')));
10+
await waitForServerReady(page, arg.url);
2811

29-
await page.goto(`http://${host}:${port}/`);
12+
// Dismiss dev mode notification if present
13+
await dismissDevmode(page);
14+
await takeScreenshot(page, __filename, 'page-loaded');
3015

31-
await page.locator('text=Hello').nth(0).click();
32-
await page.locator('input[type="text"]').fill('Greet');
33-
await page.locator('text=Say hello').click();
34-
await page.locator('text=Hello Greet');
16+
log('Testing Hello functionality');
17+
await page.locator('text=Hello').nth(0).click();
18+
await page.locator('input[type="text"]').fill('Greet');
19+
await page.locator('text=Say hello').click();
20+
await page.locator('text=Hello Greet');
21+
await takeScreenshot(page, __filename, 'hello-tested');
3522

36-
await page.locator('text=Master-Detail').nth(0).click();
37-
await page.locator('text=eula.lane').click();
38-
await page.locator('input[type="text"]').nth(0).fill('FOO');
39-
await page.locator('text=Save').click();
40-
await page.locator('text=/stored/');
23+
log('Testing Master-Detail functionality');
24+
await page.locator('text=Master-Detail').nth(0).click();
25+
await page.locator('text=eula.lane').click();
26+
await page.locator('input[type="text"]').nth(0).fill('FOO');
27+
await page.locator('text=Save').click();
28+
await page.locator('text=/stored/');
29+
await takeScreenshot(page, __filename, 'master-detail-tested');
4130

42-
// ---------------------
43-
await context.close();
44-
await browser.close();
31+
log('Start application tested successfully');
32+
await closePage(page);
4533
})();

0 commit comments

Comments
 (0)