-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add initial webview2 tests (#16827)
- Loading branch information
Showing
26 changed files
with
437 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: "WebView2 Tests" | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- release-* | ||
pull_request: | ||
paths-ignore: | ||
- 'browser_patches/**' | ||
- 'docs/**' | ||
branches: | ||
- main | ||
- release-* | ||
|
||
env: | ||
# Force terminal colors. @see https://www.npmjs.com/package/colors | ||
FORCE_COLOR: 1 | ||
FLAKINESS_CONNECTION_STRING: ${{ secrets.FLAKINESS_CONNECTION_STRING }} | ||
|
||
jobs: | ||
test_webview2: | ||
name: WebView2 | ||
runs-on: windows-2022 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: '6.0.x' | ||
- run: npm i -g npm@8 | ||
- run: npm ci | ||
env: | ||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 | ||
- run: npm run build | ||
- run: dotnet build | ||
working-directory: tests/webview2/webview2-app/ | ||
- run: npm run webview2test | ||
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json | ||
if: always() | ||
shell: bash | ||
- uses: actions/upload-artifact@v1 | ||
if: always() | ||
with: | ||
name: webview2-test-results | ||
path: test-results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import path from 'path'; | ||
import childProcess from 'child_process'; | ||
import playwright from 'playwright'; | ||
|
||
export default async () => { | ||
const cdpPort = 9876; | ||
const spawnedProcess = childProcess.spawn(path.join(__dirname, 'webview2-app/bin/Debug/net6.0-windows/webview2.exe'), { | ||
shell: true, | ||
env: { | ||
...process.env, | ||
WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS: `--remote-debugging-port=${cdpPort}`, | ||
} | ||
}); | ||
await new Promise<void>(resolve => spawnedProcess.stdout.on('data', (data: Buffer): void => { | ||
if (data.toString().includes('WebView2 initialized')) | ||
resolve(); | ||
})); | ||
const browser = await playwright.chromium.connectOverCDP(`http://127.0.0.1:${cdpPort}`); | ||
const chromeVersion = await browser.contexts()[0].pages()[0].evaluate(() => navigator.userAgent.match(/Chrome\/(.*?) /)[1]); | ||
process.env.PWTEST_WEBVIEW2_CHROMIUM_VERSION = chromeVersion; | ||
await browser.close(); | ||
childProcess.spawnSync(`taskkill /pid ${spawnedProcess.pid} /T /F`, { shell: true }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { config as loadEnv } from 'dotenv'; | ||
loadEnv({ path: path.join(__dirname, '..', '..', '.env') }); | ||
|
||
import type { Config, PlaywrightTestOptions, PlaywrightWorkerOptions } from '@playwright/test'; | ||
import * as path from 'path'; | ||
import type { CoverageWorkerOptions } from '../config/coverageFixtures'; | ||
|
||
process.env.PWPAGE_IMPL = 'webview2'; | ||
|
||
const outputDir = path.join(__dirname, '..', '..', 'test-results'); | ||
const testDir = path.join(__dirname, '..'); | ||
const config: Config<CoverageWorkerOptions & PlaywrightWorkerOptions & PlaywrightTestOptions> = { | ||
testDir, | ||
outputDir, | ||
timeout: 30000, | ||
globalTimeout: 5400000, | ||
workers: process.env.CI ? 1 : undefined, | ||
forbidOnly: !!process.env.CI, | ||
preserveOutput: process.env.CI ? 'failures-only' : 'always', | ||
retries: process.env.CI ? 3 : 0, | ||
reporter: process.env.CI ? [ | ||
['dot'], | ||
['json', { outputFile: path.join(outputDir, 'report.json') }], | ||
] : 'line', | ||
projects: [], | ||
globalSetup: './globalSetup.ts', | ||
}; | ||
|
||
const metadata = { | ||
platform: process.platform, | ||
headful: true, | ||
browserName: 'webview2', | ||
channel: undefined, | ||
mode: 'default', | ||
video: false, | ||
}; | ||
|
||
config.projects.push({ | ||
name: 'chromium', // We use 'chromium' here to share screenshots with chromium. | ||
use: { | ||
browserName: 'chromium', | ||
coverageName: 'webview2', | ||
}, | ||
testDir: path.join(testDir, 'page'), | ||
metadata, | ||
}); | ||
|
||
export default config; |
Oops, something went wrong.