Skip to content

Commit d2e5355

Browse files
committed
migrate scripts/pit/its/latest-javahtml.js to use test-utils
1 parent 92e674c commit d2e5355

File tree

1 file changed

+36
-49
lines changed

1 file changed

+36
-49
lines changed

scripts/pit/its/latest-javahtml.js

Lines changed: 36 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,39 @@
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-
const context = await browser.newContext();
20-
21-
// Open new page
22-
const page = await context.newPage();
23-
page.on('console', msg => console.log("> CONSOLE:", (msg.text() + ' - ' + msg.location().url).replace(/\s+/g, ' ')));
24-
page.on('pageerror', err => console.log("> PAGEERROR:", ('' + err).replace(/\s+/g, ' ')));
25-
26-
// Go to http://localhost:8080/
27-
await page.goto(`http://${host}:${port}/`);
28-
29-
30-
// Click text=Master-Detail (Javahtml) >> slot >> nth=1
31-
await page.locator('text=Master-Detail (Javahtml) >> slot').nth(1).click();
32-
await page.waitForURL(`http://${host}:${port}/master-detail-view`);
33-
// Click text=Master-Detail SampleAddress (Javahtml) >> slot >> nth=1
34-
await page.locator('text=Master-Detail SampleAddress (Javahtml) >> slot').nth(1).click();
35-
await page.waitForURL(`http://${host}:${port}/master-detail-view-sampleaddress`);
36-
// Click text=Master-Detail SampleBook (Javahtml) >> slot >> nth=1
37-
await page.locator('text=Master-Detail SampleBook (Javahtml) >> slot').nth(1).click();
38-
await page.waitForURL(`http://${host}:${port}/master-detail-view-samplebook`);
39-
// Click text=Hello World (Javahtml) >> slot >> nth=1
40-
await page.locator('text=Hello World (Javahtml) >> slot').nth(1).click();
41-
await page.waitForURL(`http://${host}:${port}/hello-world-view`);
42-
// Fill input[type="text"]
43-
await page.locator('input[type="text"]').fill('Greet');
44-
// Click text=Say hello
45-
await page.locator('text=Say hello').click();
46-
await page.locator('text=Hello Greet');
47-
48-
49-
// ---------------------
50-
await context.close();
51-
await browser.close();
4+
const arg = args();
5+
6+
const page = await createPage(arg.headless);
7+
8+
await waitForServerReady(page, arg.url);
9+
10+
// Dismiss dev mode notification if present
11+
await dismissDevmode(page);
12+
await takeScreenshot(page, __filename, 'page-loaded');
13+
14+
log('Testing Master-Detail (Javahtml) views');
15+
// Click text=Master-Detail (Javahtml) >> slot >> nth=1
16+
await page.locator('text=Master-Detail (Javahtml) >> slot').nth(1).click();
17+
await page.waitForURL(`${arg.url}/master-detail-view`);
18+
// Click text=Master-Detail SampleAddress (Javahtml) >> slot >> nth=1
19+
await page.locator('text=Master-Detail SampleAddress (Javahtml) >> slot').nth(1).click();
20+
await page.waitForURL(`${arg.url}/master-detail-view-sampleaddress`);
21+
// Click text=Master-Detail SampleBook (Javahtml) >> slot >> nth=1
22+
await page.locator('text=Master-Detail SampleBook (Javahtml) >> slot').nth(1).click();
23+
await page.waitForURL(`${arg.url}/master-detail-view-samplebook`);
24+
await takeScreenshot(page, __filename, 'master-detail-javahtml-tested');
25+
26+
log('Testing Hello World (Javahtml) view');
27+
// Click text=Hello World (Javahtml) >> slot >> nth=1
28+
await page.locator('text=Hello World (Javahtml) >> slot').nth(1).click();
29+
await page.waitForURL(`${arg.url}/hello-world-view`);
30+
// Fill input[type="text"]
31+
await page.locator('input[type="text"]').fill('Greet');
32+
// Click text=Say hello
33+
await page.locator('text=Say hello').click();
34+
await page.locator('text=Hello Greet');
35+
await takeScreenshot(page, __filename, 'hello-world-javahtml-tested');
36+
37+
log('All Javahtml views tested successfully');
38+
await closePage(page);
5239
})();

0 commit comments

Comments
 (0)