From b0473b71cd8ba183baa81547cb45013194251d13 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 2 Aug 2023 11:23:47 +0200 Subject: [PATCH] chore: limit docs snippet length to 100 (#24563) --- docs/src/accessibility-testing-js.md | 12 +++- docs/src/api-testing-js.md | 32 ++++++++-- docs/src/api/class-android.md | 8 ++- docs/src/api/class-browsercontext.md | 4 +- docs/src/api/class-elementhandle.md | 4 +- docs/src/api/class-frame.md | 8 ++- docs/src/api/class-page.md | 16 +++-- docs/src/chrome-extensions-js-python.md | 4 +- docs/src/other-locators.md | 4 +- docs/src/pom.md | 18 +++++- ...-workers-experimental-network-events-js.md | 4 +- docs/src/test-annotations-js.md | 5 +- docs/src/test-api/class-test.md | 5 +- docs/src/test-assertions-js.md | 6 +- docs/src/test-configuration-js.md | 3 +- docs/src/test-reporter-api/class-reporter.md | 4 +- docs/src/test-reporters-js.md | 4 +- docs/src/test-use-options-js.md | 6 +- docs/src/webview2.md | 13 +++- packages/playwright-core/types/types.d.ts | 64 ++++++++++++++----- packages/playwright-test/types/test.d.ts | 5 +- .../playwright-test/types/testReporter.d.ts | 4 +- utils/doclint/linting-code-snippets/cli.js | 1 + 23 files changed, 177 insertions(+), 57 deletions(-) diff --git a/docs/src/accessibility-testing-js.md b/docs/src/accessibility-testing-js.md index 10e8fe30a3..f31cf79af8 100644 --- a/docs/src/accessibility-testing-js.md +++ b/docs/src/accessibility-testing-js.md @@ -71,7 +71,9 @@ For example, you can use [`AxeBuilder.include()`](https://github.com/dequelabs/a `AxeBuilder.analyze()` will scan the page *in its current state* when you call it. To scan parts of a page that are revealed based on UI interactions, use [Locators](./locators.md) to interact with the page before invoking `analyze()`: ```js -test('navigation menu flyout should not have automatically detectable accessibility violations', async ({ page }) => { +test('navigation menu should not have automatically detectable accessibility violations', async ({ + page, +}) => { await page.goto('https://your-site.com/'); await page.getByRole('button', { name: 'Navigation Menu' }).click(); @@ -126,7 +128,9 @@ This is usually the simplest option, but it has some important downsides: Here is an example of excluding one element from being scanned in one specific test: ```js -test('should not have any accessibility violations outside of elements with known issues', async ({ page }) => { +test('should not have any accessibility violations outside of elements with known issues', async ({ + page, +}) => { await page.goto('https://your-site.com/page-with-known-issues'); const accessibilityScanResults = await new AxeBuilder({ page }) @@ -146,7 +150,9 @@ If your application contains many different pre-existing violations of a specifi You can find the rule IDs to pass to `disableRules()` in the `id` property of the violations you want to suppress. A [complete list of axe's rules](https://github.com/dequelabs/axe-core/blob/master/doc/rule-descriptions.md) can be found in `axe-core`'s documentation. ```js -test('should not have any accessibility violations outside of rules with known issues', async ({ page }) => { +test('should not have any accessibility violations outside of rules with known issues', async ({ + page, +}) => { await page.goto('https://your-site.com/page-with-known-issues'); const accessibilityScanResults = await new AxeBuilder({ page }) diff --git a/docs/src/api-testing-js.md b/docs/src/api-testing-js.md index 7c7fe1d94f..c8f56c24fa 100644 --- a/docs/src/api-testing-js.md +++ b/docs/src/api-testing-js.md @@ -242,7 +242,9 @@ test('last created issue should be on the server', async ({ page }) => { await page.getByText('Submit new issue').click(); const issueId = page.url().substr(page.url().lastIndexOf('/')); - const newIssue = await apiContext.get(`https://api.github.com/repos/${USER}/${REPO}/issues/${issueId}`); + const newIssue = await apiContext.get( + `https://api.github.com/repos/${USER}/${REPO}/issues/${issueId}` + ); expect(newIssue.ok()).toBeTruthy(); expect(newIssue.json()).toEqual(expect.objectContaining({ title: 'Bug report 1' @@ -288,19 +290,26 @@ The main difference is that [APIRequestContext] accessible via [`property: Brows automatically update browser cookies if [APIResponse] has `Set-Cookie` header: ```js -test('context request will share cookie storage with its browser context', async ({ page, context }) => { +test('context request will share cookie storage with its browser context', async ({ + page, + context, +}) => { await context.route('https://www.github.com/', async route => { // Send an API request that shares cookie storage with the browser context. const response = await context.request.fetch(route.request()); const responseHeaders = response.headers(); // The response will have 'Set-Cookie' header. - const responseCookies = new Map(responseHeaders['set-cookie'].split('\n').map(c => c.split(';', 2)[0].split('='))); + const responseCookies = new Map(responseHeaders['set-cookie'] + .split('\n') + .map(c => c.split(';', 2)[0].split('='))); // The response will have 3 cookies in 'Set-Cookie' header. expect(responseCookies.size).toBe(3); const contextCookies = await context.cookies(); // The browser context will already contain all the cookies from the API response. - expect(new Map(contextCookies.map(({ name, value }) => [name, value]))).toEqual(responseCookies); + expect(new Map(contextCookies.map(({ name, value }) => + [name, value]) + )).toEqual(responseCookies); route.fulfill({ response, @@ -315,14 +324,21 @@ If you don't want [APIRequestContext] to use and update cookies from the browser create a new instance of [APIRequestContext] which will have its own isolated cookies: ```js -test('global context request has isolated cookie storage', async ({ page, context, browser, playwright }) => { +test('global context request has isolated cookie storage', async ({ + page, + context, + browser, + playwright +}) => { // Create a new instance of APIRequestContext with isolated cookie storage. const request = await playwright.request.newContext(); await context.route('https://www.github.com/', async route => { const response = await request.fetch(route.request()); const responseHeaders = response.headers(); - const responseCookies = new Map(responseHeaders['set-cookie'].split('\n').map(c => c.split(';', 2)[0].split('='))); + const responseCookies = new Map(responseHeaders['set-cookie'] + .split('\n') + .map(c => c.split(';', 2)[0].split('='))); // The response will have 3 cookies in 'Set-Cookie' header. expect(responseCookies.size).toBe(3); const contextCookies = await context.cookies(); @@ -335,7 +351,9 @@ test('global context request has isolated cookie storage', async ({ page, contex const browserContext2 = await browser.newContext({ storageState }); const contextCookies2 = await browserContext2.cookies(); // The new browser context will already contain all the cookies from the API response. - expect(new Map(contextCookies2.map(({ name, value }) => [name, value]))).toEqual(responseCookies); + expect( + new Map(contextCookies2.map(({ name, value }) => [name, value])) + ).toEqual(responseCookies); route.fulfill({ response, diff --git a/docs/src/api/class-android.md b/docs/src/api/class-android.md index 67b96c331a..6f6d4c7ed1 100644 --- a/docs/src/api/class-android.md +++ b/docs/src/api/class-android.md @@ -40,8 +40,12 @@ const { _android: android } = require('playwright'); const webview = await device.webView({ pkg: 'org.chromium.webview_shell' }); // Fill the input box. - await device.fill({ res: 'org.chromium.webview_shell:id/url_field' }, 'github.com/microsoft/playwright'); - await device.press({ res: 'org.chromium.webview_shell:id/url_field' }, 'Enter'); + await device.fill({ + res: 'org.chromium.webview_shell:id/url_field', + }, 'github.com/microsoft/playwright'); + await device.press({ + res: 'org.chromium.webview_shell:id/url_field', + }, 'Enter'); // Work with WebView's page as usual. const page = await webview.page(); diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.md index 307407f4ca..322c3a5072 100644 --- a/docs/src/api/class-browsercontext.md +++ b/docs/src/api/class-browsercontext.md @@ -768,7 +768,9 @@ const crypto = require('crypto'); (async () => { const browser = await webkit.launch({ headless: false }); const context = await browser.newContext(); - await context.exposeFunction('sha256', text => crypto.createHash('sha256').update(text).digest('hex')); + await context.exposeFunction('sha256', text => + crypto.createHash('sha256').update(text).digest('hex'), + ); const page = await context.newPage(); await page.setContent(`