- Add HVAC_Test_User_Factory class with: * User creation with specific roles * Multiple role support * Persona management system * Account cleanup integration - Create comprehensive test suite in HVAC_Test_User_Factory_Test.php - Update testing improvement plan documentation - Add implementation decisions to project memory bank - Restructure .gitignore with: * Whitelist approach for better file management * Explicit backup exclusions * Specific bin directory inclusions Part of the Account Management component from the testing framework improvement plan.
137 lines
No EOL
5.6 KiB
TypeScript
137 lines
No EOL
5.6 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { RegistrationPage } from './pages/RegistrationPage';
|
|
import * as path from 'path';
|
|
|
|
test.describe('Community Registration Page Tests', () => {
|
|
let registrationPage: RegistrationPage;
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
registrationPage = new RegistrationPage(page);
|
|
await registrationPage.navigate();
|
|
});
|
|
|
|
test('Valid registration completes successfully', async () => {
|
|
await registrationPage.fillPersonalInfo({
|
|
firstName: 'John',
|
|
lastName: 'Doe',
|
|
email: 'john.doe@example.com',
|
|
password: 'ValidPass123!',
|
|
displayName: 'JohnDoe'
|
|
});
|
|
|
|
await registrationPage.fillBusinessInfo({
|
|
businessName: 'HVAC Experts Inc',
|
|
businessPhone: '555-123-4567',
|
|
businessEmail: 'business@hvacexperts.com',
|
|
country: 'US',
|
|
state: 'US-NY',
|
|
city: 'New York',
|
|
businessType: 'Contractor'
|
|
});
|
|
|
|
await registrationPage.fillTrainingInfo({
|
|
audience: ['Residential', 'Commercial'],
|
|
formats: ['In-Person', 'Online'],
|
|
locations: ['On-Site', 'Training Center'],
|
|
resources: ['Tools', 'Equipment'],
|
|
details: 'Experienced HVAC trainer with 10+ years in the field.'
|
|
});
|
|
|
|
await registrationPage.submitForm();
|
|
await registrationPage.verifySuccessfulRegistration();
|
|
});
|
|
|
|
test('Required fields validation', async () => {
|
|
await registrationPage.submitForm();
|
|
|
|
// Personal Information
|
|
await registrationPage.verifyErrorMessage('First Name is required');
|
|
await registrationPage.verifyErrorMessage('Last Name is required');
|
|
await registrationPage.verifyErrorMessage('Email is required');
|
|
await registrationPage.verifyErrorMessage('Password is required');
|
|
await registrationPage.verifyErrorMessage('Display Name is required');
|
|
|
|
// Business Information
|
|
await registrationPage.verifyErrorMessage('Business Name is required');
|
|
await registrationPage.verifyErrorMessage('Business Phone is required');
|
|
await registrationPage.verifyErrorMessage('Business Email is required');
|
|
await registrationPage.verifyErrorMessage('Country is required');
|
|
await registrationPage.verifyErrorMessage('City is required');
|
|
await registrationPage.verifyErrorMessage('Business Type is required');
|
|
|
|
// Training Information
|
|
await registrationPage.verifyErrorMessage('Training Audience is required');
|
|
await registrationPage.verifyErrorMessage('Training Formats is required');
|
|
await registrationPage.verifyErrorMessage('Training Locations is required');
|
|
await registrationPage.verifyErrorMessage('Training Resources is required');
|
|
});
|
|
|
|
test('Password complexity requirements', async () => {
|
|
const testCases = [
|
|
{ password: 'short', error: 'Password must be at least 8 characters' },
|
|
{ password: 'nouppercase123', error: 'Password must include an uppercase letter' },
|
|
{ password: 'NOLOWERCASE123', error: 'Password must include a lowercase letter' },
|
|
{ password: 'NoNumbers!', error: 'Password must include a number' }
|
|
];
|
|
|
|
for (const testCase of testCases) {
|
|
await registrationPage.fillPersonalInfo({
|
|
firstName: 'Test',
|
|
lastName: 'User',
|
|
email: 'test@example.com',
|
|
password: testCase.password,
|
|
displayName: 'TestUser'
|
|
});
|
|
await registrationPage.submitForm();
|
|
await registrationPage.verifyErrorMessage(testCase.error);
|
|
}
|
|
});
|
|
|
|
test('Profile image upload validation', async () => {
|
|
// Valid file types
|
|
const validFiles = ['test.jpg', 'test.png', 'test.gif', 'test.mpg'];
|
|
for (const file of validFiles) {
|
|
const filePath = path.join('tests', 'fixtures', file);
|
|
await registrationPage.uploadProfileImage(filePath);
|
|
// Should not show error
|
|
const errorVisible = await registrationPage.page.isVisible(registrationPage['selectors'].errorMessages);
|
|
expect(errorVisible).toBe(false);
|
|
}
|
|
|
|
// Invalid file type
|
|
const invalidFile = path.join('tests', 'fixtures', 'test.exe');
|
|
await registrationPage.uploadProfileImage(invalidFile);
|
|
await registrationPage.verifyErrorMessage('Invalid file type. Allowed: jpg, png, gif, mpg');
|
|
});
|
|
|
|
test('Country/State selection logic', async () => {
|
|
await registrationPage.fillBusinessInfo({
|
|
businessName: 'Test Company',
|
|
businessPhone: '555-0000',
|
|
businessEmail: 'test@company.com',
|
|
country: 'US',
|
|
state: 'US-CA',
|
|
city: 'Test City',
|
|
businessType: 'Manufacturer'
|
|
});
|
|
|
|
// Verify US/Canada states appear at top
|
|
await registrationPage.verifyCountryStateLogic();
|
|
|
|
// Test "Other" state option for non-US/Canada country
|
|
await registrationPage.fillBusinessInfo({
|
|
businessName: 'Test Company',
|
|
businessPhone: '555-0000',
|
|
businessEmail: 'test@company.com',
|
|
country: 'FR',
|
|
state: 'OTHER',
|
|
city: 'Paris',
|
|
businessType: 'Manufacturer'
|
|
});
|
|
|
|
await registrationPage.submitForm();
|
|
// Should not show state-related error
|
|
const errorVisible = await registrationPage.page.isVisible(registrationPage['selectors'].errorMessages);
|
|
expect(errorVisible).toBe(false);
|
|
});
|
|
}); |