Skip to content

Commit 7fb2b15

Browse files
committed
migrate scripts/pit/its/latest-java.js to use test-utils
1 parent d16ca1b commit 7fb2b15

File tree

1 file changed

+93
-88
lines changed

1 file changed

+93
-88
lines changed

scripts/pit/its/latest-java.js

Lines changed: 93 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,102 @@
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();
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 Empty (Java) view');
15+
// Click text=Empty (Java) >> slot >> nth=1
16+
await page.locator('text=Empty (Java) >> slot').nth(1).click();
17+
await page.waitForURL(`${arg.url}/empty-view`);
18+
19+
log('Testing Hello World (Java) view');
20+
// Click text=Hello World (Java) >> slot >> nth=1
21+
await page.locator('text=Hello World (Java) >> slot').nth(1).click();
22+
await page.waitForURL(`${arg.url}/hello-world-view`);
2023

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, ' ')));
24+
// Fill input[type="text"]
25+
await page.locator('input[type="text"]').fill('Greet');
26+
// Click text=Say hello
27+
await page.locator('text=Say hello').click();
28+
await page.locator('text=Hello Greet');
29+
await takeScreenshot(page, __filename, 'hello-world-tested');
2530

26-
// Go to http://${host}:${port}/
27-
await page.goto(`http://${host}:${port}/`);
31+
log('Testing Dashboard (Java) view');
32+
// Click text=Dashboard (Java) >> slot >> nth=1
33+
await page.locator('text=Dashboard (Java) >> slot').nth(1).click();
34+
await page.waitForURL(`${arg.url}/dashboard-view`);
35+
await takeScreenshot(page, __filename, 'dashboard-loaded');
36+
37+
log('Testing Card List (Java) view');
38+
// Click text=Card List (Java) >> slot >> nth=1
39+
await page.locator('text=Card List (Java) >> slot').nth(1).click();
40+
await page.waitForURL(`${arg.url}/card-list-view`);
41+
42+
log('Testing List view');
43+
// Click vcf-nav-item:nth-child(5) > a > slot:nth-child(2)
44+
await page.locator('vcf-nav-item:nth-child(5) > a > slot:nth-child(2)').click();
45+
await page.waitForURL(`${arg.url}/list-view`);
46+
47+
log('Testing Master-Detail views');
48+
// Click vcf-nav-item:nth-child(6) > a > slot:nth-child(2)
49+
await page.locator('vcf-nav-item:nth-child(6) > a > slot:nth-child(2)').click();
50+
await page.waitForURL(`${arg.url}/master-detail-view`);
51+
// Click vcf-nav-item:nth-child(7) > a > slot:nth-child(2)
52+
await page.locator('vcf-nav-item:nth-child(7) > a > slot:nth-child(2)').click();
53+
await page.waitForURL(`${arg.url}/master-detail-view-sampleaddress`);
54+
// Click vcf-nav-item:nth-child(8) > a > slot:nth-child(2)
55+
await page.locator('vcf-nav-item:nth-child(8) > a > slot:nth-child(2)').click();
56+
await page.waitForURL(`${arg.url}/master-detail-view-samplebook`);
57+
await takeScreenshot(page, __filename, 'master-detail-views-tested');
2858

29-
// Click text=Empty (Java) >> slot >> nth=1
30-
await page.locator('text=Empty (Java) >> slot').nth(1).click();
31-
await page.waitForURL(`http://${host}:${port}/empty-view`);
32-
// Click text=Hello World (Java) >> slot >> nth=1
33-
await page.locator('text=Hello World (Java) >> slot').nth(1).click();
34-
await page.waitForURL(`http://${host}:${port}/hello-world-view`);
59+
log('Testing Collaborative Master-Detail views');
60+
// Click text=Collaborative Master-Detail (Java) >> slot >> nth=1
61+
await page.locator('text=Collaborative Master-Detail (Java) >> slot').nth(1).click();
62+
await page.waitForURL(`${arg.url}/collaborative-master-detail-view`);
63+
// Click text=Collaborative Master-Detail SampleAddress (Java) >> slot >> nth=1
64+
await page.locator('text=Collaborative Master-Detail SampleAddress (Java) >> slot').nth(1).click();
65+
await page.waitForURL(`${arg.url}/collaborative-master-detail-view-sampleaddress`);
66+
// Click text=Collaborative Master-Detail SampleBook (Java) >> slot >> nth=1
67+
await page.locator('text=Collaborative Master-Detail SampleBook (Java) >> slot').nth(1).click();
68+
await page.waitForURL(`${arg.url}/collaborative-master-detail-view-samplebook`);
3569

36-
// Fill input[type="text"]
37-
await page.locator('input[type="text"]').fill('Greet');
38-
// Click text=Say hello
39-
await page.locator('text=Say hello').click();
40-
await page.locator('text=Hello Greet');
70+
log('Testing Form views');
71+
// Click text=Person Form (Java) >> slot >> nth=1
72+
await page.locator('text=Person Form (Java) >> slot').nth(1).click();
73+
await page.waitForURL(`${arg.url}/person-form-view`);
74+
// Click text=Address Form (Java) >> slot >> nth=1
75+
await page.locator('text=Address Form (Java) >> slot').nth(1).click();
76+
await page.waitForURL(`${arg.url}/address-form-view`);
77+
// Click text=Credit Card Form (Java) >> slot >> nth=1
78+
await page.locator('text=Credit Card Form (Java) >> slot').nth(1).click();
79+
await page.waitForURL(`${arg.url}/credit-card-form-view`);
80+
await takeScreenshot(page, __filename, 'forms-tested');
4181

42-
// Click text=Dashboard (Java) >> slot >> nth=1
43-
await page.locator('text=Dashboard (Java) >> slot').nth(1).click();
44-
await page.waitForURL(`http://${host}:${port}/dashboard-view`);
45-
// Click text=Card List (Java) >> slot >> nth=1
46-
await page.locator('text=Card List (Java) >> slot').nth(1).click();
47-
await page.waitForURL(`http://${host}:${port}/card-list-view`);
48-
// Click vcf-nav-item:nth-child(5) > a > slot:nth-child(2)
49-
await page.locator('vcf-nav-item:nth-child(5) > a > slot:nth-child(2)').click();
50-
await page.waitForURL(`http://${host}:${port}/list-view`);
51-
// Click vcf-nav-item:nth-child(6) > a > slot:nth-child(2)
52-
await page.locator('vcf-nav-item:nth-child(6) > a > slot:nth-child(2)').click();
53-
await page.waitForURL(`http://${host}:${port}/master-detail-view`);
54-
// Click vcf-nav-item:nth-child(7) > a > slot:nth-child(2)
55-
await page.locator('vcf-nav-item:nth-child(7) > a > slot:nth-child(2)').click();
56-
await page.waitForURL(`http://${host}:${port}/master-detail-view-sampleaddress`);
57-
// Click vcf-nav-item:nth-child(8) > a > slot:nth-child(2)
58-
await page.locator('vcf-nav-item:nth-child(8) > a > slot:nth-child(2)').click();
59-
await page.waitForURL(`http://${host}:${port}/master-detail-view-samplebook`);
60-
// Click text=Collaborative Master-Detail (Java) >> slot >> nth=1
61-
await page.locator('text=Collaborative Master-Detail (Java) >> slot').nth(1).click();
62-
await page.waitForURL(`http://${host}:${port}/collaborative-master-detail-view`);
63-
// Click text=Collaborative Master-Detail SampleAddress (Java) >> slot >> nth=1
64-
await page.locator('text=Collaborative Master-Detail SampleAddress (Java) >> slot').nth(1).click();
65-
await page.waitForURL(`http://${host}:${port}/collaborative-master-detail-view-sampleaddress`);
66-
// Click text=Collaborative Master-Detail SampleBook (Java) >> slot >> nth=1
67-
await page.locator('text=Collaborative Master-Detail SampleBook (Java) >> slot').nth(1).click();
68-
await page.waitForURL(`http://${host}:${port}/collaborative-master-detail-view-samplebook`);
69-
// Click text=Person Form (Java) >> slot >> nth=1
70-
await page.locator('text=Person Form (Java) >> slot').nth(1).click();
71-
await page.waitForURL(`http://${host}:${port}/person-form-view`);
72-
// Click text=Address Form (Java) >> slot >> nth=1
73-
await page.locator('text=Address Form (Java) >> slot').nth(1).click();
74-
await page.waitForURL(`http://${host}:${port}/address-form-view`);
75-
// Click text=Credit Card Form (Java) >> slot >> nth=1
76-
await page.locator('text=Credit Card Form (Java) >> slot').nth(1).click();
77-
await page.waitForURL(`http://${host}:${port}/credit-card-form-view`);
78-
// Click text=Map (Java) >> slot >> nth=1
79-
await page.locator('text=Map (Java) >> slot').nth(1).click();
80-
await page.waitForURL(`http://${host}:${port}/map-view`);
81-
// Click text=Chat (Java) >> slot >> nth=1
82-
await page.locator('text=Chat (Java) >> slot').nth(1).click();
83-
await page.waitForURL(`http://${host}:${port}/chat-view`);
84-
// Click text=Rich Text Editor (Java) >> slot >> nth=1
85-
await page.locator('text=Rich Text Editor (Java) >> slot').nth(1).click();
86-
await page.waitForURL(`http://${host}:${port}/editor-view`);
87-
// Click text=Image List (Java) >> slot >> nth=1
88-
await page.locator('text=Image List (Java) >> slot').nth(1).click();
89-
await page.waitForURL(`http://${host}:${port}/image-list-view`);
90-
// Click text=Checkout Form (Java) >> slot >> nth=1
91-
await page.locator('text=Checkout Form (Java) >> slot').nth(1).click();
92-
await page.waitForURL(`http://${host}:${port}/checkout-form-view`);
82+
log('Testing additional Java views');
83+
// Click text=Map (Java) >> slot >> nth=1
84+
await page.locator('text=Map (Java) >> slot').nth(1).click();
85+
await page.waitForURL(`${arg.url}/map-view`);
86+
// Click text=Chat (Java) >> slot >> nth=1
87+
await page.locator('text=Chat (Java) >> slot').nth(1).click();
88+
await page.waitForURL(`${arg.url}/chat-view`);
89+
// Click text=Rich Text Editor (Java) >> slot >> nth=1
90+
await page.locator('text=Rich Text Editor (Java) >> slot').nth(1).click();
91+
await page.waitForURL(`${arg.url}/editor-view`);
92+
// Click text=Image List (Java) >> slot >> nth=1
93+
await page.locator('text=Image List (Java) >> slot').nth(1).click();
94+
await page.waitForURL(`${arg.url}/image-list-view`);
95+
// Click text=Checkout Form (Java) >> slot >> nth=1
96+
await page.locator('text=Checkout Form (Java) >> slot').nth(1).click();
97+
await page.waitForURL(`${arg.url}/checkout-form-view`);
98+
await takeScreenshot(page, __filename, 'all-java-views-tested');
9399

94-
// ---------------------
95-
await context.close();
96-
await browser.close();
100+
log('All Java views tested successfully');
101+
await closePage(page);
97102
})();

0 commit comments

Comments
 (0)