Skip to content

Commit 1e37422

Browse files
authored
Merge pull request #441 from bitovi/fix/e2e-atlassian-consent-page
fix: update E2E auth setup for Atlassian consent page changes
2 parents 7ab1cff + 23481cc commit 1e37422

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ public/atlassian-connect.json
1616
/playwright/.auth/
1717
/playwright/.cache/
1818
/blob-report/
19-
/dist/
19+
/dist/
20+
.playwright-mcp/

playwright/auth.setup.ts

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,44 @@ setup('authenticate', async ({ page }) => {
4242

4343
const totpValue = totp.generate();
4444
await totpInput.fill(totpValue);
45-
await page.locator('#react-select-2-input').click();
46-
await page.getByText('bitovi-training.atlassian.net', { exact: true }).click();
47-
await page.getByRole('button', { name: 'Accept' }).click();
45+
46+
// Submit the TOTP form — Atlassian's TOTP page may auto-submit after
47+
// filling all 6 digits, or may require pressing Enter / clicking a button.
48+
// We press Enter as a reliable way to submit regardless of the UI variant.
49+
await totpInput.press('Enter');
50+
51+
// Debug: log where we are after TOTP submission
52+
await page.waitForTimeout(5000);
53+
console.log('[AUTH DEBUG] After TOTP - URL:', page.url());
54+
console.log('[AUTH DEBUG] After TOTP - Title:', await page.title());
55+
console.log(
56+
'[AUTH DEBUG] After TOTP - Body text:',
57+
await page
58+
.locator('body')
59+
.innerText()
60+
.catch(() => 'COULD NOT READ BODY'),
61+
);
62+
63+
// Wait for navigation to the consent page
64+
await page.waitForURL('**/oauth2/authorize/**', { timeout: 15000 });
65+
66+
// Atlassian's consent page has two variants:
67+
// 1. Multi-site: shows a combobox to "Choose a site" — must select one
68+
// 2. Single-site: auto-selects the only site, no combobox shown
69+
// Handle both by checking if the combobox exists.
70+
const siteSelector = page.getByRole('combobox');
71+
const hasSiteSelector = await siteSelector.isVisible({ timeout: 5000 }).catch(() => false);
72+
73+
if (hasSiteSelector) {
74+
await siteSelector.click();
75+
await page.getByText('bitovi-training.atlassian.net', { exact: true }).click();
76+
}
77+
78+
// Wait for Accept button to become enabled (it starts disabled while loading)
79+
const acceptButton = page.getByRole('button', { name: 'Accept' });
80+
await acceptButton.waitFor({ state: 'visible', timeout: 15000 });
81+
await expect(acceptButton).toBeEnabled({ timeout: 10000 });
82+
await acceptButton.click();
4883

4984
await expect(page.getByRole('button', { name: 'Log Out' })).toBeVisible();
5085

0 commit comments

Comments
 (0)