// @ts-check
import React from 'react';
import { test, expect } from '@playwright/experimental-ct-react';
import Switch from './index.jsx';
import { axeptio } from '../../../Presets';
import { Provider } from '../../../DesignSystem';

/**
 * Custom test utility function that wraps a test component with ThemeProvider
 * This function cannot be imported from another file because it breaks the tests
 * https://github.com/microsoft/playwright/issues/15620
 * @param {JSX.Element} component
 */
function withThemeProvider(component) {
  return (
    /* @ts-expect-error Server Component */
    <Provider theme={axeptio}>{component}</Provider>
  );
}

test.use({ viewport: { width: 500, height: 500 } });

const args = {
  active: false,
  label: 'Toto',
  offText: '',
  onText: ''
};

test('Default Switch', async ({ mount }) => {
  const component = await mount(withThemeProvider(<Switch {...args} />));
  await expect(component).toHaveCSS('color', 'rgb(255, 0, 0)');
});

// test('Active Switch', async ({ mount }) => {
//   const component = await mount(
//     /* @ts-expect-error Server Component */
//     <Provider theme={theme}>
//       <Switch {...args} active />
//     </Provider>
//   );
//   await expect(component.getByRole('checkbox').isChecked()).toBeTruthy();
// });
