← back to Handbag Auth Nextjs

playwright-test.js

59 lines

const playwright = require('playwright');

(async () => {
  const browser = await playwright.chromium.launch();
  const context = await browser.newContext({
    viewport: { width: 375, height: 812 }, // iPhone X
    userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15'
  });
  
  const page = await context.newPage();
  
  console.log('📱 Testing mobile UI at http://45.61.58.125:7991');
  
  try {
    await page.goto('http://45.61.58.125:7991', { waitUntil: 'networkidle', timeout: 30000 });
    
    // Take screenshot
    await page.screenshot({ path: '/tmp/handbag-mobile.png', fullPage: true });
    console.log('✅ Screenshot saved to /tmp/handbag-mobile.png');
    
    // Check what's visible
    const hero = await page.$('section');
    const hasHero = !!hero;
    
    const listings = await page.$$('[class*="grid"]');
    const hasGrid = listings.length > 0;
    
    const images = await page.$$('img');
    const imageCount = images.length;
    
    console.log('\n📊 Current State:');
    console.log(`- Hero Section: ${hasHero ? '✅' : '❌'}`);
    console.log(`- Listings Grid: ${hasGrid ? '✅' : '❌'}`);
    console.log(`- Images Found: ${imageCount}`);
    
    // Get page title
    const title = await page.title();
    console.log(`- Page Title: ${title}`);
    
    // Check for errors
    const errors = [];
    page.on('console', msg => {
      if (msg.type() === 'error') errors.push(msg.text());
    });
    
    await page.waitForTimeout(2000);
    
    if (errors.length > 0) {
      console.log('\n❌ Console Errors:');
      errors.forEach(err => console.log(`  - ${err}`));
    }
    
  } catch (error) {
    console.error('❌ Error:', error.message);
  }
  
  await browser.close();
})();