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

import { Auto } from '@digigov/ui/navigation/Breadcrumbs/__stories__/Auto';
import { Default } from '@digigov/ui/navigation/Breadcrumbs/__stories__/Default';
import { WithHook } from '@digigov/ui/navigation/Breadcrumbs/__stories__/WithHook';

test('renders the Default Hover and click', 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.locator('#root>nav>ol>li:nth-child(1)>a').hover();
  await page.locator('#root>nav>ol>li:nth-child(1)>a').click();
  await page.keyboard.press('Tab');

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

test('renders the WithHook click', async ({ mount, page }) => {
  await mount(<WithHook />);
  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.click("[id='Εγχειρίδια Νομοθεσίας Πυρασφάλειας']");

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

test('renders the Auto click', async ({ mount, page }) => {
  await mount(<Auto />);
  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.click("[id='Εγχειρίδια Νομοθεσίας Πυρασφάλειας']");

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