Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(ci): restore responsive viewport authentication and failure reporting (#7620)

LearningCircuit04334167e470
diff --git a/.github/workflows/responsive-ui-tests-enhanced.yml b/.github/workflows/responsive-ui-tests-enhanced.yml
index 44edbf0cfc..4785432296 100644
--- a/.github/workflows/responsive-ui-tests-enhanced.yml
+++ b/.github/workflows/responsive-ui-tests-enhanced.yml
@@ -211,10 +211,12 @@ jobs:
FAILED=$(grep -oP '\d+(?= failed)' test-output.log | tail -1 || echo "0")
WARNINGS=$(grep -oP '\d+(?= warnings)' test-output.log | tail -1 || echo "0")
- if [ "$FAILED" -eq "0" ]; then
+ # Startup/auth errors and baseline regressions can exit nonzero
+ # without incrementing the page-failure counter.
+ if [ "$TEST_EXIT_CODE" -eq "0" ]; then
echo "✅ **All tests passed!**" >> test-summary.md
else
- echo "❌ **$FAILED critical issues found**" >> test-summary.md
+ echo "❌ **Responsive UI tests failed (exit code $TEST_EXIT_CODE; $FAILED reported failures)**" >> test-summary.md
fi
{
diff --git a/tests/js/responsive-ui-auth.test.js b/tests/js/responsive-ui-auth.test.js
new file mode 100644
index 0000000000..32cb12a07e
--- /dev/null
+++ b/tests/js/responsive-ui-auth.test.js
@@ -0,0 +1,109 @@
+import crypto from 'node:crypto';
+import { readFileSync } from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { runInNewContext } from 'node:vm';
+import { describe, expect, it, vi } from 'vitest';
+
+const uiDirectory = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../ui_tests');
+
+function loadCommonJS(sourceName, modules, env) {
+ const filename = path.join(uiDirectory, sourceName);
+ const module = { exports: {} };
+ runInNewContext(readFileSync(filename, 'utf8'), {
+ module,
+ require(name) {
+ if (!Object.hasOwn(modules, name)) throw new Error(`Unexpected require: ${name}`);
+ return modules[name];
+ },
+ __dirname: uiDirectory,
+ process: { env },
+ console: { log() {}, error() {} },
+ setTimeout,
+ clearTimeout,
+ }, { filename });
+ return module.exports;
+}
+
+function setup(env = { CI: 'true' }) {
+ // Keep the real helper's account-selection and timeout behavior. Only the
+ // browser operations are replaced, so registering the existing CI user
+ // would reproduce the release failure rather than pass this regression.
+ const AuthHelper = loadCommonJS('auth_helper.js', { crypto }, env);
+ const login = vi.spyOn(AuthHelper.prototype, 'login').mockResolvedValue(true);
+ const register = vi.spyOn(AuthHelper.prototype, 'register').mockResolvedValue(true);
+ vi.spyOn(AuthHelper.prototype, 'isLoggedIn').mockResolvedValue(false);
+ const recoveredPage = { recovered: true };
+ vi.spyOn(AuthHelper.prototype, 'getPage').mockReturnValue(recoveredPage);
+ const page = { setViewport: vi.fn().mockResolvedValue() };
+ const browser = {
+ newPage: vi.fn().mockResolvedValue(page),
+ close: vi.fn().mockResolvedValue(),
+ };
+ const { ResponsiveUITester } = loadCommonJS('test_responsive_ui_comprehensive.js', {
+ puppeteer: { launch: vi.fn().mockResolvedValue(browser) },
+ './auth_helper': AuthHelper,
+ './puppeteer_config': { getPuppeteerLaunchOptions: () => ({}) },
+ fs: { existsSync: () => true },
+ path,
+ }, env);
+ const tester = new ResponsiveUITester('mobile');
+ tester.captureLoginPageScreenshots = vi.fn().mockResolvedValue();
+ return { tester, login, register, recoveredPage, AuthHelper, browser };
+}
+
+describe('responsive UI authentication', () => {
+ it('logs in as the pre-created CI user without re-registering it', async () => {
+ const { tester, login, register, recoveredPage, AuthHelper } = setup();
+
+ await tester.init();
+
+ expect(login).toHaveBeenCalledExactlyOnceWith(
+ AuthHelper.CI_TEST_USER.username, AuthHelper.CI_TEST_USER.password,
+ );
+ expect(register).not.toHaveBeenCalled();
+ expect(tester.page).toBe(recoveredPage);
+ });
+
+ it('retains fresh-user fallback when the CI account is unavailable', async () => {
+ const { tester, login, register, AuthHelper } = setup();
+ login.mockRejectedValue(new Error('CI account unavailable'));
+
+ await tester.init();
+
+ expect(register).toHaveBeenCalledTimes(1);
+ expect(register.mock.calls[0][0]).not.toBe(AuthHelper.CI_TEST_USER.username);
+ expect(register.mock.calls[0][0]).toMatch(/^testuser_/);
+ });
+
+ it('propagates authentication failures instead of testing unauthenticated pages', async () => {
+ const { tester, login, register } = setup();
+ login.mockRejectedValue(new Error('CI account unavailable'));
+ const failure = new Error('Registration rejected');
+ register.mockRejectedValue(failure);
+
+ await expect(tester.init()).rejects.toBe(failure);
+ });
+
+ it('still registers a fresh user outside CI', async () => {
+ const { tester, login, register } = setup({});
+
+ await tester.init();
+
+ expect(login).not.toHaveBeenCalled();
+ expect(register).toHaveBeenCalledTimes(1);
+ });
+
+ it('closes the browser when authentication fails before layout checks', async () => {
+ const { tester, login, register, browser } = setup();
+ login.mockRejectedValue(new Error('CI account unavailable'));
+ const failure = new Error('Registration rejected');
+ register.mockRejectedValue(failure);
+ tester.testPage = vi.fn();
+
+ await expect(tester.runTests()).rejects.toBe(failure);
+
+ expect(tester.testPage).not.toHaveBeenCalled();
+ expect(browser.close).toHaveBeenCalledTimes(1);
+ });
+});
diff --git a/tests/ui_tests/test_responsive_ui_comprehensive.js b/tests/ui_tests/test_responsive_ui_comprehensive.js
index 2b08642c87..13f1518a32 100644
--- a/tests/ui_tests/test_responsive_ui_comprehensive.js
+++ b/tests/ui_tests/test_responsive_ui_comprehensive.js
@@ -113,29 +113,12 @@ class ResponsiveUITester {
console.log('Authenticating...');
const auth = new AuthHelper(this.page, this.baseUrl);
- // Use a reasonable timeout for authentication
- const authTimeout = new Promise((_, reject) =>
- setTimeout(() => reject(new Error('Authentication timeout')), 30000)
- );
-
try {
- // For CI, use the pre-created test user from the workflow
- if (process.env.CI) {
- const testUser = {
- username: 'test_admin',
- password: 'testpass123' // pragma: allowlist secret
- };
- console.log(`Using pre-created test user: ${testUser.username}`);
- await Promise.race([
- auth.ensureAuthenticated(testUser.username, testUser.password),
- authTimeout
- ]);
- } else {
- await Promise.race([
- auth.ensureAuthenticated(),
- authTimeout
- ]);
- }
+ // Any authenticated session is sufficient for layout checks.
+ // Leave the identity unspecified so the helper first logs in as
+ // the pre-created CI user instead of trying to register it again.
+ await auth.ensureAuthenticatedWithTimeout();
+ this.page = auth.getPage();
console.log('Authentication successful');
} catch (error) {
console.error('Authentication failed:', error.message);
@@ -440,15 +423,18 @@ class ResponsiveUITester {
}
async runTests() {
- await this.init();
+ try {
+ await this.init();
- console.log(`\n📱 Running Responsive UI Tests for ${this.viewport.toUpperCase()} viewport\n`);
+ console.log(`\n📱 Running Responsive UI Tests for ${this.viewport.toUpperCase()} viewport\n`);
- for (const pageInfo of TEST_PAGES) {
- await this.testPage(pageInfo);
+ for (const pageInfo of TEST_PAGES) {
+ await this.testPage(pageInfo);
+ }
+ } finally {
+ await this.cleanup();
}
- await this.cleanup();
this.printResults();
}