Skip to content

Commit 41c5651

Browse files
committed
fix: Await some promises concurrently
1 parent b6a095f commit 41c5651

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

.github/actions/auth/src/index.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,20 @@ export default async function () {
4343
await page.goto(loginUrl);
4444

4545
// Check for a login form
46-
const usernameField = await page.getByLabel(/username/i).first();
47-
const passwordField = await page.getByLabel(/password/i).first();
48-
if (
49-
(await usernameField.count()) > 0 &&
50-
(await passwordField.count()) > 0
51-
) {
46+
const [usernameField, passwordField] = await Promise.all([
47+
page.getByLabel(/username/i).first(),
48+
page.getByLabel(/password/i).first(),
49+
]);
50+
const [usernameFieldExists, passwordFieldExists] = await Promise.all([
51+
usernameField.count(),
52+
passwordField.count(),
53+
]);
54+
if (usernameFieldExists && passwordFieldExists) {
5255
// Try form authentication
5356
core.info("Filling username");
54-
await page.getByLabel(/username/i).fill(username);
57+
await usernameField.fill(username);
5558
core.info("Filling password");
56-
await page.getByLabel(/password/i).fill(password);
59+
await passwordField.fill(password);
5760
core.info("Logging in");
5861
await page
5962
.getByLabel(/password/i)

0 commit comments

Comments
 (0)