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

import { WithHeaderNavigation } from '@digigov/ui/app/Header/__stories__/WithHeaderNavigation';
import { WithServiceNameAndLogo } from '@digigov/ui/app/Header/__stories__/WithServiceNameAndLogo';

test('renders the WithHeaderNavigation Hover on dropdown', async ({
  mount,
  page,
}) => {
  await mount(<WithHeaderNavigation />);
  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>header>div>div:nth-child(2)>button').hover();
  const screenshot = await page.screenshot({
    fullPage: true,
    animations: 'disabled',
  });
  expect(screenshot).toMatchSnapshot();
});

test('renders the WithServiceNameAndLogo Keyboard navigation', async ({
  mount,
  page,
}) => {
  await mount(<WithServiceNameAndLogo />);
  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('Tab');
  await page.keyboard.press('Tab');

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