100 lines
3.3 KiB
JavaScript
100 lines
3.3 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Jabali Admin Panel Screenshot Script
|
|
*
|
|
* Takes screenshots of admin panel pages for documentation.
|
|
*
|
|
* Usage: node tests/take-screenshots.js [--output-dir=/path/to/dir]
|
|
*
|
|
* Requires: puppeteer (npm install puppeteer)
|
|
*/
|
|
|
|
const puppeteer = require('puppeteer');
|
|
const path = require('path');
|
|
|
|
// Configuration
|
|
const CONFIG = {
|
|
baseUrl: 'https://mx.jabali-panel.com',
|
|
adminPath: '/jabali-admin',
|
|
credentials: {
|
|
email: 'admin@mx.jabali-panel.com',
|
|
password: 'PycpS1dUuLvxMMQs'
|
|
},
|
|
viewport: { width: 1400, height: 900 },
|
|
outputDir: process.argv.find(a => a.startsWith('--output-dir='))?.split('=')[1] || '/tmp'
|
|
};
|
|
|
|
// Pages to screenshot
|
|
const PAGES = [
|
|
{ name: 'dashboard', path: '', description: 'Admin Dashboard' },
|
|
{ name: 'server-status', path: '/server-status', description: 'Server Status' },
|
|
{ name: 'server-settings', path: '/server-settings', description: 'Server Settings' },
|
|
{ name: 'security', path: '/security', description: 'Security Center' },
|
|
{ name: 'users', path: '/users', description: 'User Management' },
|
|
{ name: 'ssl-manager', path: '/ssl-manager', description: 'SSL Manager' },
|
|
{ name: 'dns-zones', path: '/dns-zones', description: 'DNS Zones' },
|
|
{ name: 'backups', path: '/backups', description: 'Backups' },
|
|
{ name: 'services', path: '/services', description: 'Services' },
|
|
];
|
|
|
|
async function takeScreenshots() {
|
|
console.log('Starting Jabali Admin Screenshot Script...\n');
|
|
|
|
const browser = await puppeteer.launch({
|
|
headless: 'new',
|
|
args: ['--no-sandbox', '--disable-setuid-sandbox', '--ignore-certificate-errors']
|
|
});
|
|
|
|
const page = await browser.newPage();
|
|
await page.setViewport(CONFIG.viewport);
|
|
|
|
try {
|
|
// Login
|
|
console.log('Logging in to admin panel...');
|
|
await page.goto(`${CONFIG.baseUrl}${CONFIG.adminPath}/login`, { waitUntil: 'networkidle0' });
|
|
await new Promise(r => setTimeout(r, 2000));
|
|
|
|
await page.type('input[type="email"]', CONFIG.credentials.email);
|
|
await page.type('input[type="password"]', CONFIG.credentials.password);
|
|
await page.click('button[type="submit"]');
|
|
await new Promise(r => setTimeout(r, 5000));
|
|
|
|
// Check if login succeeded
|
|
const currentUrl = page.url();
|
|
if (currentUrl.includes('/login')) {
|
|
throw new Error('Login failed - still on login page');
|
|
}
|
|
console.log('Login successful!\n');
|
|
|
|
// Take screenshots
|
|
for (const pageInfo of PAGES) {
|
|
const url = `${CONFIG.baseUrl}${CONFIG.adminPath}${pageInfo.path}`;
|
|
const filename = `admin-${pageInfo.name}.png`;
|
|
const filepath = path.join(CONFIG.outputDir, filename);
|
|
|
|
console.log(`Taking screenshot: ${pageInfo.description}`);
|
|
console.log(` URL: ${url}`);
|
|
|
|
try {
|
|
await page.goto(url, { waitUntil: 'networkidle0', timeout: 30000 });
|
|
await new Promise(r => setTimeout(r, 3000));
|
|
await page.screenshot({ path: filepath, fullPage: true });
|
|
console.log(` Saved: ${filepath}\n`);
|
|
} catch (err) {
|
|
console.log(` Error: ${err.message}\n`);
|
|
}
|
|
}
|
|
|
|
console.log('All screenshots completed!');
|
|
console.log(`Output directory: ${CONFIG.outputDir}`);
|
|
|
|
} catch (err) {
|
|
console.error('Error:', err.message);
|
|
process.exit(1);
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
}
|
|
|
|
takeScreenshots();
|