/**
 * Global test setup for Playwright tests
 * This file runs before all tests
 */

const { test } = require('@playwright/test');

// Global setup
test.beforeAll(async () => {
  console.log('🚀 Starting AutoBackups E2E Tests');
  console.log('🌐 Base URL:', process.env.PLAYWRIGHT_BASE_URL || 'http://localhost:5000');
});

// Global teardown
test.afterAll(async () => {
  console.log('✅ AutoBackups E2E Tests completed');
});

// Setup for each test
test.beforeEach(async ({ page }) => {
  // Setup console logging for debugging
  page.on('console', msg => {
    if (msg.type() === 'error') {
      console.error(`Browser console error: ${msg.text()}`);
    }
  });

  page.on('pageerror', error => {
    console.error(`Browser page error: ${error.message}`);
  });

  // Set a reasonable timeout for each test
  test.setTimeout(30000);
});
