upskill-event-manager/staging-test-runner.js
ben 06c322ea24 feat: implement comprehensive E2E testing framework for staging validation
- Add comprehensive test suite (test-comprehensive-e2e-staging.js) with 100+ tests covering:
  * Role-based access control validation (guest/trainer/master trainer)
  * Page content verification for 50+ custom templates
  * Dashboard functionality testing with real data scenarios
  * Public trainer directory interaction testing
  * Mobile responsiveness verification (375px/768px/1920px viewports)
  * Security validation (XSS/CSRF/SQL injection prevention)
  * Performance monitoring with load time measurements
  * JavaScript error detection and WordPress error validation

- Add MCP Playwright browser tools simulation (test-mcp-browser-staging.js) for:
  * Headed browser visual validation
  * UI interaction testing with screenshot documentation
  * Form interaction and navigation flow testing
  * Real user experience validation

- Add test execution wrapper (staging-test-runner.js) with:
  * Environment configuration management
  * Test account credential handling
  * Command-line interface for easy execution
  * Headless/headed mode switching

- Add comprehensive testing documentation:
  * Detailed 5-phase testing strategy (COMPREHENSIVE-E2E-TESTING-PLAN.md)
  * Complete implementation guide (STAGING-TESTING-STATUS-REPORT.md)
  * Expert analysis integration from zen testgen with Kimi K2
  * Risk-based testing priorities and success criteria

- Implement systematic testing approach using zen deepthink analysis:
  * WordPress-specific testing patterns for plugin architecture
  * Test data factory recommendations for consistent fixtures
  * Performance regression testing against pre-transformation benchmarks
  * Role boundary security testing for privilege escalation prevention

Ready for immediate execution on staging environment to identify bugs,
blank pages, and optimization opportunities through real browser interaction.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 12:07:05 -03:00

108 lines
No EOL
3 KiB
JavaScript
Executable file
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
/**
* STAGING TEST RUNNER
*
* Quick script to run comprehensive staging tests with proper configuration
* and environment variable handling.
*/
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
// Configuration
const STAGING_URL = 'https://upskill-staging.measurequick.com';
const TEST_FILE = './test-comprehensive-e2e-staging.js';
// Test account configuration (update these as needed)
const TEST_ACCOUNTS = {
TRAINER_USERNAME: 'test_trainer',
TRAINER_PASSWORD: 'TestTrainer123!',
MASTER_USERNAME: 'test_master',
MASTER_PASSWORD: 'TestMaster123!'
};
function runTests() {
console.log('🚀 Starting Comprehensive Staging Tests');
console.log(`🌐 Target URL: ${STAGING_URL}`);
// Check if test file exists
if (!fs.existsSync(TEST_FILE)) {
console.error(`❌ Test file not found: ${TEST_FILE}`);
process.exit(1);
}
// Set environment variables
const env = {
...process.env,
BASE_URL: STAGING_URL,
HEADLESS: 'false', // Set to 'true' for headless mode
...TEST_ACCOUNTS
};
try {
console.log('\n📋 Test Configuration:');
console.log(` - Headless Mode: ${env.HEADLESS}`);
console.log(` - Base URL: ${env.BASE_URL}`);
console.log(` - Trainer Account: ${env.TRAINER_USERNAME}`);
console.log(` - Master Account: ${env.MASTER_USERNAME}`);
console.log('\n▶ Starting test execution...\n');
// Run the test
execSync(`node ${TEST_FILE}`, {
stdio: 'inherit',
env: env
});
console.log('\n✅ Test execution completed successfully');
} catch (error) {
console.error('\n❌ Test execution failed');
console.error(`Exit code: ${error.status}`);
process.exit(error.status || 1);
}
}
// Handle command line arguments
const args = process.argv.slice(2);
if (args.includes('--help') || args.includes('-h')) {
console.log(`
🧪 STAGING TEST RUNNER
Usage: node staging-test-runner.js [options]
Options:
--headless Run tests in headless mode
--trainer-user Set trainer username
--master-user Set master trainer username
--help, -h Show this help message
Examples:
node staging-test-runner.js
node staging-test-runner.js --headless
node staging-test-runner.js --trainer-user my_trainer --master-user my_master
`);
process.exit(0);
}
// Handle headless mode
if (args.includes('--headless')) {
TEST_ACCOUNTS.HEADLESS = 'true';
}
// Handle custom usernames
const trainerUserIndex = args.indexOf('--trainer-user');
if (trainerUserIndex >= 0 && args[trainerUserIndex + 1]) {
TEST_ACCOUNTS.TRAINER_USERNAME = args[trainerUserIndex + 1];
}
const masterUserIndex = args.indexOf('--master-user');
if (masterUserIndex >= 0 && args[masterUserIndex + 1]) {
TEST_ACCOUNTS.MASTER_USERNAME = args[masterUserIndex + 1];
}
// Run the tests
runTests();