import { test, expect } from '@playwright/test';
import fs from 'fs/promises';
import path from 'path';

const docsDir = path.join(__dirname, '..', 'docs');

test.describe('Docs content checks', () => {
  test('competitive-analysis has Licencia lines and Metadatos', async () => {
    const file = await fs.readFile(path.join(docsDir, 'competitive-analysis.md'), 'utf-8');
    expect(file).toContain('Licencia:');
    expect(file).toContain('Fuentes');
    expect(file).toContain('Metadatos');
    expect(file).toContain('Autor: Quasar (investigación automatizada)');
    expect(file).toContain('Última actualización: 2026-02-07');
  });

  test('apis-comparison includes Fecha verificación and subscription markers', async () => {
    const file = await fs.readFile(path.join(docsDir, 'apis-comparison.md'), 'utf-8');
    expect(file).toContain('Fecha verificación: 2026-02-07');
    expect(file).toMatch(/PriceCharting|MobyGames|EmuMovies/);
    expect(file).toContain('TOS');
  });

  test('lessons-learned contains PoC and license compatibility note', async () => {
    const file = await fs.readFile(path.join(docsDir, 'lessons-learned.md'), 'utf-8');
    expect(file).toContain(
      'PoC propuesta: Backend mínimo (Node/Fastify) que implemente search IGDB + RAWG y cache LRU de 24h'
    );
    expect(file).toContain('compatibilidad de licencias');
    expect(file).toContain('Fuentes');
    expect(file).toContain('Metadatos');
  });
});
