Add debug mode feature flag with environment variable parsing, UI badge indicator, secret redaction utility, and enhanced terminal session management with status checks and session limit error handling
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
function loadMainJsAsGlobal() {
|
||||
const mainPath = path.resolve(process.cwd(), 'app', 'main.js');
|
||||
const source = fs.readFileSync(mainPath, 'utf8');
|
||||
const wrapped = `${source}\n;globalThis.__DashboardManager = DashboardManager;`;
|
||||
eval(wrapped);
|
||||
return globalThis.__DashboardManager;
|
||||
}
|
||||
|
||||
describe('DEBUG_MODE UI gating', () => {
|
||||
beforeEach(() => {
|
||||
document.body.innerHTML = `
|
||||
<div class="desktop-nav-links">
|
||||
<div class="relative group"></div>
|
||||
</div>
|
||||
<div id="hosts-list"></div>
|
||||
`;
|
||||
|
||||
delete globalThis.__DashboardManager;
|
||||
delete globalThis.DashboardManager;
|
||||
});
|
||||
|
||||
it('shows DEBUG badge only when enabled', () => {
|
||||
const DashboardManager = loadMainJsAsGlobal();
|
||||
const dashboard = new DashboardManager();
|
||||
|
||||
dashboard.setDebugBadgeVisible(false);
|
||||
expect(document.getElementById('debug-mode-badge')).toBeNull();
|
||||
|
||||
dashboard.setDebugBadgeVisible(true);
|
||||
expect(document.getElementById('debug-mode-badge')?.textContent).toBe('DEBUG');
|
||||
|
||||
dashboard.setDebugBadgeVisible(false);
|
||||
expect(document.getElementById('debug-mode-badge')).toBeNull();
|
||||
});
|
||||
|
||||
it('mounts terminal buttons when debug is disabled', () => {
|
||||
const DashboardManager = loadMainJsAsGlobal();
|
||||
const dashboard = new DashboardManager();
|
||||
|
||||
dashboard.debugModeEnabled = false;
|
||||
dashboard.hosts = [
|
||||
{
|
||||
id: 'h1',
|
||||
name: 'host1',
|
||||
ip: '127.0.0.1',
|
||||
os: 'linux',
|
||||
status: 'online',
|
||||
bootstrap_ok: true,
|
||||
groups: ['env_prod', 'role_web'],
|
||||
last_seen: new Date().toISOString(),
|
||||
},
|
||||
];
|
||||
|
||||
dashboard.renderHosts();
|
||||
|
||||
expect(document.querySelector('[data-action="terminal"]')).not.toBeNull();
|
||||
expect(document.querySelector('[data-action="terminal-popout"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('mounts terminal buttons when debug is enabled', () => {
|
||||
const DashboardManager = loadMainJsAsGlobal();
|
||||
const dashboard = new DashboardManager();
|
||||
|
||||
dashboard.debugModeEnabled = true;
|
||||
dashboard.hosts = [
|
||||
{
|
||||
id: 'h1',
|
||||
name: 'host1',
|
||||
ip: '127.0.0.1',
|
||||
os: 'linux',
|
||||
status: 'online',
|
||||
bootstrap_ok: true,
|
||||
groups: ['env_prod', 'role_web'],
|
||||
last_seen: new Date().toISOString(),
|
||||
},
|
||||
];
|
||||
|
||||
dashboard.renderHosts();
|
||||
|
||||
expect(document.querySelector('[data-action="terminal"]')).not.toBeNull();
|
||||
expect(document.querySelector('[data-action="terminal-popout"]')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -68,6 +68,7 @@ export function createMockResponse(data, status = 200) {
|
||||
export function setupFetchMock(responses = {}) {
|
||||
const defaultResponses = {
|
||||
'/api/auth/status': { setup_required: false, authenticated: true, user: { username: 'test' } },
|
||||
'/api/config': { debug_mode: false },
|
||||
'/api/hosts': [],
|
||||
'/api/tasks': [],
|
||||
'/api/schedules': [],
|
||||
|
||||
Reference in New Issue
Block a user