mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Reapply "test: take screenshots to debug visibility tests"
This reverts commit b4c691443b.
This commit is contained in:
@@ -237,6 +237,13 @@ jobs:
|
||||
$DATADOG_PATH/datadog-ci junit upload src/electron/junit/test-results-main.xml
|
||||
fi
|
||||
if: always() && !cancelled()
|
||||
- name: Upload Test Artifacts
|
||||
if: always() && !cancelled()
|
||||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
|
||||
with:
|
||||
name: test_artifacts_${{ env.ARTIFACT_KEY }}_${{ matrix.shard }}
|
||||
path: src/electron/spec/artifacts
|
||||
if-no-files-found: ignore
|
||||
- name: Wait for active SSH sessions
|
||||
if: always() && !cancelled()
|
||||
shell: bash
|
||||
|
||||
@@ -4,8 +4,9 @@ import { expect } from 'chai';
|
||||
|
||||
import { once } from 'node:events';
|
||||
|
||||
import { ScreenCapture } from './lib/screen-helpers';
|
||||
import { defer, ifit, waitUntil } from './lib/spec-helpers';
|
||||
import { cleanupWebContents, closeAllWindows } from './lib/window-helpers';
|
||||
import { closeAllWindows } from './lib/window-helpers';
|
||||
|
||||
describe('WebContentsView', () => {
|
||||
afterEach(async () => {
|
||||
@@ -181,7 +182,14 @@ describe('WebContentsView', () => {
|
||||
});
|
||||
|
||||
describe('visibilityState', () => {
|
||||
afterEach(cleanupWebContents);
|
||||
before(async () => {
|
||||
const screenCapture = await ScreenCapture.create();
|
||||
await screenCapture.takeScreenShot();
|
||||
});
|
||||
afterEach(async () => {
|
||||
const screenCapture = await ScreenCapture.create();
|
||||
await screenCapture.takeScreenShot();
|
||||
});
|
||||
|
||||
async function haveVisibilityState (view: WebContentsView, state: string) {
|
||||
const docVisState = await view.webContents.executeJavaScript('document.visibilityState');
|
||||
|
||||
@@ -121,6 +121,14 @@ export class ScreenCapture {
|
||||
return this._expectImpl(findPoint(this.image.getSize()), hexColor, true);
|
||||
}
|
||||
|
||||
public async takeScreenShot () {
|
||||
const artifactName = await createArtifactWithRandomId(
|
||||
(id) => `screen-cap-${id}.png`,
|
||||
this.image.toPNG()
|
||||
);
|
||||
console.log(`Created artifact at: ${artifactName}`);
|
||||
}
|
||||
|
||||
private static async _createImpl (display: Electron.Display) {
|
||||
const sources = await desktopCapturer.getSources({
|
||||
types: ['screen'],
|
||||
|
||||
Reference in New Issue
Block a user