Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Upgdate CI Puppeteer to latest #901

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/storycap/package.json
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@
"@types/yargs": "^17.0.0",
"jest": "29.7.0",
"minimist": "1.2.8",
"puppeteer": "19.11.1",
"puppeteer": "23.2.1",
"ts-jest": "29.1.2",
"typedoc": "0.25.13",
"typescript": "5.4.5"
9 changes: 7 additions & 2 deletions packages/storycap/src/node/capturing-browser.ts
Original file line number Diff line number Diff line change
@@ -372,7 +372,8 @@ export class CapturingBrowser extends StoryPreviewBrowser {
let emittedScreenshotOptions: ScreenshotOptions | undefined;
this.resourceWatcher.clear();

function onConsoleLog(msg: ConsoleMessage) {
function onConsoleLog(_msg: any) {
const msg = _msg as ConsoleMessage;
const niceMessage = `From ${requestId} (${msg.type()}): ${msg.text()}`;

if (forwardConsoleLogs) {
@@ -468,6 +469,8 @@ export class CapturingBrowser extends StoryPreviewBrowser {
let buffer: Buffer | null = null;
if (Buffer.isBuffer(rawBuffer)) {
buffer = rawBuffer;
} else if (rawBuffer instanceof Uint8Array) {
buffer = Buffer.from(rawBuffer);
}

// We should reset elements state(e.g. focusing, hovering, clicking) for future screenshot for this story.
@@ -490,7 +493,9 @@ export class CapturingBrowser extends StoryPreviewBrowser {

// Calculate the suffix and save the trace to the file.
const suffix = variantKey.isDefault && defaultVariantSuffix ? [defaultVariantSuffix] : variantKey.keys;
await fileSystem.saveTrace(story.kind, story.story, suffix, traceBuffer);
if (traceBuffer) {
await fileSystem.saveTrace(story.kind, story.story, suffix, Buffer.from(traceBuffer));
}
}
}
}
2 changes: 1 addition & 1 deletion packages/storycrawler/package.json
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@
},
"dependencies": {
"chalk": "^2.4.1",
"puppeteer-core": "^9.0.0",
"puppeteer-core": "^23.2.1",
"wait-on": "^7.0.0"
},
"jest": {
3 changes: 2 additions & 1 deletion packages/storycrawler/src/browser/devices.ts
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import type { Viewport } from 'puppeteer-core';
*
*/
export function getDeviceDescriptors() {
const dd = require('puppeteer-core').devices as Record<string, { name: string; viewport: Viewport }>;
const pc = require('puppeteer-core');
const dd = (pc.KnownDevices || pc.devices) as Record<string, { name: string; viewport: Viewport }>;
return Object.values(dd);
}
17 changes: 11 additions & 6 deletions packages/storycrawler/src/browser/stories-browser.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { setTimeout as nodeSetTimeout } from 'node:timers/promises';
import { BaseBrowser, BaseBrowserOptions } from './base-browser';
import { Logger } from '../logger';
import { NoStoriesError, StoriesTimeoutError } from '../errors';
@@ -62,12 +63,16 @@ export class StoriesBrowser extends BaseBrowser {
this.logger.debug('Wait for stories definition.');
await this.page.goto(this.connection.url);
let stories: Story[] | null = null;
await this.page.goto(
// await this.page
// .goto(this.connection.url + '/iframe.html?selectedKind=story-crawler-kind&selectedStory=story-crawler-story', {
// timeout: 60_000,
// waitUntil: 'domcontentloaded',
// })
// .catch(() => {
// this.logger.warn('Timeout to open Storybook preview iframe.');
// });
this.page.goto(
this.connection.url + '/iframe.html?selectedKind=story-crawler-kind&selectedStory=story-crawler-story',
{
timeout: 60_000,
waitUntil: 'domcontentloaded',
},
);
await this.page.waitForFunction(
() =>
@@ -77,7 +82,7 @@ export class StoriesBrowser extends BaseBrowser {
timeout: 60_000,
},
);
await this.page.waitForTimeout(500);
await nodeSetTimeout(500);
await this.page.evaluate(() => {
const api = (window as ExposedWindow).__STORYBOOK_CLIENT_API__ || (window as ExposedWindow).__STORYBOOK_PREVIEW__;
function isPreviewApi(api: API | PreviewAPI): api is PreviewAPI {
438 changes: 332 additions & 106 deletions yarn.lock

Large diffs are not rendered by default.