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

import { HorizontalWithoutDrawer } from '@digigov/ui/navigation/NavList/__stories__/HorizontalWithoutDrawer';
import { UsingHeaderButton } from '@digigov/ui/navigation/NavList/__stories__/UsingHeaderButton';
import { VerticalWithoutDrawer } from '@digigov/ui/navigation/NavList/__stories__/VerticalWithoutDrawer';

test('renders the HorizontalWithoutDrawer Open submenu', async ({
  mount,
  page,
}) => {
  await mount(<HorizontalWithoutDrawer />);
  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>ul>li:nth-child(2)>button').click();
  const screenshot = await page.screenshot({
    fullPage: true,
    animations: 'disabled',
  });
  expect(screenshot).toMatchSnapshot();
});

test('renders the VerticalWithoutDrawer Open submenu', async ({
  mount,
  page,
}) => {
  await mount(<VerticalWithoutDrawer />);
  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>ul>li:nth-child(2)>button').click();
  const screenshot = await page.screenshot({
    fullPage: true,
    animations: 'disabled',
  });
  expect(screenshot).toMatchSnapshot();
});

test('renders the UsingHeaderButton menu', async ({ mount, page }) => {
  await mount(<UsingHeaderButton />);
  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('button:text("Επιλογές")').click();
  const screenshot = await page.screenshot({
    fullPage: true,
    animations: 'disabled',
  });
  expect(screenshot).toMatchSnapshot();
});
