textarea-size.spec.ts 828 B

12345678910111213141516171819
  1. import { test, expect } from '@playwright/test';
  2. // BUG-11 修复:使用 data-testid 兜底
  3. const TEXTAREA_LOCATOR = '[data-testid="form-textarea"], .form-textarea, textarea';
  4. test('textarea 高度足够大', async ({ page }) => {
  5. await page.goto('http://localhost:5173/#/pages/book-generator/create', { waitUntil: 'networkidle' });
  6. await page.waitForSelector(TEXTAREA_LOCATOR, { timeout: 15000 });
  7. await page.waitForTimeout(500);
  8. const info = await page.locator(TEXTAREA_LOCATOR).first().evaluate((el: any) => {
  9. const rect = el.getBoundingClientRect();
  10. return { width: rect.width, height: rect.height };
  11. });
  12. console.log('textarea 实际尺寸:', info);
  13. // 期望高度 > 200px(约 420rpx 在常见屏上)
  14. expect(info.height).toBeGreaterThan(200);
  15. expect(info.width).toBeGreaterThan(300);
  16. });