// Session 53 — social preview: clean OG/Twitter copy + generated OG image.

const fs = require('fs');
const path = require('path');
const APP = path.join(__dirname, '..', '..', 'web', 'src', 'app');
const read = (rel) => fs.readFileSync(path.join(APP, rel), 'utf8');

describe('Open Graph / Twitter metadata (layout)', () => {
  const src = read('layout.tsx');

  it('drops the engineer-speak from the social copy', () => {
    const og = src.slice(src.indexOf('openGraph'));
    expect(og).not.toMatch(/Bayesian/i);
    expect(og).not.toMatch(/kill condition/i);
    expect(og).not.toMatch(/point-biserial/i);
    expect(og).not.toMatch(/xG regression/i);
  });

  it('uses the new user-facing copy', () => {
    expect(src).toContain("The edge the books don't want you to have");
    expect(src).toContain('Pre-graded player props');
    expect(src).toContain('Parlay Lab');
    expect(src).toContain('Built in Detroit');
  });

  it('keeps the large Twitter card + creator', () => {
    expect(src).toContain("card: 'summary_large_image'");
    expect(src).toContain("creator: '@getvyndr'");
  });

  it('lets the file-based convention own the image (no stale /og-image.png ref)', () => {
    expect(src).not.toContain('/og-image.png');
  });
});

describe('generated OG image', () => {
  const og = read('opengraph-image.tsx');
  it('is a 1200x630 PNG with the new tagline', () => {
    expect(og).toContain('width: 1200, height: 630');
    expect(og).toContain("contentType = 'image/png'");
    expect(og).toContain('We built this to give it back.');
    expect(og).toContain('BUILT IN DETROIT');
  });
  it('does NOT use the edge runtime (self-hosted standalone)', () => {
    expect(og).not.toContain("runtime = 'edge'");
  });
  it('twitter-image reuses the same card', () => {
    expect(read('twitter-image.tsx')).toContain("from './opengraph-image'");
  });
});
