import React from 'react'; import { test, expect } from '@playwright/experimental-ct-react'; import { GroupingButtonsAndLinks } from '@digigov/ui/form/Button/__stories__/GroupingButtonsAndLinks'; import { Primary } from '@digigov/ui/form/Button/__stories__/Primary'; import { Secondary } from '@digigov/ui/form/Button/__stories__/Secondary'; import { ThemeToggle } from '@digigov/ui/form/Button/__stories__/ThemeToggle'; import { Warning } from '@digigov/ui/form/Button/__stories__/Warning'; test('renders the GroupingButtonsAndLinks Keyboard navigation', async ({ mount, page, }) => { await mount(); 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'); const screenshot = await page.screenshot({ fullPage: true, animations: 'disabled', }); expect(screenshot).toMatchSnapshot(); }); test('renders the Primary Hover and click', async ({ mount, page }) => { await mount(); 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>button').hover(); await page.locator('#root>button').click(); const screenshot = await page.screenshot({ fullPage: true, animations: 'disabled', }); expect(screenshot).toMatchSnapshot(); }); test('renders the Secondary Hover and click', async ({ mount, page }) => { await mount(); 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>button').hover(); await page.locator('#root>button').click(); const screenshot = await page.screenshot({ fullPage: true, animations: 'disabled', }); expect(screenshot).toMatchSnapshot(); }); test('renders the ThemeToggle change theme', async ({ mount, page }) => { await mount(); 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>button').click(); const screenshot = await page.screenshot({ fullPage: true, animations: 'disabled', }); expect(screenshot).toMatchSnapshot(); }); test('renders the Warning Hover and click', async ({ mount, page }) => { await mount(); 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>button').hover(); await page.locator('#root>button').click(); const screenshot = await page.screenshot({ fullPage: true, animations: 'disabled', }); expect(screenshot).toMatchSnapshot(); });