fix(ct): mount then unmount then mount (#30657)
closes https://github.com/microsoft/playwright/issues/30628
This commit is contained in:
parent
27ce5c0226
commit
9ce41fa1b0
|
|
@ -86,6 +86,8 @@ window.playwrightMount = async (component, rootElement, hooksConfig) => {
|
|||
window.playwrightUnmount = async rootElement => {
|
||||
if (!__pwReactDOM.unmountComponentAtNode(rootElement))
|
||||
throw new Error('Component was not mounted');
|
||||
|
||||
__pwRootRegistry.delete(rootElement);
|
||||
};
|
||||
|
||||
window.playwrightUpdate = async (rootElement, component) => {
|
||||
|
|
|
|||
|
|
@ -23,3 +23,10 @@ test('unmount twice throws an error', async ({ mount }) => {
|
|||
await component.unmount();
|
||||
await expect(component.unmount()).rejects.toThrowError('Component was not mounted');
|
||||
});
|
||||
|
||||
test('mount then unmount then mount', async ({ mount }) => {
|
||||
let component = await mount(<Button title="Submit" />);
|
||||
await component.unmount();
|
||||
component = await mount(<Button title="Save" />);
|
||||
await expect(component).toContainText('Save');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -23,3 +23,10 @@ test('unmount twice throws an error', async ({ mount }) => {
|
|||
await component.unmount();
|
||||
await expect(component.unmount()).rejects.toThrowError('Component was not mounted');
|
||||
});
|
||||
|
||||
test('mount then unmount then mount', async ({ mount }) => {
|
||||
let component = await mount(<Button title="Submit" />);
|
||||
await component.unmount();
|
||||
component = await mount(<Button title="Save" />);
|
||||
await expect(component).toContainText('Save');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -23,3 +23,10 @@ test('unmount twice throws an error', async ({ mount }) => {
|
|||
await component.unmount();
|
||||
await expect(component.unmount()).rejects.toThrowError('Component was not mounted');
|
||||
});
|
||||
|
||||
test('mount then unmount then mount', async ({ mount }) => {
|
||||
let component = await mount(<Button title="Submit" />);
|
||||
await component.unmount();
|
||||
component = await mount(<Button title="Save" />);
|
||||
await expect(component).toContainText('Save');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -31,3 +31,18 @@ test('unmount twice throws an error', async ({ mount }) => {
|
|||
await component.unmount();
|
||||
await expect(component.unmount()).rejects.toThrowError('Component was not mounted');
|
||||
});
|
||||
|
||||
test('mount then unmount then mount', async ({ mount }) => {
|
||||
let component = await mount(Button, {
|
||||
props: {
|
||||
title: 'Submit',
|
||||
},
|
||||
});
|
||||
await component.unmount();
|
||||
component = await mount(Button, {
|
||||
props: {
|
||||
title: 'Save',
|
||||
},
|
||||
});
|
||||
await expect(component).toContainText('Save');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { test, expect } from '@playwright/experimental-ct-vue';
|
||||
import MultiRoot from '@/components/MultiRoot.vue';
|
||||
import Button from '@/components/Button.vue';
|
||||
|
||||
test('unmount a multi root component', async ({ mount, page }) => {
|
||||
const component = await mount(MultiRoot);
|
||||
|
|
@ -9,3 +10,19 @@ test('unmount a multi root component', async ({ mount, page }) => {
|
|||
await expect(page.locator('#root')).not.toContainText('root 1');
|
||||
await expect(page.locator('#root')).not.toContainText('root 2');
|
||||
});
|
||||
|
||||
test('mount then unmount then mount', async ({ mount }) => {
|
||||
let component = await mount(Button, {
|
||||
props: {
|
||||
title: 'Submit',
|
||||
},
|
||||
});
|
||||
await component.unmount();
|
||||
component = await mount(Button, {
|
||||
props: {
|
||||
title: 'Save',
|
||||
},
|
||||
});
|
||||
await expect(component).toContainText('Save');
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -31,3 +31,18 @@ test('unmount twice throws an error', async ({ mount }) => {
|
|||
await component.unmount();
|
||||
await expect(component.unmount()).rejects.toThrowError('Component was not mounted');
|
||||
});
|
||||
|
||||
test('mount then unmount then mount', async ({ mount }) => {
|
||||
let component = await mount(Button, {
|
||||
props: {
|
||||
title: 'Submit',
|
||||
},
|
||||
});
|
||||
await component.unmount();
|
||||
component = await mount(Button, {
|
||||
props: {
|
||||
title: 'Save',
|
||||
},
|
||||
});
|
||||
await expect(component).toContainText('Save');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,3 +16,10 @@ test('unmount twice throws an error', async ({ mount }) => {
|
|||
await component.unmount();
|
||||
await expect(component.unmount()).rejects.toThrowError('Component was not mounted');
|
||||
});
|
||||
|
||||
test('mount then unmount then mount', async ({ mount }) => {
|
||||
let component = await mount(<Button title="Submit" />);
|
||||
await component.unmount();
|
||||
component = await mount(<Button title="Save" />);
|
||||
await expect(component).toContainText('Save');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -21,3 +21,18 @@ test('unmount twice throws an error', async ({ mount }) => {
|
|||
await component.unmount();
|
||||
await expect(component.unmount()).rejects.toThrowError('Component was not mounted');
|
||||
});
|
||||
|
||||
test('mount then unmount then mount', async ({ mount }) => {
|
||||
let component = await mount(Button, {
|
||||
props: {
|
||||
title: 'Submit',
|
||||
},
|
||||
});
|
||||
await component.unmount();
|
||||
component = await mount(Button, {
|
||||
props: {
|
||||
title: 'Save',
|
||||
},
|
||||
});
|
||||
await expect(component).toContainText('Save');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,3 +13,10 @@ test('unmount twice throws an error', async ({ mount }) => {
|
|||
await component.unmount();
|
||||
await expect(component.unmount()).rejects.toThrowError('Component was not mounted');
|
||||
});
|
||||
|
||||
test('mount then unmount then mount', async ({ mount }) => {
|
||||
let component = await mount(<Button title="Submit" />);
|
||||
await component.unmount();
|
||||
component = await mount(<Button title="Save" />);
|
||||
await expect(component).toContainText('Save');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue