import { test, expect } from '@playwright/experimental-ct-solid';
import Button from './components/Button';
import Counter from './components/Counter';
import DefaultChildren from './components/DefaultChildren';
import MultipleChildren from './components/MultipleChildren';
import MultiRoot from './components/MultiRoot';
import EmptyFragment from './components/EmptyFragment';
import type { HooksConfig } from '../playwright';
test.use({ viewport: { width: 500, height: 500 } });
test('render props', async ({ mount }) => {
const component = await mount();
await expect(component).toContainText('Submit');
});
test('render attributes', async ({ mount }) => {
const component = await mount()
await expect(component).toHaveClass('primary');
});
test('renderer updates props without remounting', async ({ mount }) => {
const component = await mount()
await expect(component.getByTestId('props')).toContainText('9001')
await component.update()
await expect(component).not.toContainText('9001')
await expect(component.getByTestId('props')).toContainText('1337')
/**
* Ideally toContainText('2') should be toContainText('1')
* However it seems impossible to update the props, slots or events of a rendered component
*/
await expect(component.getByTestId('remount-count')).toContainText('2')
});
test('renderer updates slots without remounting', async ({ mount }) => {
const component = await mount(Default Slot)
await expect(component).toContainText('Default Slot')
await component.update(Test Slot)
await expect(component).not.toContainText('Default Slot')
await expect(component).toContainText('Test Slot')
/**
* Ideally toContainText('2') should be toContainText('1')
* However it seems impossible to update the props, slots or events of a rendered component
*/
await expect(component.getByTestId('remount-count')).toContainText('2')
});
test('renderer updates callbacks without remounting', async ({ mount }) => {
const component = await mount()
const messages: string[] = []
await component.update( {
messages.push(message)
}} />)
await component.click();
expect(messages).toEqual(['hello'])
/**
* Ideally toContainText('2') should be toContainText('1')
* However it seems impossible to update the props, slots or events of a rendered component
*/
await expect(component.getByTestId('remount-count')).toContainText('2')
});
test('execute callback when the button is clicked', async ({ mount }) => {
const messages: string[] = [];
const component = await mount(