partial fix for: 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>
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import { test, expect } from '@playwright/experimental-ct-vue';
|
|
import Button from '@/components/Button.vue';
|
|
import DefaultSlot from '@/components/DefaultSlot.vue';
|
|
import NamedSlots from '@/components/NamedSlots.vue';
|
|
|
|
test('render a default slot', async ({ mount }) => {
|
|
const component = await mount(
|
|
<DefaultSlot>
|
|
<strong>Main Content</strong>
|
|
</DefaultSlot>
|
|
);
|
|
await expect(component.getByRole('strong')).toContainText('Main Content');
|
|
});
|
|
|
|
test('render a component as slot', async ({ mount }) => {
|
|
const component = await mount(
|
|
<DefaultSlot>
|
|
<Button title="Submit" />
|
|
</DefaultSlot>
|
|
);
|
|
await expect(component).toContainText('Submit');
|
|
});
|
|
|
|
test('render a component with multiple slots', async ({ mount }) => {
|
|
const component = await mount(
|
|
<DefaultSlot>
|
|
<div data-testid="one">One</div>
|
|
<div data-testid="two">Two</div>
|
|
</DefaultSlot>
|
|
);
|
|
await expect(component.getByTestId('one')).toContainText('One');
|
|
await expect(component.getByTestId('two')).toContainText('Two');
|
|
});
|
|
|
|
test('render a component with a named slot', async ({ mount }) => {
|
|
const component = await mount(
|
|
<NamedSlots>
|
|
<template v-slot:header>Header</template>
|
|
<template v-slot:main>Main Content</template>
|
|
<template v-slot:footer>Footer</template>
|
|
</NamedSlots>
|
|
);
|
|
await expect(component).toContainText('Header');
|
|
await expect(component).toContainText('Main Content');
|
|
await expect(component).toContainText('Footer');
|
|
});
|
|
|
|
test('render array as child', async ({ mount }) => {
|
|
const component = await mount(<DefaultSlot>{[<h4>{[4]}</h4>,[[<p>[2,3]</p>]]]}</DefaultSlot>);
|
|
await expect(component.getByRole('heading', { level: 4 })).toHaveText('4');
|
|
await expect(component.getByRole('paragraph')).toHaveText('[2,3]');
|
|
});
|