- 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.
88 lines
No EOL
2.4 KiB
TypeScript
88 lines
No EOL
2.4 KiB
TypeScript
import { test as base, type Page } from '@playwright/test';
|
|
import { TestUtils } from './test-utils';
|
|
|
|
// Extend the base test fixture with our custom utilities and types
|
|
interface CustomFixtures {
|
|
testUtils: TestUtils;
|
|
loggedInPage: Page;
|
|
}
|
|
|
|
// Define custom test with extended fixtures
|
|
export const test = base.extend<CustomFixtures>({
|
|
// Add TestUtils to every test
|
|
testUtils: async ({ page }, use) => {
|
|
const testUtils = new TestUtils(page);
|
|
await use(testUtils);
|
|
},
|
|
|
|
// Provide a pre-authenticated page for tests requiring login
|
|
loggedInPage: async ({ page }, use) => {
|
|
// Navigate to login page
|
|
await page.goto('/wp-login.php');
|
|
|
|
// Fill in login credentials (these should be loaded from env variables in production)
|
|
await page.fill('#user_login', process.env.WP_TEST_USERNAME || 'testuser');
|
|
await page.fill('#user_pass', process.env.WP_TEST_PASSWORD || 'testpass');
|
|
|
|
// Submit login form
|
|
await page.click('#wp-submit');
|
|
|
|
// Wait for navigation to complete
|
|
await page.waitForLoadState('networkidle');
|
|
|
|
// Make the authenticated page available to the test
|
|
await use(page);
|
|
|
|
// Cleanup: Logout after test
|
|
await page.goto('/wp-login.php?action=logout');
|
|
await page.click('text=log out');
|
|
},
|
|
});
|
|
|
|
// Export expect from the base test
|
|
export const { expect } = test;
|
|
|
|
// Export commonly used test data
|
|
export const testData = {
|
|
urls: {
|
|
login: '/wp-login.php',
|
|
dashboard: '/wp-admin/index.php',
|
|
events: '/wp-admin/edit.php?post_type=tribe_events',
|
|
},
|
|
selectors: {
|
|
loginForm: {
|
|
username: '#user_login',
|
|
password: '#user_pass',
|
|
submit: '#wp-submit',
|
|
},
|
|
navigation: {
|
|
events: '#menu-posts-tribe_events',
|
|
settings: '#menu-settings',
|
|
},
|
|
},
|
|
timeouts: {
|
|
short: 5000,
|
|
medium: 10000,
|
|
long: 30000,
|
|
},
|
|
};
|
|
|
|
// Export common test hooks
|
|
export const hooks = {
|
|
// Setup function for tests requiring specific WordPress settings
|
|
async setupWordPressSettings(page: Page) {
|
|
// Navigate to settings
|
|
await page.goto('/wp-admin/options-general.php');
|
|
|
|
// Configure common settings
|
|
// (Add specific settings configuration as needed)
|
|
|
|
await page.waitForLoadState('networkidle');
|
|
},
|
|
|
|
// Cleanup function to reset test data
|
|
async cleanupTestData(page: Page) {
|
|
// Add cleanup logic here
|
|
// (e.g., deleting test posts, resetting settings, etc.)
|
|
},
|
|
}; |