fix: fixed event reassignment on update and removed slot tests for v4
This commit is contained in:
parent
642b074ac3
commit
1a47fc3af5
|
|
@ -92,6 +92,9 @@ window.playwrightMount = async (component, rootElement, hooksConfig) => {
|
|||
|
||||
for (const hook of window.__pw_hooks_after_mount || [])
|
||||
await hook({ hooksConfig, svelteComponent });
|
||||
|
||||
for (const [key, listener] of Object.entries(component.on || {}))
|
||||
svelteComponent.$on(key, event => listener(event.detail));
|
||||
};
|
||||
|
||||
window.playwrightUnmount = async rootElement => {
|
||||
|
|
@ -111,4 +114,7 @@ window.playwrightUpdate = async (rootElement, component) => {
|
|||
throw new Error('Component was not mounted');
|
||||
|
||||
svelteComponent.$set(extractParams(component));
|
||||
|
||||
for (const [key, listener] of Object.entries(component.on || {}))
|
||||
svelteComponent.$on(key, event => listener(event.detail));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
import { test, expect } from '@playwright/experimental-ct-svelte';
|
||||
import DefaultSlot from '@/components/DefaultSlot.svelte';
|
||||
import NamedSlots from '@/components/NamedSlots.svelte';
|
||||
|
||||
test('render a default slot', async ({ mount }) => {
|
||||
const component = await mount(DefaultSlot, {
|
||||
slots: {
|
||||
default: 'Main Content',
|
||||
},
|
||||
});
|
||||
await expect(component).toContainText('Main Content');
|
||||
});
|
||||
|
||||
test('render a component with a named slot', async ({ mount }) => {
|
||||
const component = await mount(NamedSlots, {
|
||||
slots: {
|
||||
header: 'Header',
|
||||
main: 'Main Content',
|
||||
footer: 'Footer',
|
||||
},
|
||||
});
|
||||
await expect(component).toContainText('Header');
|
||||
await expect(component).toContainText('Main Content');
|
||||
await expect(component).toContainText('Footer');
|
||||
});
|
||||
Loading…
Reference in a new issue