import { chromium } from 'playwright';

async function test() {
  const browser = await chromium.launch({ headless: true });
  const page = await browser.newPage();
  
  // 测试登录页
  console.log('Testing login page...');
  await page.goto('http://localhost:5176/login');
  await page.waitForTimeout(2000);
  await page.screenshot({ path: 'login-page.png', fullPage: true });
  console.log('Login page screenshot saved');
  
  // 测试登录
  console.log('Logging in...');
  await page.fill('input[placeholder="请输入手机号"]', '13800138000');
  await page.fill('input[placeholder="请输入密码"]', '123456');
  await page.click('button:has-text("登录")');
  await page.waitForTimeout(3000);
  await page.screenshot({ path: 'home-page.png', fullPage: true });
  console.log('Home page screenshot saved');
  
  // 测试车型列表
  console.log('Testing vehicles page...');
  await page.goto('http://localhost:5176/vehicles');
  await page.waitForTimeout(2000);
  await page.screenshot({ path: 'vehicles-page.png', fullPage: true });
  console.log('Vehicles page screenshot saved');
  
  // 测试订单页
  console.log('Testing orders page...');
  await page.goto('http://localhost:5176/orders');
  await page.waitForTimeout(2000);
  await page.screenshot({ path: 'orders-page.png', fullPage: true });
  console.log('Orders page screenshot saved');
  
  // 测试个人中心
  console.log('Testing profile page...');
  await page.goto('http://localhost:5176/profile');
  await page.waitForTimeout(2000);
  await page.screenshot({ path: 'profile-page.png', fullPage: true });
  console.log('Profile page screenshot saved');
  
  await browser.close();
  console.log('All tests completed!');
}

test().catch(console.error);
