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

import { Default } from '@digigov/ui/navigation/Tabs/__stories__/Default';
const SCREENSHOT_DELAY = 2_000;
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

test('renders the Default Click second tab', 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 delay(SCREENSHOT_DELAY);
  await page.locator('#root>div>ul>li:nth-child(2)>a').hover();
  await page.locator('#root>div>ul>li:nth-child(2)>a').click();

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