import { test, expect } from '@playwright/test'; test('Verify Chat (Hermes) accessible via SSO', async ({ page }) => { page.on('console', msg => console.log(`Browser Console [${msg.type()}]:`, msg.text())); page.on('requestfailed', req => console.log('Request Failed:', req.url(), req.failure()?.errorText)); page.on('pageerror', err => console.log('Page Error:', err.message)); console.log('Navigating to Chat via domain...'); await page.goto('https://chat.researchstack.info/'); await page.waitForTimeout(5000); console.log('Current URL:', page.url()); // Check if we are on the Authentik login page and need credentials const usernameInput = page.locator('input[name="username"], input[type="text"]').first(); if (await usernameInput.isVisible({ timeout: 5000 }).catch(() => false)) { console.log('Authentik login detected. Entering credentials...'); await usernameInput.fill('allaun'); const submitUsername = page.locator('button[type="submit"], input[type="submit"]').first(); await submitUsername.click(); await page.waitForTimeout(3000); const passwordInput = page.locator('input[name="password"], input[type="password"]').first(); await passwordInput.fill('Silverkitten14'); const submitPassword = page.locator('button[type="submit"], input[type="submit"]').first(); await submitPassword.click(); await page.waitForTimeout(8000); } // Handle consent screen if it appears if (page.url().includes('consent') || page.url().includes('authorize') || page.url().includes('application/o/authorize')) { console.log('Consent/Authorization screen detected. Clicking continue...'); const continueBtn = page.locator('button:has-text("Continue"), input[type="submit"], button[type="submit"]').first(); if (await continueBtn.isVisible({ timeout: 5000 }).catch(() => false)) { await continueBtn.click(); await page.waitForTimeout(8000); } } console.log('Final Page Title:', await page.title()); console.log('Final URL:', page.url()); await page.screenshot({ path: '/tmp/chat-verify-final.png' }); console.log('Page Content HTML:', await page.content()); // Assert that we have landed on the chat interface // The page title should contain "Hermes" or similar const title = await page.title(); expect(title.toLowerCase()).toContain('hermes'); });