tigerstyle-life9/@artifacts/test-backup-automation.cjs
Ryan Malloy e92b7f8700 Initial commit: TigerStyle Life9 v1.0.0
Because cats have 9 lives, but servers don't - so they need
backup-restore! Complete backup solution with S3/MinIO support.

- Full WordPress backup (files + database)
- S3 / MinIO / S3-compatible storage backends
- Scheduled automatic backups
- Disaster recovery / one-click restore
- Backup integrity validation
- Cat-themed admin interface

Includes build.sh and .distignore for WordPress-installable release ZIPs.
2026-05-27 14:32:00 -06:00

143 lines
6.0 KiB
JavaScript

// WordPress Backup Testing Script
// This script will test the backup functionality using playwright
const { chromium } = require('playwright');
async function testBackupFunctionality() {
console.log('🚀 Starting WordPress backup functionality test...');
const browser = await chromium.launch({
headless: false, // Show browser for debugging
slowMo: 1000 // Slow down actions for visibility
});
const context = await browser.newContext({
viewport: { width: 1280, height: 720 }
});
const page = await context.newPage();
try {
// Navigate to WordPress admin
console.log('📍 Navigating to WordPress admin...');
await page.goto('https://9lives.l.supported.systems/wp-admin');
// Wait for login page to load
await page.waitForSelector('#loginform', { timeout: 10000 });
console.log('✅ Login page loaded');
// You'll need to add credentials here or handle authentication
console.log('⚠️ Authentication required - please login manually');
console.log(' Username: [admin credentials needed]');
console.log(' Password: [admin credentials needed]');
// Wait for manual login (you could automate this with credentials)
console.log('⏳ Waiting 30 seconds for manual login...');
await page.waitForTimeout(30000);
// Navigate to backup page
console.log('📍 Navigating to backup page...');
await page.goto('https://9lives.l.supported.systems/wp-admin/admin.php?page=tigerstyle-life9-complete-backup');
// Wait for backup page to load
await page.waitForSelector('form', { timeout: 10000 });
console.log('✅ Backup page loaded');
// Take screenshot of the backup page
const screenshotPath = `@artifacts/screenshots/${new Date().toISOString().split('T')[0]}/backup-page-${Date.now()}.png`;
await page.screenshot({
path: screenshotPath,
fullPage: true
});
console.log(`📸 Screenshot saved: ${screenshotPath}`);
// Fill out the backup form
console.log('📝 Filling out backup form...');
// Look for backup name field
const nameField = await page.locator('input[name="backup_name"], input[type="text"]').first();
if (await nameField.isVisible()) {
await nameField.fill('test-pclzip-backup');
console.log('✅ Backup name set: test-pclzip-backup');
}
// Check "Include Files" if available
const includeFilesCheckbox = await page.locator('input[name*="files"], input[value*="files"]').first();
if (await includeFilesCheckbox.isVisible()) {
await includeFilesCheckbox.check();
console.log('✅ Include Files checked');
}
// Check "Include Database" if available
const includeDatabaseCheckbox = await page.locator('input[name*="database"], input[value*="database"]').first();
if (await includeDatabaseCheckbox.isVisible()) {
await includeDatabaseCheckbox.check();
console.log('✅ Include Database checked');
}
// Take screenshot before submission
const preSubmitScreenshot = `@artifacts/screenshots/${new Date().toISOString().split('T')[0]}/backup-form-filled-${Date.now()}.png`;
await page.screenshot({
path: preSubmitScreenshot,
fullPage: true
});
console.log(`📸 Pre-submission screenshot: ${preSubmitScreenshot}`);
// Submit the form
console.log('🚀 Submitting backup form...');
const submitButton = await page.locator('input[type="submit"], button[type="submit"]').first();
if (await submitButton.isVisible()) {
await submitButton.click();
console.log('✅ Form submitted');
// Wait for response
await page.waitForTimeout(5000);
// Take screenshot of result
const resultScreenshot = `@artifacts/screenshots/${new Date().toISOString().split('T')[0]}/backup-result-${Date.now()}.png`;
await page.screenshot({
path: resultScreenshot,
fullPage: true
});
console.log(`📸 Result screenshot: ${resultScreenshot}`);
// Check for success or error messages
const successMessages = await page.locator('.notice-success, .updated, .success').count();
const errorMessages = await page.locator('.notice-error, .error').count();
console.log(`✅ Success messages found: ${successMessages}`);
console.log(`❌ Error messages found: ${errorMessages}`);
// Log any visible error text
const errors = await page.locator('.notice-error, .error').allTextContents();
if (errors.length > 0) {
console.log('❌ Error details:', errors);
}
// Log any visible success text
const successes = await page.locator('.notice-success, .updated, .success').allTextContents();
if (successes.length > 0) {
console.log('✅ Success details:', successes);
}
} else {
console.log('❌ Submit button not found');
}
} catch (error) {
console.error('❌ Test failed:', error);
// Take error screenshot
const errorScreenshot = `@artifacts/screenshots/${new Date().toISOString().split('T')[0]}/backup-error-${Date.now()}.png`;
await page.screenshot({
path: errorScreenshot,
fullPage: true
});
console.log(`📸 Error screenshot: ${errorScreenshot}`);
} finally {
await browser.close();
console.log('🏁 Test completed');
}
}
// Run the test
testBackupFunctionality().catch(console.error);