fix(ct-vue): update default slot should work (#32952)

Closes https://github.com/microsoft/playwright/issues/32809

We were writing onto the wrong object.
This commit is contained in:
Simon Knott 2024-10-04 14:18:21 +02:00 committed by GitHub
parent 10d6812058
commit ff0c498904
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 26 additions and 1 deletions

View File

@ -188,7 +188,7 @@ function __pwWrapFunctions(slots) {
for (const [key, value] of Object.entries(slots || {}))
slotsWithRenderFunctions[key] = () => [value];
} else if (slots?.length) {
slots['default'] = () => slots;
slotsWithRenderFunctions['default'] = () => slots;
}
return slotsWithRenderFunctions;
}

View File

@ -0,0 +1,3 @@
<template>
<slot>default value</slot>
</template>

View File

@ -2,6 +2,7 @@ import { test, expect } from '@playwright/experimental-ct-vue';
import DefaultSlot from '@/components/DefaultSlot.vue';
import NamedSlots from '@/components/NamedSlots.vue';
import Button from '@/components/Button.vue';
import SlotDefaultValue from "@/components/SlotDefaultValue.vue";
test('render a default slot', async ({ mount }) => {
const component = await mount(DefaultSlot, {
@ -49,3 +50,13 @@ test('render a component with a named slot', async ({ mount }) => {
await expect(component).toContainText('Main Content');
await expect(component).toContainText('Footer');
});
test('updating default slot should work', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/32809' } }, async ({ mount }) => {
const slots = { default: 'foo' };
const component = await mount(SlotDefaultValue, { slots });
await expect(component).toHaveText('foo');
await component.update({ slots });
await expect(component).toHaveText('foo');
});

View File

@ -2,6 +2,7 @@ import { test, expect } from '@playwright/experimental-ct-vue';
import DefaultSlot from '@/components/DefaultSlot.vue';
import NamedSlots from '@/components/NamedSlots.vue';
import Button from '@/components/Button.vue';
import SlotDefaultValue from "@/components/SlotDefaultValue.vue";
test('render a default slot', async ({ mount }) => {
const component = await mount(DefaultSlot, {
@ -49,3 +50,13 @@ test('render a component with a named slot', async ({ mount }) => {
await expect(component).toContainText('Main Content');
await expect(component).toContainText('Footer');
});
test('updating default slot should work', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/32809' } }, async ({ mount }) => {
const slots = { default: 'foo' };
const component = await mount(SlotDefaultValue, { slots });
await expect(component).toHaveText('foo');
await component.update({ slots });
await expect(component).toHaveText('foo');
});