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

import { Multiple } from '@digigov/ui/form/AutoComplete/__stories__/Multiple';

test('renders the Multiple show chip', async ({ mount, page }) => {
  await mount(<Multiple />);
  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>div>fieldset>div>div:nth-child(2)>button')
    .click();
  await page
    .locator(
      '#root>div>div>fieldset>div>div:nth-child(2)>ul:nth-child(4)>div>li:nth-child(3)'
    )
    .click();
  await page
    .locator('#root>div>div>fieldset>div>div:nth-child(2)>button')
    .click();

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