Skip to content

Commit 92e674c

Browse files
committed
migrate scripts/pit/its/k8s-demo.js to use test-utils
1 parent 03bf0c7 commit 92e674c

File tree

1 file changed

+55
-49
lines changed

1 file changed

+55
-49
lines changed

scripts/pit/its/k8s-demo.js

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,58 @@
1-
const { args, createPage, closePage, takeScreenshot, waitForServerReady, dismissDevmode} = require('./test-utils');
1+
const { log, args, createPage, closePage, takeScreenshot, waitForServerReady, dismissDevmode} = require('./test-utils');
22

33
(async () => {
4-
const arg = args();
5-
const page = await createPage(arg.headless, arg.ignoreHTTPSErrors);
6-
await waitForServerReady(page, arg.url);
7-
8-
await page.evaluate(() =>
9-
window.localStorage.setItem("vaadin.live-reload.dismissedNotifications","liveReloadUnavailable,preserveOnRefreshWarning")
10-
);
11-
12-
await takeScreenshot(page, __filename, 'loaded');
13-
await page.waitForURL(`${arg.url}login`);
14-
await page.getByLabel('Username').fill('admin');
15-
await page.getByLabel('Username').press('Tab');
16-
await page.getByLabel('Password').first().fill('admin');
17-
await page.getByLabel('Password').first().press('Tab');
18-
await page.getByRole('button', { name: 'Log in' }).locator('div').click();
19-
await takeScreenshot(page, __filename, 'loggedin');
20-
await page.waitForURL(`${arg.url}`);
21-
22-
await page.getByRole('link').locator('text=/Personas/').click();
23-
await takeScreenshot(page, __filename, 'personas');
24-
await page.waitForURL(`${arg.url}personas`);
25-
26-
await dismissDevmode(page);
27-
await takeScreenshot(page, __filename, 'dismissed');
28-
29-
await page.getByRole('button', { name: '+' }).locator('div').click();
30-
await takeScreenshot(page, __filename, 'new');
31-
await page.waitForURL(`${arg.url}personas/new`);
32-
33-
await page.locator('.detail').getByLabel('First Name').click();
34-
await page.locator('.detail').getByLabel('First Name').fill('FOOBAR');
35-
await page.locator('.detail').getByLabel('First Name').press('Tab');
36-
await page.locator('.detail').getByLabel('Last Name').fill('BAZ');
37-
await page.locator('.detail').getByLabel('Last Name').press('Tab');
38-
await page.locator('.detail').getByLabel('First Name').click();
39-
await page.locator('.detail').getByLabel('Email').press('Escape');
40-
await takeScreenshot(page, __filename, 'escape');
41-
42-
await page.evaluate(() => window.location.reload());
43-
await takeScreenshot(page, __filename, 'reload');
44-
await page.waitForURL(`${arg.url}personas/new`);
45-
46-
await page.getByRole('button', { name: 'No' }).locator('div').click();
47-
await takeScreenshot(page, __filename, 'clicked-no');
48-
const name = await page.locator('.detail').getByLabel('First Name').inputValue();
49-
if (name != 'FOOBAR') throw new Error();
50-
51-
await closePage(page);
4+
const arg = args();
5+
const page = await createPage(arg.headless, arg.ignoreHTTPSErrors);
6+
await waitForServerReady(page, arg.url);
7+
8+
await page.evaluate(() =>
9+
window.localStorage.setItem("vaadin.live-reload.dismissedNotifications","liveReloadUnavailable,preserveOnRefreshWarning")
10+
);
11+
12+
await takeScreenshot(page, __filename, 'loaded');
13+
14+
log('Testing login flow');
15+
await page.waitForURL(`${arg.url}login`);
16+
await page.getByLabel('Username').fill('admin');
17+
await page.getByLabel('Username').press('Tab');
18+
await page.getByLabel('Password').first().fill('admin');
19+
await page.getByLabel('Password').first().press('Tab');
20+
await page.getByRole('button', { name: 'Log in' }).locator('div').click();
21+
await takeScreenshot(page, __filename, 'loggedin');
22+
await page.waitForURL(`${arg.url}`);
23+
24+
log('Testing Personas navigation');
25+
await page.getByRole('link').locator('text=/Personas/').click();
26+
await takeScreenshot(page, __filename, 'personas');
27+
await page.waitForURL(`${arg.url}personas`);
28+
29+
await dismissDevmode(page);
30+
await takeScreenshot(page, __filename, 'dismissed');
31+
32+
log('Testing person creation form');
33+
await page.getByRole('button', { name: '+' }).locator('div').click();
34+
await takeScreenshot(page, __filename, 'new');
35+
await page.waitForURL(`${arg.url}personas/new`);
36+
37+
await page.locator('.detail').getByLabel('First Name').click();
38+
await page.locator('.detail').getByLabel('First Name').fill('FOOBAR');
39+
await page.locator('.detail').getByLabel('First Name').press('Tab');
40+
await page.locator('.detail').getByLabel('Last Name').fill('BAZ');
41+
await page.locator('.detail').getByLabel('Last Name').press('Tab');
42+
await page.locator('.detail').getByLabel('First Name').click();
43+
await page.locator('.detail').getByLabel('Email').press('Escape');
44+
await takeScreenshot(page, __filename, 'escape');
45+
46+
log('Testing form preservation after reload');
47+
await page.evaluate(() => window.location.reload());
48+
await takeScreenshot(page, __filename, 'reload');
49+
await page.waitForURL(`${arg.url}personas/new`);
50+
51+
await page.getByRole('button', { name: 'No' }).locator('div').click();
52+
await takeScreenshot(page, __filename, 'clicked-no');
53+
const name = await page.locator('.detail').getByLabel('First Name').inputValue();
54+
if (name != 'FOOBAR') throw new Error();
55+
56+
log('K8s demo tested successfully');
57+
await closePage(page);
5258
})();

0 commit comments

Comments
 (0)