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

import { MultipleQuestions } from '@digigov/ui/form/Checkbox/__stories__/MultipleQuestions';
import { WithHint } from '@digigov/ui/form/Checkbox/__stories__/WithHint';

test('renders the MultipleQuestions check first box', async ({
  mount,
  page,
}) => {
  await mount(<MultipleQuestions />);
  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();
});

test('renders the WithHint click first option', async ({ mount, page }) => {
  await mount(<WithHint />);
  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();
  await page
    .locator('#root>div>fieldset>div>div:nth-child(2)>label>input')
    .click();
  await page.keyboard.press('Tab');
  await page.keyboard.press('Space');

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