feat: Add deployment utilities and login troubleshooting test
- Add web installer creation script - Add domain-updated plugin deployment script - Add plugin package deployment script - Add E2E test for login troubleshooting scenarios
This commit is contained in:
parent
c20be7ebbc
commit
f17234ba3b
4 changed files with 1532 additions and 0 deletions
168
wordpress-dev/bin/create-web-installer.php
Normal file
168
wordpress-dev/bin/create-web-installer.php
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
/**
|
||||
* Web-based installer for HVAC Community Events plugin
|
||||
* This file should be uploaded to the staging server root and accessed via web browser
|
||||
*/
|
||||
|
||||
// Security check - use a secret key parameter to prevent unauthorized access
|
||||
$security_key = isset($_GET['key']) ? $_GET['key'] : '';
|
||||
$valid_key = 'hvac_installer_2025'; // Change this to your preferred key
|
||||
|
||||
if ($security_key !== $valid_key) {
|
||||
die('Unauthorized access');
|
||||
}
|
||||
|
||||
// Configuration
|
||||
$staging_url = 'https://upskill-staging.measurequick.com';
|
||||
$plugin_dir = ABSPATH . 'wp-content/plugins/hvac-community-events';
|
||||
$plugin_zip_url = isset($_GET['zip_url']) ? $_GET['zip_url'] : '';
|
||||
$action = isset($_GET['action']) ? $_GET['action'] : '';
|
||||
|
||||
// Initialize WordPress
|
||||
define('WP_USE_THEMES', false);
|
||||
require_once('wp-load.php');
|
||||
|
||||
// Check admin capabilities
|
||||
if (!current_user_can('install_plugins')) {
|
||||
die('You do not have permission to install plugins');
|
||||
}
|
||||
|
||||
// Set up HTML response
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HVAC Community Events Plugin Installer</title>
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; max-width: 800px; margin: 20px auto; padding: 20px; }
|
||||
pre { background: #f5f5f5; padding: 10px; overflow: auto; }
|
||||
.success { color: green; }
|
||||
.error { color: red; }
|
||||
.step { margin-bottom: 20px; padding: 15px; border: 1px solid #ddd; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>HVAC Community Events Plugin Installer</h1>
|
||||
|
||||
<?php if ($action === 'install' && !empty($plugin_zip_url)): ?>
|
||||
<div class="step">
|
||||
<h2>Installing Plugin from URL</h2>
|
||||
<?php
|
||||
// Include WordPress plugin installer
|
||||
require_once(ABSPATH . 'wp-admin/includes/file.php');
|
||||
require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
|
||||
require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
|
||||
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
||||
|
||||
// Set up the upgrader
|
||||
$skin = new WP_Ajax_Upgrader_Skin();
|
||||
$upgrader = new Plugin_Upgrader($skin);
|
||||
|
||||
// Install the plugin
|
||||
echo '<pre>';
|
||||
echo "Attempting to install plugin from: $plugin_zip_url\n";
|
||||
$result = $upgrader->install($plugin_zip_url);
|
||||
|
||||
if ($result) {
|
||||
echo "Plugin installed successfully.\n";
|
||||
|
||||
// Activate the plugin
|
||||
$plugin_main_file = 'hvac-community-events/hvac-community-events.php';
|
||||
$activate = activate_plugin($plugin_main_file);
|
||||
|
||||
if (is_wp_error($activate)) {
|
||||
echo "Error activating plugin: " . $activate->get_error_message() . "\n";
|
||||
} else {
|
||||
echo "Plugin activated successfully.\n";
|
||||
|
||||
// Create .env file with Zoho settings
|
||||
$env_file = $plugin_dir . '/.env';
|
||||
$env_content = "# Zoho API Credentials\n";
|
||||
$env_content .= "ZOHO_CLIENT_ID=your_client_id_here\n";
|
||||
$env_content .= "ZOHO_CLIENT_SECRET=your_client_secret_here\n";
|
||||
$env_content .= "ZOHO_REDIRECT_URI={$staging_url}/wp-admin/admin-ajax.php?action=zoho_oauth_callback\n";
|
||||
$env_content .= "ZOHO_REFRESH_TOKEN=your_refresh_token_here\n\n";
|
||||
$env_content .= "# Site URL Settings\n";
|
||||
$env_content .= "UPSKILL_STAGING_URL={$staging_url}\n";
|
||||
|
||||
if (file_put_contents($env_file, $env_content)) {
|
||||
echo "Created .env file with default settings.\n";
|
||||
} else {
|
||||
echo "Could not create .env file. Please create it manually.\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "Error installing plugin.\n";
|
||||
if (is_wp_error($skin->result)) {
|
||||
echo "Error: " . $skin->result->get_error_message() . "\n";
|
||||
}
|
||||
}
|
||||
echo '</pre>';
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="step">
|
||||
<h2>Plugin Installation Form</h2>
|
||||
<form method="GET" action="">
|
||||
<input type="hidden" name="key" value="<?php echo esc_attr($valid_key); ?>">
|
||||
<input type="hidden" name="action" value="install">
|
||||
<p>
|
||||
<label for="zip_url">Plugin ZIP URL:</label><br>
|
||||
<input type="text" id="zip_url" name="zip_url" style="width: 100%;"
|
||||
placeholder="https://example.com/path/to/hvac-community-events.zip" required>
|
||||
</p>
|
||||
<p><input type="submit" value="Install Plugin"></p>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
<h2>Manual Plugin Upload</h2>
|
||||
<p>If the automatic installation fails, you can manually upload the plugin:</p>
|
||||
<ol>
|
||||
<li>Go to <a href="<?php echo esc_url(admin_url('plugin-install.php?tab=upload')); ?>" target="_blank">WordPress Plugin Upload</a></li>
|
||||
<li>Upload the plugin ZIP file</li>
|
||||
<li>Activate the plugin</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
<h2>Create .env File</h2>
|
||||
<p>After installing the plugin, create a .env file in the plugin directory with these settings:</p>
|
||||
<pre># Zoho API Credentials
|
||||
ZOHO_CLIENT_ID=your_client_id_here
|
||||
ZOHO_CLIENT_SECRET=your_client_secret_here
|
||||
ZOHO_REDIRECT_URI=<?php echo esc_html($staging_url); ?>/wp-admin/admin-ajax.php?action=zoho_oauth_callback
|
||||
ZOHO_REFRESH_TOKEN=your_refresh_token_here
|
||||
|
||||
# Site URL Settings
|
||||
UPSKILL_STAGING_URL=<?php echo esc_html($staging_url); ?></pre>
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
<h2>Plugin Status</h2>
|
||||
<?php
|
||||
// Check if plugin is installed and active
|
||||
if (is_plugin_active('hvac-community-events/hvac-community-events.php')) {
|
||||
echo '<p class="success">HVAC Community Events plugin is installed and active.</p>';
|
||||
|
||||
// Check .env file
|
||||
if (file_exists($plugin_dir . '/.env')) {
|
||||
echo '<p class="success">.env file exists in the plugin directory.</p>';
|
||||
} else {
|
||||
echo '<p class="error">.env file does not exist in the plugin directory.</p>';
|
||||
}
|
||||
} else {
|
||||
if (file_exists($plugin_dir)) {
|
||||
echo '<p class="error">HVAC Community Events plugin is installed but not active.</p>';
|
||||
} else {
|
||||
echo '<p class="error">HVAC Community Events plugin is not installed.</p>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
// End of file
|
||||
1198
wordpress-dev/bin/deploy-domain-updated-plugin.sh
Executable file
1198
wordpress-dev/bin/deploy-domain-updated-plugin.sh
Executable file
File diff suppressed because it is too large
Load diff
62
wordpress-dev/bin/deploy-plugin-package.sh
Executable file
62
wordpress-dev/bin/deploy-plugin-package.sh
Executable file
|
|
@ -0,0 +1,62 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Script to deploy the HVAC Community Events plugin to staging
|
||||
# This uses a web-based approach since SSH may have permission issues
|
||||
|
||||
# Configuration
|
||||
STAGING_URL="https://upskill-staging.measurequick.com"
|
||||
PLUGIN_DIR="/Users/ben/dev/upskill-event-manager/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events"
|
||||
TEMP_DIR="/tmp/hvac-plugin-deploy"
|
||||
PACKAGE_NAME="hvac-community-events.zip"
|
||||
WP_ADMIN="${STAGING_URL}/wp-admin"
|
||||
UPLOAD_URL="${WP_ADMIN}/plugin-install.php?tab=upload"
|
||||
|
||||
# Create deployment package
|
||||
echo "Creating plugin deployment package..."
|
||||
mkdir -p "$TEMP_DIR"
|
||||
cd "$PLUGIN_DIR" || { echo "Error: Plugin directory not found"; exit 1; }
|
||||
zip -r "$TEMP_DIR/$PACKAGE_NAME" . -x "*.git*" -x "*.DS_Store" -x "*.idea*" -x "node_modules/*" -x "vendor/*"
|
||||
|
||||
echo "Plugin package created at: $TEMP_DIR/$PACKAGE_NAME"
|
||||
echo "Package size: $(du -h $TEMP_DIR/$PACKAGE_NAME | cut -f1)"
|
||||
|
||||
# Open browser to upload page
|
||||
echo "Please manually upload the plugin package at: $TEMP_DIR/$PACKAGE_NAME"
|
||||
echo "Upload URL: $UPLOAD_URL"
|
||||
|
||||
# Instructions for manual upload and activation
|
||||
echo "=== Manual Upload Instructions ==="
|
||||
echo "1. Navigate to: $UPLOAD_URL"
|
||||
echo "2. Login with your admin credentials"
|
||||
echo "3. Click 'Browse' and select the file at: $TEMP_DIR/$PACKAGE_NAME"
|
||||
echo "4. Click 'Install Now'"
|
||||
echo "5. Once installed, click 'Activate Plugin'"
|
||||
echo "6. Verify the plugin is active at ${WP_ADMIN}/plugins.php"
|
||||
|
||||
# Open browser to upload URL
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
open "$UPLOAD_URL"
|
||||
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
xdg-open "$UPLOAD_URL"
|
||||
fi
|
||||
|
||||
# Create instructions for creating the .env file with required Zoho settings
|
||||
cat > "$TEMP_DIR/zoho-env-instructions.txt" << EOF
|
||||
### IMPORTANT: After plugin activation, create a .env file in the plugin directory with the following settings:
|
||||
|
||||
# Create this file at: /wp-content/plugins/hvac-community-events/.env
|
||||
|
||||
# Zoho API Credentials
|
||||
ZOHO_CLIENT_ID=your_client_id_here
|
||||
ZOHO_CLIENT_SECRET=your_client_secret_here
|
||||
ZOHO_REDIRECT_URI=${STAGING_URL}/wp-admin/admin-ajax.php?action=zoho_oauth_callback
|
||||
ZOHO_REFRESH_TOKEN=your_refresh_token_here
|
||||
|
||||
# Site URL Settings
|
||||
UPSKILL_STAGING_URL=${STAGING_URL}
|
||||
|
||||
# Create this file using the WordPress file editor or via FTP
|
||||
EOF
|
||||
|
||||
echo "Zoho environment instructions created at: $TEMP_DIR/zoho-env-instructions.txt"
|
||||
echo "Done! Follow the instructions above to complete the installation."
|
||||
104
wordpress-dev/tests/e2e/login-troubleshooting.test.ts
Normal file
104
wordpress-dev/tests/e2e/login-troubleshooting.test.ts
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
import { STAGING_URL } from './config/staging-config';
|
||||
|
||||
/**
|
||||
* Test to troubleshoot login-related issues
|
||||
* This test checks different login selectors and error message patterns
|
||||
*/
|
||||
test.describe('Login Troubleshooting', () => {
|
||||
test('Analyze login form and error messages', async ({ page }) => {
|
||||
// Navigate to login page
|
||||
await page.goto(`${STAGING_URL}/community-login/`);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
console.log(`Current URL: ${page.url()}`);
|
||||
console.log(`Page title: ${await page.title()}`);
|
||||
|
||||
// Take screenshot of login page
|
||||
await page.screenshot({ path: 'test-results/login-form.png' });
|
||||
|
||||
// Check for form elements
|
||||
const usernameField = page.locator('#user_login');
|
||||
const passwordField = page.locator('#user_pass');
|
||||
const submitButton = page.locator('#wp-submit');
|
||||
|
||||
console.log(`Username field visible: ${await usernameField.isVisible()}`);
|
||||
console.log(`Password field visible: ${await passwordField.isVisible()}`);
|
||||
console.log(`Submit button visible: ${await submitButton.isVisible()}`);
|
||||
|
||||
// Check if form is in an iframe
|
||||
const loginIframe = page.frameLocator('iframe[name="login-form"]').first();
|
||||
const iframeExists = await page.locator('iframe[name="login-form"]').count() > 0;
|
||||
console.log(`Login form in iframe: ${iframeExists}`);
|
||||
|
||||
// Test with valid credentials first
|
||||
await usernameField.fill('test_trainer');
|
||||
await passwordField.fill('Test123!');
|
||||
await submitButton.click();
|
||||
|
||||
// Wait for navigation
|
||||
await page.waitForLoadState('networkidle');
|
||||
console.log(`After login URL: ${page.url()}`);
|
||||
console.log(`After login title: ${await page.title()}`);
|
||||
|
||||
// Take screenshot after login
|
||||
await page.screenshot({ path: 'test-results/after-login.png' });
|
||||
|
||||
// Navigate back to login
|
||||
await page.goto(`${STAGING_URL}/community-login/`);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Test with invalid credentials
|
||||
await usernameField.fill('invalid_user');
|
||||
await passwordField.fill('wrong_password');
|
||||
await submitButton.click();
|
||||
|
||||
// Wait for potential error message
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Take screenshot of error state
|
||||
await page.screenshot({ path: 'test-results/login-error.png' });
|
||||
|
||||
// Check all possible error message selectors
|
||||
const errorSelectors = [
|
||||
'.login-error',
|
||||
'.login_error',
|
||||
'#login_error',
|
||||
'.error',
|
||||
'.message',
|
||||
'.notice-error',
|
||||
'.woocommerce-error',
|
||||
'.wp-die-message',
|
||||
'p.error',
|
||||
'div.error'
|
||||
];
|
||||
|
||||
console.log('Checking error message selectors:');
|
||||
for (const selector of errorSelectors) {
|
||||
const count = await page.locator(selector).count();
|
||||
const visible = count > 0 ? await page.locator(selector).isVisible() : false;
|
||||
const text = visible ? await page.locator(selector).textContent() : 'N/A';
|
||||
|
||||
console.log(`- Selector: ${selector}`);
|
||||
console.log(` Count: ${count}`);
|
||||
console.log(` Visible: ${visible}`);
|
||||
console.log(` Text: ${text}`);
|
||||
}
|
||||
|
||||
// Check error message in page content
|
||||
const pageContent = await page.content();
|
||||
console.log('Page content contains:');
|
||||
console.log(`- "Invalid username": ${pageContent.includes('Invalid username')}`);
|
||||
console.log(`- "incorrect password": ${pageContent.includes('incorrect password')}`);
|
||||
console.log(`- "Unknown username": ${pageContent.includes('Unknown username')}`);
|
||||
console.log(`- "Error": ${pageContent.includes('Error')}`);
|
||||
|
||||
// Check DOM structure around form
|
||||
const formParent = await page.evaluate(() => {
|
||||
const form = document.querySelector('form');
|
||||
return form ? form.parentElement?.tagName + '#' + form.parentElement?.id + '.' + form.parentElement?.className : 'Not found';
|
||||
});
|
||||
|
||||
console.log(`Form parent element: ${formParent}`);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue