upskill-event-manager/wordpress-dev/tests/e2e/utils/testHelpers.ts
bengizmo d6211ee364 feat(testing): Implement HVAC_Test_User_Factory and update .gitignore
- 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.
2025-04-14 17:41:36 -03:00

46 lines
No EOL
1.6 KiB
TypeScript

import { expect } from '@playwright/test';
import { LogEntry } from './logParser';
expect.extend({
async toContainEventCreation(logs: LogEntry[], eventName: string) {
const eventCreationLog = logs.find(log =>
log.level === 'INFO' &&
log.component === 'EventManager' &&
log.message.includes(`Event created: ${eventName}`)
);
return {
pass: !!eventCreationLog,
message: () =>
eventCreationLog
? `Expected logs not to contain event creation for "${eventName}"`
: `Expected logs to contain event creation for "${eventName}"`
};
},
async toContainEventModification(logs: LogEntry[], eventName: string) {
const eventModificationLog = logs.find(log =>
log.level === 'INFO' &&
log.component === 'EventManager' &&
log.message.includes(`Event modified: ${eventName}`)
);
return {
pass: !!eventModificationLog,
message: () =>
eventModificationLog
? `Expected logs not to contain event modification for "${eventName}"`
: `Expected logs to contain event modification for "${eventName}"`
};
}
});
// Add the custom matchers to the global expect interface
declare global {
namespace PlaywrightTest {
interface Matchers<R> {
toContainEventCreation(eventName: string): Promise<R>;
toContainEventModification(eventName: string): Promise<R>;
}
}
}