import React from 'react';
import { test, expect } from '@playwright/experimental-ct-react';

import { Default } from '@digigov/ui/form/RadioContainer/__stories__/Default';
import { WithHints } from '@digigov/ui/form/RadioContainer/__stories__/WithHints';

test('renders the Default Navigate with keyboard', async ({ mount, page }) => {
  await mount(<Default />);
  await page.evaluate(() => document.fonts.ready);

  // Move the mouse to the top-left corner to avoid random hover issues
  await page.mouse.move(0, 0);

  await page.keyboard.press('Tab');
  await page.keyboard.press('Space');
  await page.keyboard.press('ArrowDown');

  const screenshot = await page.screenshot({
    fullPage: true,
    animations: 'disabled',
  });
  expect(screenshot).toMatchSnapshot();
});

test('renders the WithHints Click first', async ({ mount, page }) => {
  await mount(<WithHints />);
  await page.evaluate(() => document.fonts.ready);

  // Move the mouse to the top-left corner to avoid random hover issues
  await page.mouse.move(0, 0);

  await page
    .locator('#root>div>fieldset>div>div:nth-child(1)>label>input')
    .click();
  const screenshot = await page.screenshot({
    fullPage: true,
    animations: 'disabled',
  });
  expect(screenshot).toMatchSnapshot();
});
