From 7e7ea722d72bfa563ffe1ae6873b7ebb28d76d7f Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 10 Aug 2024 10:07:09 +0000 Subject: [PATCH] feat(roll): roll to ToT Playwright (10-08-24) --- dotnet/docs/api-testing.mdx | 2 -- dotnet/docs/screenshots.mdx | 2 -- java/docs/accessibility-testing.mdx | 2 -- java/docs/api-testing.mdx | 2 -- java/docs/ci-intro.mdx | 2 +- java/docs/ci.mdx | 10 +++++----- java/docs/docker.mdx | 14 +++++++------- java/docs/intro.mdx | 2 +- java/docs/junit.mdx | 2 -- java/docs/screenshots.mdx | 2 -- java/docs/test-runners.mdx | 6 ++---- nodejs/docs/api-testing.mdx | 2 -- nodejs/docs/screenshots.mdx | 2 -- python/docs/api-testing.mdx | 2 -- python/docs/screenshots.mdx | 2 -- src/markdown.js | 20 +++++++++++++++++++- 16 files changed, 35 insertions(+), 39 deletions(-) diff --git a/dotnet/docs/api-testing.mdx b/dotnet/docs/api-testing.mdx index 65a0e4b90d..972c711b5c 100644 --- a/dotnet/docs/api-testing.mdx +++ b/dotnet/docs/api-testing.mdx @@ -19,8 +19,6 @@ All of that could be achieved via [APIRequestContext] methods. The following examples rely on the [`Microsoft.Playwright.MSTest`](./test-runners.mdx) package which creates a Playwright and Page instance for each test. - - ## Writing API Test [APIRequestContext] can send all kinds of HTTP(S) requests over network. diff --git a/dotnet/docs/screenshots.mdx b/dotnet/docs/screenshots.mdx index db9c26e9d5..fc3d18b756 100644 --- a/dotnet/docs/screenshots.mdx +++ b/dotnet/docs/screenshots.mdx @@ -19,8 +19,6 @@ await Page.ScreenshotAsync(new() [Screenshots API](./api/class-page#page-screenshot) accepts many parameters for image format, clip area, quality, etc. Make sure to check them out. - - ## Full page screenshots Full page screenshot is a screenshot of a full scrollable page, as if you had a very tall screen and the page could fit it entirely. diff --git a/java/docs/accessibility-testing.mdx b/java/docs/accessibility-testing.mdx index 0814cc1c81..5f71f759b2 100644 --- a/java/docs/accessibility-testing.mdx +++ b/java/docs/accessibility-testing.mdx @@ -17,8 +17,6 @@ A few examples of problems this can catch include: The following examples rely on the [`com.deque.html.axe-core/playwright`](https://mvnrepository.com/artifact/com.deque.html.axe-core/playwright) Maven package which adds support for running the [axe accessibility testing engine](https://www.deque.com/axe/) as part of your Playwright tests. - - ## Disclaimer Automated accessibility tests can detect some common accessibility problems such as missing or invalid properties. But many accessibility problems can only be discovered through manual testing. We recommend using a combination of automated testing, manual accessibility assessments, and inclusive user testing. diff --git a/java/docs/api-testing.mdx b/java/docs/api-testing.mdx index 2626b214e7..c14b08e253 100644 --- a/java/docs/api-testing.mdx +++ b/java/docs/api-testing.mdx @@ -17,8 +17,6 @@ Sometimes you may want to send requests to the server directly from Java without All of that could be achieved via [APIRequestContext] methods. - - ## Writing API Test [APIRequestContext] can send all kinds of HTTP(S) requests over network. diff --git a/java/docs/ci-intro.mdx b/java/docs/ci-intro.mdx index 869cf3ae2f..82492e396e 100644 --- a/java/docs/ci-intro.mdx +++ b/java/docs/ci-intro.mdx @@ -64,7 +64,7 @@ jobs: name: 'Playwright Tests' runs-on: ubuntu-latest container: - image: mcr.microsoft.com/playwright/java:v1.45.1-jammy + image: mcr.microsoft.com/playwright/java:v1.46.0-jammy steps: - uses: actions/checkout@v4 - uses: actions/setup-java@v3 diff --git a/java/docs/ci.mdx b/java/docs/ci.mdx index f6ae268fa9..6ce784001b 100644 --- a/java/docs/ci.mdx +++ b/java/docs/ci.mdx @@ -78,7 +78,7 @@ trigger: pool: vmImage: ubuntu-latest -container: mcr.microsoft.com/playwright/java:v1.45.1-jammy +container: mcr.microsoft.com/playwright/java:v1.46.0-jammy steps: - task: JavaToolInstaller@0 @@ -101,7 +101,7 @@ Running Playwright on CircleCI is very similar to running on GitHub Actions. In executors: pw-jammy-development: docker: - - image: mcr.microsoft.com/playwright/java:v1.45.1-jammy + - image: mcr.microsoft.com/playwright/java:v1.46.0-jammy ``` Note: When using the docker agent definition, you are specifying the resource class of where playwright runs to the 'medium' tier [here](https://circleci.com/docs/configuration-reference?#docker-execution-environment). The default behavior of Playwright is to set the number of workers to the detected core count (2 in the case of the medium tier). Overriding the number of workers to greater than this number will cause unnecessary timeouts and failures. @@ -112,7 +112,7 @@ Jenkins supports Docker agents for pipelines. Use the [Playwright Docker image]( ```groovy pipeline { - agent { docker { image 'mcr.microsoft.com/playwright/java:v1.45.1-jammy' } } + agent { docker { image 'mcr.microsoft.com/playwright/java:v1.46.0-jammy' } } stages { stage('e2e-tests') { steps { @@ -129,7 +129,7 @@ pipeline { Bitbucket Pipelines can use public [Docker images as build environments](https://confluence.atlassian.com/bitbucket/use-docker-images-as-build-environments-792298897.html). To run Playwright tests on Bitbucket, use our public Docker image ([see Dockerfile](./docker.mdx)). ```yml -image: mcr.microsoft.com/playwright/java:v1.45.1-jammy +image: mcr.microsoft.com/playwright/java:v1.46.0-jammy ``` ### GitLab CI @@ -142,7 +142,7 @@ stages: tests: stage: test - image: mcr.microsoft.com/playwright/java:v1.45.1-jammy + image: mcr.microsoft.com/playwright/java:v1.46.0-jammy script: ... ``` diff --git a/java/docs/docker.mdx b/java/docs/docker.mdx index 4554a0ecf9..3100994d46 100644 --- a/java/docs/docker.mdx +++ b/java/docs/docker.mdx @@ -21,7 +21,7 @@ This Docker image is intended to be used for testing and development purposes on ### Pull the image ```bash -docker pull mcr.microsoft.com/playwright/java:v1.45.1-jammy +docker pull mcr.microsoft.com/playwright/java:v1.46.0-jammy ``` ### Run the image @@ -33,7 +33,7 @@ By default, the Docker image will use the `root` user to run the browsers. This On trusted websites, you can avoid creating a separate user and use root for it since you trust the code which will run on the browsers. ```bash -docker run -it --rm --ipc=host mcr.microsoft.com/playwright/java:v1.45.1-jammy /bin/bash +docker run -it --rm --ipc=host mcr.microsoft.com/playwright/java:v1.46.0-jammy /bin/bash ``` #### Crawling and scraping @@ -41,7 +41,7 @@ docker run -it --rm --ipc=host mcr.microsoft.com/playwright/java:v1.45.1-jammy / On untrusted websites, it's recommended to use a separate user for launching the browsers in combination with the seccomp profile. Inside the container or if you are using the Docker image as a base image you have to use `adduser` for it. ```bash -docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/java:v1.45.1-jammy /bin/bash +docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/java:v1.46.0-jammy /bin/bash ``` [`seccomp_profile.json`](https://github.com/microsoft/playwright/blob/main/utils/docker/seccomp_profile.json) is needed to run Chromium with sandbox. This is a [default Docker seccomp profile](https://github.com/docker/engine/blob/d0d99b04cf6e00ed3fc27e81fc3d94e7eda70af3/profiles/seccomp/default.json) with extra user namespace cloning permissions: @@ -76,10 +76,10 @@ See [all available image tags]. We currently publish images with the following tags: - `:next` - tip-of-tree image version based on Ubuntu 22.04 LTS (Jammy Jellyfish). - `:next-jammy` - tip-of-tree image version based on Ubuntu 22.04 LTS (Jammy Jellyfish). -- `:v1.45.1` - Playwright v1.45.1 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). -- `:v1.45.1-noble` - Playwright v1.45.1 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). -- `:v1.45.1-jammy` - Playwright v1.45.1 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). -- `:v1.45.1-focal` - Playwright v1.45.1 release docker image based on Ubuntu 20.04 LTS (Focal Fossa). +- `:v1.46.0` - Playwright v1.46.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). +- `:v1.46.0-noble` - Playwright v1.46.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). +- `:v1.46.0-jammy` - Playwright v1.46.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). +- `:v1.46.0-focal` - Playwright v1.46.0 release docker image based on Ubuntu 20.04 LTS (Focal Fossa). :::note It is recommended to always pin your Docker image to a specific version if possible. If the Playwright version in your Docker image does not match the version in your project/tests, Playwright will be unable to locate browser executables. diff --git a/java/docs/intro.mdx b/java/docs/intro.mdx index 3e63d98b15..efebbcc8b9 100644 --- a/java/docs/intro.mdx +++ b/java/docs/intro.mdx @@ -58,7 +58,7 @@ public class App { com.microsoft.playwright playwright - 1.45.1 + 1.46.0 diff --git a/java/docs/junit.mdx b/java/docs/junit.mdx index 41ea33fb1d..116a35b85c 100644 --- a/java/docs/junit.mdx +++ b/java/docs/junit.mdx @@ -12,8 +12,6 @@ With a few lines of code, you can hook up Playwright to your favorite Java test In [JUnit](https://junit.org/junit5/), you can use Playwright [fixtures](./junit.mdx#fixtures) to automatically initialize [Playwright], [Browser], [BrowserContext] or [Page]. In the example below, all three test methods use the same [Browser]. Each test uses its own [BrowserContext] and [Page]. - - ```java package org.example; diff --git a/java/docs/screenshots.mdx b/java/docs/screenshots.mdx index ac71373caa..ce624544d5 100644 --- a/java/docs/screenshots.mdx +++ b/java/docs/screenshots.mdx @@ -17,8 +17,6 @@ page.screenshot(new Page.ScreenshotOptions() [Screenshots API](./api/class-page#page-screenshot) accepts many parameters for image format, clip area, quality, etc. Make sure to check them out. - - ## Full page screenshots Full page screenshot is a screenshot of a full scrollable page, as if you had a very tall screen and the page could fit it entirely. diff --git a/java/docs/test-runners.mdx b/java/docs/test-runners.mdx index 8184aad800..8eb0c5b7b5 100644 --- a/java/docs/test-runners.mdx +++ b/java/docs/test-runners.mdx @@ -12,8 +12,6 @@ With a few lines of code, you can hook up Playwright to your favorite Java test Playwright and Browser instances can be reused between tests for better performance. We recommend running each test case in a new BrowserContext, this way browser state will be isolated between the tests. - - ## JUnit In [JUnit](https://junit.org/junit5/) you can initialize [Playwright] and [Browser] in [@BeforeAll](https://junit.org/junit5/docs/current/api/org.junit.jupiter.api/org/junit/jupiter/api/BeforeAll.html) method and destroy them in [@AfterAll](https://junit.org/junit5/docs/current/api/org.junit.jupiter.api/org/junit/jupiter/api/AfterAll.html). In the example below all three test methods use the same [Browser]. Each test uses its own [BrowserContext] and [Page]. @@ -200,7 +198,7 @@ repositories { } dependencies { - implementation 'com.microsoft.playwright:playwright:1.45.1' + implementation 'com.microsoft.playwright:playwright:1.46.0' } application { @@ -233,7 +231,7 @@ repositories { } dependencies { - implementation("com.microsoft.playwright:playwright:1.45.1") + implementation("com.microsoft.playwright:playwright:1.46.0") } application { diff --git a/nodejs/docs/api-testing.mdx b/nodejs/docs/api-testing.mdx index 7c4b6bbece..5c585c9794 100644 --- a/nodejs/docs/api-testing.mdx +++ b/nodejs/docs/api-testing.mdx @@ -17,8 +17,6 @@ Sometimes you may want to send requests to the server directly from Node.js with All of that could be achieved via [APIRequestContext] methods. - - ## Writing API Test [APIRequestContext] can send all kinds of HTTP(S) requests over network. diff --git a/nodejs/docs/screenshots.mdx b/nodejs/docs/screenshots.mdx index e12f37c3e4..9a304d1fb8 100644 --- a/nodejs/docs/screenshots.mdx +++ b/nodejs/docs/screenshots.mdx @@ -16,8 +16,6 @@ await page.screenshot({ path: 'screenshot.png' }); [Screenshots API](./api/class-page#page-screenshot) accepts many parameters for image format, clip area, quality, etc. Make sure to check them out. - - ## Full page screenshots Full page screenshot is a screenshot of a full scrollable page, as if you had a very tall screen and the page could fit it entirely. diff --git a/python/docs/api-testing.mdx b/python/docs/api-testing.mdx index db7a60d4ed..aa86e162be 100644 --- a/python/docs/api-testing.mdx +++ b/python/docs/api-testing.mdx @@ -19,8 +19,6 @@ All of that could be achieved via [APIRequestContext] methods. The following examples rely on the [`pytest-playwright`](./test-runners.mdx) package which add Playwright fixtures to the Pytest test-runner. - - ## Writing API Test [APIRequestContext] can send all kinds of HTTP(S) requests over network. diff --git a/python/docs/screenshots.mdx b/python/docs/screenshots.mdx index 446d89d755..f77f875c15 100644 --- a/python/docs/screenshots.mdx +++ b/python/docs/screenshots.mdx @@ -36,8 +36,6 @@ await page.screenshot(path="screenshot.png") [Screenshots API](./api/class-page#page-screenshot) accepts many parameters for image format, clip area, quality, etc. Make sure to check them out. - - ## Full page screenshots Full page screenshot is a screenshot of a full scrollable page, as if you had a very tall screen and the page could fit it entirely. diff --git a/src/markdown.js b/src/markdown.js index a8ae8d4360..77a405192c 100644 --- a/src/markdown.js +++ b/src/markdown.js @@ -461,6 +461,24 @@ function visit(node, visitor, depth = 0) { visit(n, visitor, depth + 1); } +/** + * @param {MarkdownNode[]} nodes + * @param {boolean=} h3 + * @returns {string} + */ +function generateToc(nodes, h3) { + const result = []; + visitAll(nodes, (node, depth) => { + if (node.type === 'h1' || node.type === 'h2' || (h3 && node.type === 'h3')) { + let link = node.text.toLowerCase(); + link = link.replace(/[ ]+/g, '-'); + link = link.replace(/[^\w-_]/g, ''); + result.push(`${' '.repeat(depth * 2)}- [${node.text}](#${link})`); + } + }); + return result.join('\n'); +} + /** * @param {MarkdownNode[]} nodes * @param {string} language @@ -491,4 +509,4 @@ function filterNodesForLanguage(nodes, language) { return result; } -module.exports = { parse, render, clone, visitAll, visit, filterNodesForLanguage, wrapText }; +module.exports = { parse, render, clone, visitAll, visit, generateToc, filterNodesForLanguage, wrapText };