Skip to content

Commit 4f38273

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
Pre-fix for packages bump
When updating the packages in package.json some new issue were found. I fix them in this CL to split them up. Bug: none. Change-Id: I8339de288a2816679867fcfe4791e33ce92abc44 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6764815 Commit-Queue: Nikolay Vitkov <nvitkov@chromium.org> Reviewed-by: Danil Somsikov <dsv@chromium.org> Auto-Submit: Nikolay Vitkov <nvitkov@chromium.org> Commit-Queue: Danil Somsikov <dsv@chromium.org>
1 parent a0f11d6 commit 4f38273

File tree

4 files changed

+34
-25
lines changed

4 files changed

+34
-25
lines changed

front_end/panels/media/MainView.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describeWithMockConnection('MediaMainView', () => {
2727
inScope: boolean) => async () => {
2828
SDK.TargetManager.TargetManager.instance().setScopeTarget(inScope ? target : null);
2929
const downloadStore = new Media.MainView.PlayerDataDownloadManager();
30-
const expectedCall = sinon.stub(downloadStore, expectedMethod).returns();
30+
const expectedCall = sinon.stub(downloadStore, expectedMethod);
3131
const mainView = new Media.MainView.MainView(downloadStore);
3232
renderElementIntoDOM(mainView);
3333
const model = target.model(Media.MediaModel.MediaModel);

front_end/panels/sources/SourcesView.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ describeWithEnvironment('SourcesView', () => {
149149
const uiSourceCodeFrame = widget;
150150

151151
// Skip creating the DebuggerPlugin, which times out and simulate DOM attach/showing.
152-
sinon.stub(uiSourceCodeFrame, 'loadPlugins' as keyof typeof uiSourceCodeFrame).callsFake(() => {});
152+
sinon.stub(uiSourceCodeFrame, 'loadPlugins' as keyof typeof uiSourceCodeFrame);
153153
uiSourceCodeFrame.wasShown();
154154

155155
await contentLoadedPromise;

test/shared/screenshots.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ const DEFAULT_MS_BETWEEN_RETRIES = 150;
6868
const DEFAULT_SCREENSHOT_THRESHOLD_PERCENT = 0.1;
6969

7070
export const assertElementScreenshotUnchanged = async (
71-
element: puppeteer.ElementHandle|null, fileName: string, options: Partial<puppeteer.ScreenshotOptions> = {}) => {
71+
element: puppeteer.ElementHandle|null,
72+
fileName: NonNullable<puppeteer.ScreenshotOptions['path']>,
73+
options: Partial<puppeteer.ScreenshotOptions> = {},
74+
) => {
7275
if (!element) {
7376
assert.fail(`Given element for test ${fileName} was not found.`);
7477
}
@@ -95,8 +98,8 @@ function getFrontend() {
9598
}
9699

97100
const assertScreenshotUnchangedWithRetries = async (
98-
elementOrPage: puppeteer.ElementHandle|puppeteer.Page, fileName: string, maximumDiffThreshold: number,
99-
maximumRetries: number, options: Partial<puppeteer.ScreenshotOptions> = {}) => {
101+
elementOrPage: puppeteer.ElementHandle|puppeteer.Page, fileName: NonNullable<puppeteer.ScreenshotOptions['path']>,
102+
maximumDiffThreshold: number, maximumRetries: number, options: Partial<puppeteer.ScreenshotOptions> = {}) => {
100103
const frontend = getFrontend();
101104
try {
102105
await frontend?.evaluate(() => window.dispatchEvent(new Event('hidecomponentdocsui')));
@@ -107,7 +110,8 @@ const assertScreenshotUnchangedWithRetries = async (
107110
*/
108111
const fileNameForPlatform = fileName.split('/').join(path.sep);
109112
const goldenScreenshotPath = path.join(GOLDENS_FOLDER, fileNameForPlatform);
110-
const generatedScreenshotPath = path.join(generatedScreenshotFolder, fileNameForPlatform);
113+
const generatedScreenshotPath =
114+
path.join(generatedScreenshotFolder, fileNameForPlatform) as NonNullable<puppeteer.ScreenshotOptions['path']>;
111115

112116
/**
113117
* Ensure that the directories for the golden/generated file exist. We need
@@ -133,7 +137,7 @@ const assertScreenshotUnchangedWithRetries = async (
133137

134138
interface ScreenshotAssertionOptions {
135139
goldenScreenshotPath: string;
136-
generatedScreenshotPath: string;
140+
generatedScreenshotPath: NonNullable<puppeteer.ScreenshotOptions['path']>;
137141
screenshotOptions: Partial<puppeteer.ScreenshotOptions>;
138142
elementOrPage: puppeteer.ElementHandle|puppeteer.Page;
139143
fileName: string;
@@ -153,7 +157,7 @@ const assertScreenshotUnchanged = async (options: ScreenshotAssertionOptions) =>
153157
retryCount = 1,
154158
} = options;
155159
const screenshotOptions = {...defaultScreenshotOpts, ...options.screenshotOptions, path: generatedScreenshotPath};
156-
await (elementOrPage as puppeteer.Page).screenshot(screenshotOptions);
160+
await elementOrPage.screenshot(screenshotOptions);
157161

158162
/**
159163
* The user can do UPDATE_GOLDEN=accordion/basic.png npm run screenshotstest

test/unit/karma.conf.ts

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/* eslint @typescript-eslint/no-explicit-any: 0 */
66

77
import * as path from 'path';
8-
import type {Page, Target} from 'puppeteer-core';
8+
import type {Page, ScreenshotOptions, Target} from 'puppeteer-core';
99
import puppeteer from 'puppeteer-core';
1010

1111
import {formatAsPatch, resultAssertionsDiff, ResultsDBReporter} from '../../test/conductor/karma-resultsdb-reporter.js';
@@ -59,23 +59,28 @@ const CustomChrome = function(this: any, _baseBrowserDecorator: unknown, args: B
5959
const page = await browser.newPage();
6060

6161
async function setupBindings(page: Page) {
62-
await page.exposeFunction('assertScreenshot', async (elementSelector: string, filename: string) => {
63-
try {
64-
// Karma sometimes runs tests in an iframe or in the main frame.
65-
const testFrame = page.frames()[1] ?? page.mainFrame();
66-
const element = await testFrame.waitForSelector(elementSelector);
67-
68-
await assertElementScreenshotUnchanged(element, filename, {
69-
captureBeyondViewport: false,
62+
await page.exposeFunction(
63+
'assertScreenshot',
64+
async (
65+
elementSelector: string,
66+
filename: NonNullable<ScreenshotOptions['path']>,
67+
) => {
68+
try {
69+
// Karma sometimes runs tests in an iframe or in the main frame.
70+
const testFrame = page.frames()[1] ?? page.mainFrame();
71+
const element = await testFrame.waitForSelector(elementSelector);
72+
73+
await assertElementScreenshotUnchanged(element, filename, {
74+
captureBeyondViewport: false,
75+
});
76+
return undefined;
77+
} catch (error) {
78+
if (error instanceof ScreenshotError) {
79+
ScreenshotError.errors.push(error);
80+
}
81+
return `ScreenshotError: ${error.message}`;
82+
}
7083
});
71-
return undefined;
72-
} catch (error) {
73-
if (error instanceof ScreenshotError) {
74-
ScreenshotError.errors.push(error);
75-
}
76-
return `ScreenshotError: ${error.message}`;
77-
}
78-
});
7984
}
8085

8186
async function disableAnimations(page: Page) {

0 commit comments

Comments
 (0)