closes: https://github.com/microsoft/playwright/issues/27587#issuecomment-1762133376 related: https://github.com/microsoft/playwright/pull/27692 CC @dgozman Co-authored-by: sand4rt <mbr@mbrs-MacBook-Air.local>
61 lines
2 KiB
TypeScript
61 lines
2 KiB
TypeScript
import { test, expect } from '@playwright/experimental-ct-solid';
|
|
import Button from '@/components/Button';
|
|
import DefaultChildren from '@/components/DefaultChildren';
|
|
import MultipleChildren from '@/components/MultipleChildren';
|
|
|
|
test('render a default child', async ({ mount }) => {
|
|
const component = await mount(
|
|
<DefaultChildren>Main Content</DefaultChildren>
|
|
);
|
|
await expect(component).toContainText('Main Content');
|
|
});
|
|
|
|
test('render multiple children', async ({ mount }) => {
|
|
const component = await mount(
|
|
<DefaultChildren>
|
|
<div data-testid="one">One</div>
|
|
<div data-testid="two">Two</div>
|
|
</DefaultChildren>
|
|
);
|
|
await expect(component.getByTestId('one')).toContainText('One');
|
|
await expect(component.getByTestId('two')).toContainText('Two');
|
|
});
|
|
|
|
test('render a component as child', async ({ mount }) => {
|
|
const component = await mount(
|
|
<DefaultChildren>
|
|
<Button title="Submit" />
|
|
</DefaultChildren>
|
|
);
|
|
await expect(component).toContainText('Submit');
|
|
});
|
|
|
|
test('render named children', async ({ mount }) => {
|
|
const component = await mount(
|
|
<MultipleChildren>
|
|
<div>Header</div>
|
|
<div>Main Content</div>
|
|
<div>Footer</div>
|
|
</MultipleChildren>
|
|
);
|
|
await expect(component).toContainText('Header');
|
|
await expect(component).toContainText('Main Content');
|
|
await expect(component).toContainText('Footer');
|
|
});
|
|
|
|
test('render string as child', async ({ mount }) => {
|
|
const component = await mount(<DefaultChildren>{'string'}</DefaultChildren>);
|
|
await expect(component).toContainText('string');
|
|
});
|
|
|
|
test('render array as child', async ({ mount }) => {
|
|
const component = await mount(<DefaultChildren>{[<h4>{[4]}</h4>,[[<p>[2,3]</p>]]]}</DefaultChildren>);
|
|
await expect(component.getByRole('heading', { level: 4 })).toHaveText('4');
|
|
await expect(component.getByRole('paragraph')).toHaveText('[2,3]');
|
|
});
|
|
|
|
test('render number as child', async ({ mount }) => {
|
|
const component = await mount(<DefaultChildren>{1337}</DefaultChildren>);
|
|
await expect(component).toContainText('1337');
|
|
});
|