From 9a38aedf09f203a58008756e588324254abaef9a Mon Sep 17 00:00:00 2001 From: Playwright Service <89237858+playwrightmachine@users.noreply.github.com> Date: Sat, 24 Feb 2024 00:19:46 -0800 Subject: [PATCH 01/14] feat(firefox): roll to r1440 (#29643) Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- README.md | 4 ++-- packages/playwright-core/browsers.json | 8 ++++---- .../src/server/deviceDescriptorsSource.json | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 515062ddd0..14737d10d4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 🎭 Playwright -[![npm version](https://img.shields.io/npm/v/playwright.svg)](https://www.npmjs.com/package/playwright) [![Chromium version](https://img.shields.io/badge/chromium-123.0.6312.4-blue.svg?logo=google-chrome)](https://www.chromium.org/Home) [![Firefox version](https://img.shields.io/badge/firefox-122.0-blue.svg?logo=firefoxbrowser)](https://www.mozilla.org/en-US/firefox/new/) [![WebKit version](https://img.shields.io/badge/webkit-17.4-blue.svg?logo=safari)](https://webkit.org/) +[![npm version](https://img.shields.io/npm/v/playwright.svg)](https://www.npmjs.com/package/playwright) [![Chromium version](https://img.shields.io/badge/chromium-123.0.6312.4-blue.svg?logo=google-chrome)](https://www.chromium.org/Home) [![Firefox version](https://img.shields.io/badge/firefox-123.0-blue.svg?logo=firefoxbrowser)](https://www.mozilla.org/en-US/firefox/new/) [![WebKit version](https://img.shields.io/badge/webkit-17.4-blue.svg?logo=safari)](https://webkit.org/) ## [Documentation](https://playwright.dev) | [API reference](https://playwright.dev/docs/api/class-playwright) @@ -10,7 +10,7 @@ Playwright is a framework for Web Testing and Automation. It allows testing [Chr | :--- | :---: | :---: | :---: | | Chromium 123.0.6312.4 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | WebKit 17.4 | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| Firefox 122.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Firefox 123.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | Headless execution is supported for all browsers on all platforms. Check out [system requirements](https://playwright.dev/docs/intro#system-requirements) for details. diff --git a/packages/playwright-core/browsers.json b/packages/playwright-core/browsers.json index 8a0af13f94..bf862ae74c 100644 --- a/packages/playwright-core/browsers.json +++ b/packages/playwright-core/browsers.json @@ -21,15 +21,15 @@ }, { "name": "firefox", - "revision": "1439", + "revision": "1440", "installByDefault": true, - "browserVersion": "122.0" + "browserVersion": "123.0" }, { "name": "firefox-asan", - "revision": "1439", + "revision": "1440", "installByDefault": false, - "browserVersion": "122.0" + "browserVersion": "123.0" }, { "name": "firefox-beta", diff --git a/packages/playwright-core/src/server/deviceDescriptorsSource.json b/packages/playwright-core/src/server/deviceDescriptorsSource.json index f44a165987..6191ef5d2e 100644 --- a/packages/playwright-core/src/server/deviceDescriptorsSource.json +++ b/packages/playwright-core/src/server/deviceDescriptorsSource.json @@ -1472,7 +1472,7 @@ "defaultBrowserType": "chromium" }, "Desktop Firefox HiDPI": { - "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0", + "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0", "screen": { "width": 1792, "height": 1120 @@ -1532,7 +1532,7 @@ "defaultBrowserType": "chromium" }, "Desktop Firefox": { - "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0", + "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0", "screen": { "width": 1920, "height": 1080 From c5af51c59dcd21c09ec2d6d3eb7a5d35faef0c28 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Mon, 26 Feb 2024 15:19:27 +0100 Subject: [PATCH 02/14] docs(intro): fix grammar mistake in docs (#29659) Signed-off-by: Simon Knott --- docs/src/ci-intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/ci-intro.md b/docs/src/ci-intro.md index da4f31522f..f5393cfc9e 100644 --- a/docs/src/ci-intro.md +++ b/docs/src/ci-intro.md @@ -8,7 +8,7 @@ title: "CI GitHub Actions" Playwright tests can be run on any CI provider. In this section we will cover running tests on GitHub using GitHub actions. If you would like to see how to configure other CI providers check out our detailed [doc on Continuous Integration](./ci.md). -When [installing Playwright](./intro.md) using the [VS Code extension](./getting-started-vscode.md) or with `npm init playwright@latest` you are given the option to add a [GitHub Actions](https://docs.github.com/en/actions). This creates a `playwright.yml` file inside a `.github/workflows` folder containing everything you need so that your tests run on each push and pull request into the main/master branch. +When [installing Playwright](./intro.md) using the [VS Code extension](./getting-started-vscode.md) or with `npm init playwright@latest` you are given the option to add a [GitHub Actions](https://docs.github.com/en/actions) workflow. This creates a `playwright.yml` file inside a `.github/workflows` folder containing everything you need so that your tests run on each push and pull request into the main/master branch. #### You will learn * langs: js From 7eb910a652f0e950507502981f4ec349ee8ef0b3 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Mon, 26 Feb 2024 09:39:21 -0800 Subject: [PATCH 03/14] chore: enable eslint for js (#29639) --- .eslintignore | 3 ++- .eslintrc.js | 1 + package.json | 2 +- packages/playwright-ct-react/registerSource.mjs | 10 ++++------ packages/playwright-ct-react17/registerSource.mjs | 11 ++++------- packages/playwright-ct-svelte/registerSource.mjs | 4 ++-- packages/playwright/.eslintrc.js | 9 --------- tsconfig.json | 6 ------ 8 files changed, 14 insertions(+), 32 deletions(-) diff --git a/.eslintignore b/.eslintignore index f7365e0082..152cbbe228 100644 --- a/.eslintignore +++ b/.eslintignore @@ -19,4 +19,5 @@ tests/components/ tests/installation/fixture-scripts/ examples/ DEPS -.cache/ \ No newline at end of file +.cache/ +utils/ diff --git a/.eslintrc.js b/.eslintrc.js index 7bc5a0868f..ab0ffeecee 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -4,6 +4,7 @@ module.exports = { parserOptions: { ecmaVersion: 9, sourceType: "module", + project: "./tsconfig.json", }, extends: [ "plugin:react-hooks/recommended" diff --git a/package.json b/package.json index 89550ec4e4..e62801990d 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "ttest": "node ./tests/playwright-test/stable-test-runner/node_modules/@playwright/test/cli test --config=tests/playwright-test/playwright.config.ts", "ct": "playwright test tests/components/test-all.spec.js --reporter=list", "test": "playwright test --config=tests/library/playwright.config.ts", - "eslint": "eslint --cache --report-unused-disable-directives --ext ts,tsx .", + "eslint": "eslint --cache --report-unused-disable-directives --ext ts,tsx,js,jsx,mjs .", "tsc": "tsc -p .", "build-installer": "babel -s --extensions \".ts\" --out-dir packages/playwright-core/lib/utils/ packages/playwright-core/src/utils", "doc": "node utils/doclint/cli.js", diff --git a/packages/playwright-ct-react/registerSource.mjs b/packages/playwright-ct-react/registerSource.mjs index 10dad4c0db..9ad2612bc4 100644 --- a/packages/playwright-ct-react/registerSource.mjs +++ b/packages/playwright-ct-react/registerSource.mjs @@ -40,13 +40,11 @@ function __pwRender(value) { if (isJsxComponent(v)) { const component = v; const props = component.props ? __pwRender(component.props) : {}; - const {children, ...propsWithoutChildren} = props; - /** @type {[any, any, any?]} */ - const createElementArguments = [component.type, propsWithoutChildren]; - if(children){ + const { children, ...propsWithoutChildren } = props; + const createElementArguments = [propsWithoutChildren]; + if (children) createElementArguments.push(children); - } - return { result: __pwReact.createElement(...createElementArguments) }; + return { result: __pwReact.createElement(component.type, ...createElementArguments) }; } }); } diff --git a/packages/playwright-ct-react17/registerSource.mjs b/packages/playwright-ct-react17/registerSource.mjs index 8dfc1d24e9..158984f3ac 100644 --- a/packages/playwright-ct-react17/registerSource.mjs +++ b/packages/playwright-ct-react17/registerSource.mjs @@ -40,14 +40,11 @@ function __pwRender(value) { if (isJsxComponent(v)) { const component = v; const props = component.props ? __pwRender(component.props) : {}; - - const {children, ...propsWithoutChildren} = props; - /** @type {[any, any, any?]} */ - const createElementArguments = [component.type, propsWithoutChildren]; - if(children){ + const { children, ...propsWithoutChildren } = props; + const createElementArguments = [propsWithoutChildren]; + if (children) createElementArguments.push(children); - } - return { result: __pwReact.createElement(...createElementArguments) }; + return { result: __pwReact.createElement(component.type, ...createElementArguments) }; } }); } diff --git a/packages/playwright-ct-svelte/registerSource.mjs b/packages/playwright-ct-svelte/registerSource.mjs index 4552a4ba0a..b11f8e0369 100644 --- a/packages/playwright-ct-svelte/registerSource.mjs +++ b/packages/playwright-ct-svelte/registerSource.mjs @@ -42,8 +42,8 @@ function __pwCreateSlots(slots) { for (const slotName in slots) { const template = document - .createRange() - .createContextualFragment(slots[slotName]); + .createRange() + .createContextualFragment(slots[slotName]); svelteSlots[slotName] = [createSlotFn(template)]; } diff --git a/packages/playwright/.eslintrc.js b/packages/playwright/.eslintrc.js index 67c9b6313d..71985134bd 100644 --- a/packages/playwright/.eslintrc.js +++ b/packages/playwright/.eslintrc.js @@ -1,14 +1,5 @@ -const path = require('path'); - module.exports = { extends: '../.eslintrc.js', - parser: "@typescript-eslint/parser", - plugins: ["@typescript-eslint", "notice"], - parserOptions: { - ecmaVersion: 9, - sourceType: "module", - project: path.join(__dirname, '..', '..', 'tsconfig.json'), - }, rules: { '@typescript-eslint/no-floating-promises': 'error', }, diff --git a/tsconfig.json b/tsconfig.json index 733973760a..56d9996996 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -35,11 +35,5 @@ "include": ["packages"], "exclude": [ "packages/*/lib", - "packages/playwright-ct-react", - "packages/playwright-ct-react17", - "packages/playwright-ct-solid", - "packages/playwright-ct-svelte", - "packages/playwright-ct-vue", - "packages/playwright-ct-vue2" ], } From 7e502e91b2cf1148f186502649424074a8b35ccc Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 26 Feb 2024 20:15:08 +0100 Subject: [PATCH 04/14] fix(ct): solid pass children when they are defined (#29648) --- .../playwright-ct-solid/registerSource.mjs | 48 +++++-------------- .../src/components/CheckChildrenProp.tsx | 17 ++----- .../ct-react-vite/tests/children.spec.tsx | 2 +- .../src/components/CheckChildrenProp.tsx | 17 ++----- .../ct-react17/tests/children.spec.tsx | 2 +- .../src/components/CheckChildrenProp.tsx | 7 +++ .../ct-solid/tests/children.spec.tsx | 6 +++ 7 files changed, 35 insertions(+), 64 deletions(-) create mode 100644 tests/components/ct-solid/src/components/CheckChildrenProp.tsx diff --git a/packages/playwright-ct-solid/registerSource.mjs b/packages/playwright-ct-solid/registerSource.mjs index a76792c513..c89caa7bd8 100644 --- a/packages/playwright-ct-solid/registerSource.mjs +++ b/packages/playwright-ct-solid/registerSource.mjs @@ -19,9 +19,7 @@ import { render as __pwSolidRender, createComponent as __pwSolidCreateComponent } from 'solid-js/web'; import __pwH from 'solid-js/h'; - /** @typedef {import('../playwright-ct-core/types/component').JsxComponent} JsxComponent */ -/** @typedef {() => import('solid-js').JSX.Element} FrameworkComponent */ /** * @param {any} component @@ -32,42 +30,20 @@ function isJsxComponent(component) { } /** - * @param {any} child + * @param {any} value */ -function __pwCreateChild(child) { - if (Array.isArray(child)) - return child.map(grandChild => __pwCreateChild(grandChild)); - if (isJsxComponent(child)) - return __pwCreateComponent(child); - return child; -} - -/** - * @param {JsxComponent} component - * @returns {any[] | undefined} - */ -function __pwJsxChildArray(component) { - if (!component.props.children) - return; - if (Array.isArray(component.props.children)) - return component.props.children; - return [component.props.children]; -} - -/** - * @param {JsxComponent} component - */ -function __pwCreateComponent(component) { - const children = __pwJsxChildArray(component)?.map(child => __pwCreateChild(child)).filter(child => { - if (typeof child === 'string') - return !!child.trim(); - return true; +function __pwCreateComponent(value) { + return window.__pwTransformObject(value, v => { + if (isJsxComponent(v)) { + const component = v; + const props = component.props ? __pwCreateComponent(component.props) : {}; + if (typeof component.type === 'string') { + const { children, ...propsWithoutChildren } = props; + return { result: __pwH(component.type, propsWithoutChildren, children) }; + } + return { result: __pwSolidCreateComponent(component.type, props) }; + } }); - - if (typeof component.type === 'string') - return __pwH(component.type, component.props, children); - - return __pwSolidCreateComponent(component.type, { ...component.props, children }); } const __pwUnmountKey = Symbol('unmountKey'); diff --git a/tests/components/ct-react-vite/src/components/CheckChildrenProp.tsx b/tests/components/ct-react-vite/src/components/CheckChildrenProp.tsx index 42b3a361e8..3e8f405a5b 100644 --- a/tests/components/ct-react-vite/src/components/CheckChildrenProp.tsx +++ b/tests/components/ct-react-vite/src/components/CheckChildrenProp.tsx @@ -1,16 +1,7 @@ -type DefaultChildrenProps = { - children?: any; -} +import type { PropsWithChildren } from 'react'; + +type DefaultChildrenProps = PropsWithChildren<{}>; export default function CheckChildrenProp(props: DefaultChildrenProps) { - const content = 'children' in props ? props.children : 'No Children'; - return
-

Welcome!

-
- {content} -
-
- Thanks for visiting. -
-
+ return <>{'children' in props ? props.children : 'No Children'} } diff --git a/tests/components/ct-react-vite/tests/children.spec.tsx b/tests/components/ct-react-vite/tests/children.spec.tsx index d671b14e64..03da7d2c55 100644 --- a/tests/components/ct-react-vite/tests/children.spec.tsx +++ b/tests/components/ct-react-vite/tests/children.spec.tsx @@ -60,7 +60,7 @@ test('render number as child', async ({ mount }) => { await expect(component).toContainText('1337'); }); -test('render without children', async ({ mount }) => { +test('absence of children when children prop is not provided', async ({ mount }) => { const component = await mount(); await expect(component).toContainText('No Children'); }); diff --git a/tests/components/ct-react17/src/components/CheckChildrenProp.tsx b/tests/components/ct-react17/src/components/CheckChildrenProp.tsx index 42b3a361e8..3e8f405a5b 100644 --- a/tests/components/ct-react17/src/components/CheckChildrenProp.tsx +++ b/tests/components/ct-react17/src/components/CheckChildrenProp.tsx @@ -1,16 +1,7 @@ -type DefaultChildrenProps = { - children?: any; -} +import type { PropsWithChildren } from 'react'; + +type DefaultChildrenProps = PropsWithChildren<{}>; export default function CheckChildrenProp(props: DefaultChildrenProps) { - const content = 'children' in props ? props.children : 'No Children'; - return
-

Welcome!

-
- {content} -
-
- Thanks for visiting. -
-
+ return <>{'children' in props ? props.children : 'No Children'} } diff --git a/tests/components/ct-react17/tests/children.spec.tsx b/tests/components/ct-react17/tests/children.spec.tsx index 32ddabe7ac..8f55237723 100644 --- a/tests/components/ct-react17/tests/children.spec.tsx +++ b/tests/components/ct-react17/tests/children.spec.tsx @@ -60,7 +60,7 @@ test('render number as child', async ({ mount }) => { await expect(component).toContainText('1337'); }); -test('render without children', async ({ mount }) => { +test('absence of children when children prop is not provided', async ({ mount }) => { const component = await mount(); await expect(component).toContainText('No Children'); }); diff --git a/tests/components/ct-solid/src/components/CheckChildrenProp.tsx b/tests/components/ct-solid/src/components/CheckChildrenProp.tsx new file mode 100644 index 0000000000..113a44ced9 --- /dev/null +++ b/tests/components/ct-solid/src/components/CheckChildrenProp.tsx @@ -0,0 +1,7 @@ +import { type ParentProps } from 'solid-js'; + +type DefaultChildrenProps = ParentProps<{}>; + +export default function CheckChildrenProp(props: DefaultChildrenProps) { + return <>{'children' in props ? props.children : 'No Children'} +} diff --git a/tests/components/ct-solid/tests/children.spec.tsx b/tests/components/ct-solid/tests/children.spec.tsx index 75515f754e..ebf80fe803 100644 --- a/tests/components/ct-solid/tests/children.spec.tsx +++ b/tests/components/ct-solid/tests/children.spec.tsx @@ -2,6 +2,7 @@ import { test, expect } from '@playwright/experimental-ct-solid'; import Button from '@/components/Button'; import DefaultChildren from '@/components/DefaultChildren'; import MultipleChildren from '@/components/MultipleChildren'; +import CheckChildrenProp from '@/components/CheckChildrenProp' test('render a default child', async ({ mount }) => { const component = await mount( @@ -58,3 +59,8 @@ test('render number as child', async ({ mount }) => { const component = await mount({1337}); await expect(component).toContainText('1337'); }); + +test('absence of children when children prop is not provided', async ({ mount }) => { + const component = await mount(); + await expect(component).toContainText('No Children'); +}); From 303d7fdac9971312d7314a151c7e33329b06b660 Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 26 Feb 2024 20:15:55 +0100 Subject: [PATCH 05/14] chore(ct): vue resolve internal type errors (#29649) --- packages/playwright-ct-vue/registerSource.mjs | 49 ++++++++++++------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/packages/playwright-ct-vue/registerSource.mjs b/packages/playwright-ct-vue/registerSource.mjs index 5256a241a4..198372cc38 100644 --- a/packages/playwright-ct-vue/registerSource.mjs +++ b/packages/playwright-ct-vue/registerSource.mjs @@ -88,6 +88,9 @@ function __pwCreateSlot(html) { }; } +/** + * @param {string | string[]} slot + */ function __pwSlotToFunction(slot) { if (typeof slot === 'string') return __pwCreateSlot(slot)(); @@ -175,7 +178,11 @@ function __pwCreateComponent(component) { return { Component: component.type, props, slots: lastArg, listeners }; } +/** + * @param {any} slots + */ function __pwWrapFunctions(slots) { + /** @type {import('vue').ComponentInternalInstance['slots']} */ const slotsWithRenderFunctions = {}; if (!Array.isArray(slots)) { for (const [key, value] of Object.entries(slots || {})) @@ -198,25 +205,27 @@ function __pwCreateWrapper(component) { return wrapper; } -/** - * @returns {any} - */ -function __pwCreateDevTools() { - return { +function __pwSetDevTools() { + __pwSetDevtoolsHook({ emit(eventType, ...payload) { - if (eventType === 'component:emit') { - const [, componentVM, event, eventArgs] = payload; - for (const [wrapper, listeners] of __pwAllListeners) { - if (wrapper.component !== componentVM) - continue; - const listener = listeners[event]; - if (!listener) - return; - listener(...eventArgs); - } + if (eventType !== 'component:emit') + return; + + const [, componentVM, event, eventArgs] = payload; + for (const [wrapper, listeners] of __pwAllListeners) { + if (wrapper.component !== componentVM) + continue; + const listener = listeners[event]; + if (!listener) + return; + listener(...eventArgs); } - } - }; + }, + on() {}, + off() {}, + once() {}, + appRecords: [] + }, {}); } const __pwAppKey = Symbol('appKey'); @@ -230,7 +239,7 @@ window.playwrightMount = async (component, rootElement, hooksConfig) => { return wrapper; } }); - __pwSetDevtoolsHook(__pwCreateDevTools(), {}); + __pwSetDevTools(); for (const hook of window.__pw_hooks_before_mount || []) await hook({ app, hooksConfig }); @@ -242,13 +251,15 @@ window.playwrightMount = async (component, rootElement, hooksConfig) => { }; window.playwrightUnmount = async rootElement => { - const app = /** @type {import('vue').App} */ (rootElement[__pwAppKey]); + /** @type {import('vue').App | undefined} */ + const app = rootElement[__pwAppKey]; if (!app) throw new Error('Component was not mounted'); app.unmount(); }; window.playwrightUpdate = async (rootElement, component) => { + /** @type {import('vue').VNode | undefined} */ const wrapper = rootElement[__pwWrapperKey]; if (!wrapper) throw new Error('Component was not mounted'); From 015a1bcc1c0bdcc17409266ccc448b2def320914 Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 26 Feb 2024 20:16:27 +0100 Subject: [PATCH 06/14] feat(ct): double unmounting component throws error (#29650) --- packages/playwright-ct-solid/registerSource.mjs | 1 + packages/playwright-ct-svelte/registerSource.mjs | 1 + packages/playwright-ct-vue/registerSource.mjs | 1 + packages/playwright-ct-vue2/registerSource.mjs | 1 + tests/components/ct-react-vite/tests/unmount.spec.tsx | 6 ++++++ tests/components/ct-react17/tests/unmount.spec.tsx | 6 ++++++ tests/components/ct-solid/tests/unmount.spec.tsx | 6 ++++++ tests/components/ct-svelte-vite/tests/unmount.spec.ts | 10 ++++++++++ tests/components/ct-svelte/tests/unmount.spec.ts | 10 ++++++++++ .../ct-vue-cli/tests/unmount/unmount.spec.ts | 11 +++++++++++ .../ct-vue-cli/tests/unmount/unmount.spec.tsx | 6 ++++++ .../ct-vue-vite/tests/unmount/unmount.spec.ts | 10 ++++++++++ .../ct-vue-vite/tests/unmount/unmount.spec.tsx | 7 +++++++ .../ct-vue2-cli/tests/unmount/unmount.spec.ts | 10 ++++++++++ .../ct-vue2-cli/tests/unmount/unmount.spec.tsx | 6 ++++++ 15 files changed, 92 insertions(+) diff --git a/packages/playwright-ct-solid/registerSource.mjs b/packages/playwright-ct-solid/registerSource.mjs index c89caa7bd8..d0077dd494 100644 --- a/packages/playwright-ct-solid/registerSource.mjs +++ b/packages/playwright-ct-solid/registerSource.mjs @@ -72,6 +72,7 @@ window.playwrightUnmount = async rootElement => { throw new Error('Component was not mounted'); unmount(); + delete rootElement[__pwUnmountKey]; }; window.playwrightUpdate = async (rootElement, component) => { diff --git a/packages/playwright-ct-svelte/registerSource.mjs b/packages/playwright-ct-svelte/registerSource.mjs index b11f8e0369..642548f18a 100644 --- a/packages/playwright-ct-svelte/registerSource.mjs +++ b/packages/playwright-ct-svelte/registerSource.mjs @@ -108,6 +108,7 @@ window.playwrightUnmount = async rootElement => { if (!svelteComponent) throw new Error('Component was not mounted'); svelteComponent.$destroy(); + delete rootElement[__pwSvelteComponentKey]; }; window.playwrightUpdate = async (rootElement, component) => { diff --git a/packages/playwright-ct-vue/registerSource.mjs b/packages/playwright-ct-vue/registerSource.mjs index 198372cc38..07ce5298f4 100644 --- a/packages/playwright-ct-vue/registerSource.mjs +++ b/packages/playwright-ct-vue/registerSource.mjs @@ -256,6 +256,7 @@ window.playwrightUnmount = async rootElement => { if (!app) throw new Error('Component was not mounted'); app.unmount(); + delete rootElement[__pwAppKey]; }; window.playwrightUpdate = async (rootElement, component) => { diff --git a/packages/playwright-ct-vue2/registerSource.mjs b/packages/playwright-ct-vue2/registerSource.mjs index b0a7ae71dc..19b4d41c08 100644 --- a/packages/playwright-ct-vue2/registerSource.mjs +++ b/packages/playwright-ct-vue2/registerSource.mjs @@ -182,6 +182,7 @@ window.playwrightUnmount = async rootElement => { throw new Error('Component was not mounted'); component.$destroy(); component.$el.remove(); + delete rootElement[instanceKey]; }; window.playwrightUpdate = async (element, options) => { diff --git a/tests/components/ct-react-vite/tests/unmount.spec.tsx b/tests/components/ct-react-vite/tests/unmount.spec.tsx index acc11c4fdb..20374d8b8e 100644 --- a/tests/components/ct-react-vite/tests/unmount.spec.tsx +++ b/tests/components/ct-react-vite/tests/unmount.spec.tsx @@ -17,3 +17,9 @@ 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('unmount twice throws an error', async ({ mount }) => { + const component = await mount(`); + await page.locator('button').evaluate(button => { + window['clicks'] = 0; + button.addEventListener('click', () => ++window['clicks'], false); + }); + return page; + }; + + const clickInPage = async (page, count) => { + for (let i = 0; i < count; ++i) + await page.locator('button').click(); + }; + + const getClicks = async page => page.evaluate(() => window['clicks']); + + const page1 = await createPage(); + const page2 = await createPage(); + + const CLICK_COUNT = 20; + await Promise.all([ + clickInPage(page1, CLICK_COUNT), + clickInPage(page2, CLICK_COUNT), + ]); + expect(await getClicks(page1)).toBe(CLICK_COUNT); + expect(await getClicks(page2)).toBe(CLICK_COUNT); +}); + it('window.open should use parent tab context', async function({ browser, server }) { const context = await browser.newContext(); const page = await context.newPage(); From 1c8e8bea7e6ae32997434cb963e320fe8d86d3dc Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Mon, 26 Feb 2024 17:39:25 -0800 Subject: [PATCH 14/14] chore: roll stable test runner to 1.42.0-beta-1708994059000 (#29672) --- .../stable-test-runner/package-lock.json | 46 +++++++++---------- .../stable-test-runner/package.json | 2 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/playwright-test/stable-test-runner/package-lock.json b/tests/playwright-test/stable-test-runner/package-lock.json index 2594cfcffd..f1937fd021 100644 --- a/tests/playwright-test/stable-test-runner/package-lock.json +++ b/tests/playwright-test/stable-test-runner/package-lock.json @@ -5,15 +5,15 @@ "packages": { "": { "dependencies": { - "@playwright/test": "1.41.0-beta-1705101589000" + "@playwright/test": "1.42.0-beta-1708994059000" } }, "node_modules/@playwright/test": { - "version": "1.41.0-beta-1705101589000", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.41.0-beta-1705101589000.tgz", - "integrity": "sha512-tpaEm+ih0PhJdk6yrRtk40I9ahErhGYZT2lR65ZZ6Il7tMnUgzxF5OOw3XLGJ59T29nMyI1+hKGqQnf8nUKkQw==", + "version": "1.42.0-beta-1708994059000", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.42.0-beta-1708994059000.tgz", + "integrity": "sha512-dfCvXGLsNRTOIRXyU7Cx8EdmMJxpHP3Dg2yD+ACM4GhpcSTJqLD0kwggZY2ziDJNG1sNJ1zN/aDgRqv4G3NREQ==", "dependencies": { - "playwright": "1.41.0-beta-1705101589000" + "playwright": "1.42.0-beta-1708994059000" }, "bin": { "playwright": "cli.js" @@ -36,11 +36,11 @@ } }, "node_modules/playwright": { - "version": "1.41.0-beta-1705101589000", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.41.0-beta-1705101589000.tgz", - "integrity": "sha512-3mMpZXmkw+fGIb+wBpvDZ4OEm7L1QYptgJgTdP8/OEitYjV5Q05MRZWbgelF/9ameoRpMz7rbkZTWUh/1UtrIw==", + "version": "1.42.0-beta-1708994059000", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.42.0-beta-1708994059000.tgz", + "integrity": "sha512-+lMRsLfaLx/Okb3qH9r8eUfDBQ7Vq0eTLehxG9plLorSBQnU1b9kQnmchV3jl2hjm9Oh7vNf/No+vgsRBuj7/Q==", "dependencies": { - "playwright-core": "1.41.0-beta-1705101589000" + "playwright-core": "1.42.0-beta-1708994059000" }, "bin": { "playwright": "cli.js" @@ -53,9 +53,9 @@ } }, "node_modules/playwright-core": { - "version": "1.41.0-beta-1705101589000", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.41.0-beta-1705101589000.tgz", - "integrity": "sha512-w3aDw2Kp/ZwAUSqLZdmd+mq6khl3ufb2csM51b85r9t8S4m2JYoz1WHFNGNHqFWHBXSrjSBXzFLNgKUmwizRuA==", + "version": "1.42.0-beta-1708994059000", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.42.0-beta-1708994059000.tgz", + "integrity": "sha512-mdXcpctceoX0aHouE+ZglhB7JnLO1NtQgTF8MBgL/Wsa3r6jRI8DESCVTmbcazr8QGs9MT9wTKSx8Y70zYkaxw==", "bin": { "playwright-core": "cli.js" }, @@ -66,11 +66,11 @@ }, "dependencies": { "@playwright/test": { - "version": "1.41.0-beta-1705101589000", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.41.0-beta-1705101589000.tgz", - "integrity": "sha512-tpaEm+ih0PhJdk6yrRtk40I9ahErhGYZT2lR65ZZ6Il7tMnUgzxF5OOw3XLGJ59T29nMyI1+hKGqQnf8nUKkQw==", + "version": "1.42.0-beta-1708994059000", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.42.0-beta-1708994059000.tgz", + "integrity": "sha512-dfCvXGLsNRTOIRXyU7Cx8EdmMJxpHP3Dg2yD+ACM4GhpcSTJqLD0kwggZY2ziDJNG1sNJ1zN/aDgRqv4G3NREQ==", "requires": { - "playwright": "1.41.0-beta-1705101589000" + "playwright": "1.42.0-beta-1708994059000" } }, "fsevents": { @@ -80,18 +80,18 @@ "optional": true }, "playwright": { - "version": "1.41.0-beta-1705101589000", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.41.0-beta-1705101589000.tgz", - "integrity": "sha512-3mMpZXmkw+fGIb+wBpvDZ4OEm7L1QYptgJgTdP8/OEitYjV5Q05MRZWbgelF/9ameoRpMz7rbkZTWUh/1UtrIw==", + "version": "1.42.0-beta-1708994059000", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.42.0-beta-1708994059000.tgz", + "integrity": "sha512-+lMRsLfaLx/Okb3qH9r8eUfDBQ7Vq0eTLehxG9plLorSBQnU1b9kQnmchV3jl2hjm9Oh7vNf/No+vgsRBuj7/Q==", "requires": { "fsevents": "2.3.2", - "playwright-core": "1.41.0-beta-1705101589000" + "playwright-core": "1.42.0-beta-1708994059000" } }, "playwright-core": { - "version": "1.41.0-beta-1705101589000", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.41.0-beta-1705101589000.tgz", - "integrity": "sha512-w3aDw2Kp/ZwAUSqLZdmd+mq6khl3ufb2csM51b85r9t8S4m2JYoz1WHFNGNHqFWHBXSrjSBXzFLNgKUmwizRuA==" + "version": "1.42.0-beta-1708994059000", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.42.0-beta-1708994059000.tgz", + "integrity": "sha512-mdXcpctceoX0aHouE+ZglhB7JnLO1NtQgTF8MBgL/Wsa3r6jRI8DESCVTmbcazr8QGs9MT9wTKSx8Y70zYkaxw==" } } } diff --git a/tests/playwright-test/stable-test-runner/package.json b/tests/playwright-test/stable-test-runner/package.json index 17ce2477d8..363a340c04 100644 --- a/tests/playwright-test/stable-test-runner/package.json +++ b/tests/playwright-test/stable-test-runner/package.json @@ -1,6 +1,6 @@ { "private": true, "dependencies": { - "@playwright/test": "1.41.0-beta-1705101589000" + "@playwright/test": "1.42.0-beta-1708994059000" } }