Skip to content

Commit 973a763

Browse files
committed
migrate scripts/pit/its/oauth.js to use test-utils
1 parent cb48d3b commit 973a763

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

scripts/pit/its/oauth.js

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
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();
205

21-
const page = await context.newPage();
22-
page.on('console', msg => console.log("> CONSOLE:", (msg.text() + ' - ' + msg.location().url).replace(/\s+/g, ' ')));
23-
page.on('pageerror', err => console.log("> PAGEERROR:", ('' + err).replace(/\s+/g, ' ')));
6+
const page = await createPage(arg.headless);
247

25-
await page.goto(`http://${host}:${port}/`);
8+
await waitForServerReady(page, arg.url);
269

27-
await page.waitForURL('http://localhost:8080/login');
28-
await page.getByRole('link', { name: 'Login with Google' }).click();
29-
await page.locator('input[type=email]').fill('aaa');
30-
await page.getByRole('button').nth(2).click();
10+
// Dismiss dev mode notification if present
11+
await dismissDevmode(page);
12+
await takeScreenshot(page, __filename, 'page-loaded');
3113

14+
log('Testing OAuth login flow');
15+
await page.waitForURL(`${arg.url.replace(':8080', ':8080')}/login`);
16+
await takeScreenshot(page, __filename, 'login-page');
3217

33-
await context.close();
34-
await browser.close();
18+
await page.getByRole('link', { name: 'Login with Google' }).click();
19+
await takeScreenshot(page, __filename, 'google-login-clicked');
20+
21+
await page.locator('input[type=email]').fill('aaa');
22+
await page.getByRole('button').nth(2).click();
23+
await takeScreenshot(page, __filename, 'oauth-form-filled');
24+
25+
log('OAuth flow tested successfully');
26+
await closePage(page);
3527
})();

0 commit comments

Comments
 (0)