Implements the full HTML structure for the Community Registration form based on requirements, including all specified fields, labels, hints, and basic structure for error display. Adds corresponding JavaScript for dynamic state/province dropdown population.
Creates initial E2E tests (`registration.spec.ts`) for the registration page covering loading, validation scenarios (empty fields, invalid email, password mismatch, weak password), and successful submission. Creates a test data file (`personas.ts`) with sample user data.
Undertakes extensive debugging of failing E2E tests:
- Resolved initial shortcode rendering failure by correctly instantiating the `HVAC_Registration` class.
- Fixed incorrect form ID and submit button selectors in E2E tests.
- Corrected field ID selector (`#business_phone`) in E2E test.
- Refactored form submission handling multiple times (trying `init` hook, `admin_post` hooks, and direct shortcode processing) to address issues with validation error display and success redirects. Reverted to using the `init` hook with transient-based error handling as the most promising path despite current display issues.
- Identified and fixed a fatal PHP error ("Cannot redeclare handle_profile_image_upload") caused by duplicated code during refactoring.
- Troubleshot and resolved Docker volume/cache issues preventing code fixes from taking effect by restarting containers and flushing caches.
- Added and subsequently removed extensive diagnostic logging throughout the PHP classes and main plugin file to trace execution flow.
- Refined Playwright waits in E2E tests, specifically for the dynamically populated state dropdown.
Updates Memory Bank files (`activeContext.md`, `progress.md`) and `docs/implementation_plan.md` to reflect the completed unit test validation (Task 0.6) and the current debugging status of registration E2E tests (Task 1.10).
Current Status:
- Fatal errors resolved, plugin initializes correctly.
- Login E2E tests pass.
- Registration page loads correctly.
- Successful registration E2E test path completes form filling and submission, resulting in the expected redirect.
- Validation error E2E tests still fail as backend errors are not displayed on the frontend after form submission/redirect. Further debugging needed on error display mechanism (likely transient handling or HTML rendering).
Modified Files:
- docs/implementation_plan.md
- memory-bank/activeContext.md
- memory-bank/progress.md
- wordpress-dev/tests/e2e/data/personas.ts (new)
- wordpress-dev/tests/e2e/tests/registration.spec.ts (new)
- wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/assets/js/hvac-registration.js
- wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/hvac-community-events.php
- wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php
- wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-registration.php
146 lines
No EOL
6.1 KiB
TypeScript
146 lines
No EOL
6.1 KiB
TypeScript
// wordpress-dev/tests/e2e/data/personas.ts
|
|
|
|
export interface Persona {
|
|
// Core User Fields
|
|
firstName: string;
|
|
lastName: string;
|
|
email: string; // Will be made unique per test run if needed
|
|
password?: string; // Store common password or generate per test
|
|
displayName: string;
|
|
website?: string; // user_url
|
|
linkedin?: string; // user_linkedin
|
|
accreditation?: string; // personal_accreditation
|
|
bio?: string; // description
|
|
// profileImage?: string; // File upload - handle separately in tests
|
|
|
|
// Business Fields (also mapped to Organizer)
|
|
businessName: string;
|
|
businessPhone: string; // phone
|
|
businessEmail: string; // business_email (can differ from user_email)
|
|
businessWebsite?: string; // business_website
|
|
businessDescription?: string; // business_description
|
|
|
|
// Address Fields
|
|
country: 'Canada' | 'United States' | string; // user_country
|
|
stateProvince: string; // user_state (or user_state_other)
|
|
city: string; // user_city
|
|
postalCode: string; // user_zip
|
|
|
|
// Training Info Fields
|
|
createVenue: 'Yes' | 'No'; // create_venue
|
|
businessType: 'Manufacturer' | 'Distributor' | 'Contractor' | 'Consultant' | 'Educator' | 'Government' | 'Other'; // business_type
|
|
trainingAudience: string[]; // training_audience[]
|
|
trainingFormats: string[]; // training_formats[]
|
|
trainingLocations: string[]; // training_locations[]
|
|
trainingResources: string[]; // training_resources[]
|
|
|
|
// Application Fields
|
|
applicationDetails: string;
|
|
annualRevenueTarget?: number; // annual_revenue_target
|
|
}
|
|
|
|
// Common password for simplicity in testing
|
|
const COMMON_PASSWORD = 'Password123!';
|
|
|
|
export const personas: Persona[] = [
|
|
// 1. Canadian Instructor
|
|
{
|
|
firstName: 'Jean-Luc',
|
|
lastName: 'Tremblay',
|
|
email: 'jeanluc.tremblay.{timestamp}@example.ca', // Use timestamp placeholder
|
|
password: COMMON_PASSWORD,
|
|
displayName: 'JL Tremblay Training',
|
|
website: 'https://jltremblay.example.ca',
|
|
linkedin: 'https://linkedin.com/in/jltremblay',
|
|
accreditation: 'HRAI, TECA',
|
|
bio: 'Experienced HVAC instructor based in Quebec, specializing in heat pump technology.',
|
|
businessName: 'Tremblay HVAC Training Inc.',
|
|
businessPhone: '514-555-1234',
|
|
businessEmail: 'info@tremblayhvactraining.example.ca',
|
|
businessWebsite: 'https://tremblayhvactraining.example.ca',
|
|
businessDescription: 'Providing top-notch HVAC training across Eastern Canada.',
|
|
country: 'Canada',
|
|
stateProvince: 'Quebec', // Will select from dropdown
|
|
city: 'Montreal',
|
|
postalCode: 'H3B 2T9',
|
|
createVenue: 'Yes',
|
|
businessType: 'Educator',
|
|
trainingAudience: ['Industry professionals', 'Registered students'],
|
|
trainingFormats: ['In-person', 'Virtual'],
|
|
trainingLocations: ['Online', 'Regional Travel'],
|
|
trainingResources: ['Classroom', 'Training Lab', 'Ducted Heat Pump(s)', 'Presentation Slides'],
|
|
applicationDetails: 'Looking to expand my training reach through the Upskill HVAC platform.',
|
|
annualRevenueTarget: 50000,
|
|
},
|
|
// 2. US Instructor 1
|
|
{
|
|
firstName: 'Alice',
|
|
lastName: 'Johnson',
|
|
email: 'alice.johnson.{timestamp}@example.com', // Use timestamp placeholder
|
|
password: COMMON_PASSWORD,
|
|
displayName: 'Alice J HVAC',
|
|
website: 'https://alicehvac.example.com',
|
|
linkedin: '',
|
|
accreditation: 'NATE, EPA 608',
|
|
bio: 'Certified HVAC technician and instructor with 15 years of field experience.',
|
|
businessName: 'Johnson Technical Training',
|
|
businessPhone: '555-111-2222',
|
|
businessEmail: 'contact@johnsontech.example.com',
|
|
businessWebsite: 'https://johnsontech.example.com',
|
|
businessDescription: 'Hands-on HVAC training for new technicians in the Midwest.',
|
|
country: 'United States',
|
|
stateProvince: 'Illinois', // Will select from dropdown
|
|
city: 'Chicago',
|
|
postalCode: '60606',
|
|
createVenue: 'No',
|
|
businessType: 'Contractor',
|
|
trainingAudience: ['Industry professionals'],
|
|
trainingFormats: ['In-person', 'Hybrid'],
|
|
trainingLocations: ['Local', 'Regional Travel'],
|
|
trainingResources: ['Training Lab', 'Ducted Furnace(s)', 'Ducted Air Conditioner(s)', 'Training Manuals'],
|
|
applicationDetails: 'Aiming to provide practical skills training via Upskill HVAC.',
|
|
annualRevenueTarget: 75000,
|
|
},
|
|
// 3. US Instructor 2
|
|
{
|
|
firstName: 'Bob',
|
|
lastName: 'Smith',
|
|
email: 'bob.smith.{timestamp}@example.com', // Use timestamp placeholder
|
|
password: COMMON_PASSWORD,
|
|
displayName: 'Bob Smith Consulting',
|
|
website: '',
|
|
linkedin: 'https://linkedin.com/in/bobsmithhvac',
|
|
accreditation: 'CEM',
|
|
bio: 'HVAC consultant focusing on energy efficiency and commercial systems.',
|
|
businessName: 'Smith Energy Consulting LLC',
|
|
businessPhone: '555-999-8888',
|
|
businessEmail: 'bob@smithenergy.example.com',
|
|
businessWebsite: 'https://smithenergy.example.com',
|
|
businessDescription: 'Consulting and training services for commercial HVAC optimization.',
|
|
country: 'United States',
|
|
stateProvince: 'California', // Will select from dropdown
|
|
city: 'Los Angeles',
|
|
postalCode: '90012',
|
|
createVenue: 'No',
|
|
businessType: 'Consultant',
|
|
trainingAudience: ['Industry professionals', 'Anyone (open to the public)'],
|
|
trainingFormats: ['Virtual', 'On-demand'],
|
|
trainingLocations: ['Online', 'National Travel'],
|
|
trainingResources: ['Presentation Slides', 'LMS Platform / SCORM Files', 'Custom Curriculum'],
|
|
applicationDetails: 'Want to offer specialized online courses through Upskill HVAC.',
|
|
// annualRevenueTarget: undefined, // Optional field left out
|
|
},
|
|
];
|
|
|
|
/**
|
|
* Utility function to get a persona object with a unique email.
|
|
* Replaces {timestamp} with Date.now().
|
|
*/
|
|
export function getUniquePersona(personaTemplate: Persona): Persona {
|
|
const uniquePersona = JSON.parse(JSON.stringify(personaTemplate)); // Deep clone
|
|
const timestamp = Date.now();
|
|
uniquePersona.email = personaTemplate.email.replace('{timestamp}', timestamp.toString());
|
|
// Optionally make business email unique too if needed for testing
|
|
// uniquePersona.businessEmail = personaTemplate.businessEmail.replace('{timestamp}', timestamp.toString());
|
|
return uniquePersona;
|
|
} |