Research-Stack/4-Infrastructure/k3s-flake/tests/chat-verify.spec.ts
allaun a8fa660009 test(infra): add E2E Playwright verification spec for Chat SSO login
- Automate multi-step SSO login and NextAuth session activation for chat.researchstack.info
- Verify Caddy reverse proxy and forward auth configuration resolves ERR_TOO_MANY_REDIRECTS

Build: 0 jobs, 0 errors (lake build)
2026-06-29 16:38:39 -05:00

51 lines
2.3 KiB
TypeScript

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');
});