@chromatic-com/playwright 0.14.5 → 0.14.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -3403,7 +3403,7 @@ var logger = process.env.LOG ? console : {
|
|
|
3403
3403
|
|
|
3404
3404
|
// ../shared/src/resource-archiver/index.ts
|
|
3405
3405
|
var _ResourceArchiver = class _ResourceArchiver {
|
|
3406
|
-
constructor(cdpClient, allowedDomains, httpCredentials) {
|
|
3406
|
+
constructor(cdpClient, allowedDomains, httpCredentials, firstUrl) {
|
|
3407
3407
|
__publicField(this, "archive", {});
|
|
3408
3408
|
__publicField(this, "client");
|
|
3409
3409
|
/**
|
|
@@ -3477,6 +3477,7 @@ var _ResourceArchiver = class _ResourceArchiver {
|
|
|
3477
3477
|
}, "requestPaused"));
|
|
3478
3478
|
this.client = cdpClient;
|
|
3479
3479
|
this.httpCredentials = httpCredentials;
|
|
3480
|
+
this.firstUrl = firstUrl;
|
|
3480
3481
|
this.assetDomains = (allowedDomains || []).map((domain) => {
|
|
3481
3482
|
if (domain.startsWith("http")) {
|
|
3482
3483
|
return domain;
|
|
@@ -3536,12 +3537,25 @@ var _ResourceArchiver = class _ResourceArchiver {
|
|
|
3536
3537
|
const contentTypeHeader = responseHeaders.find(({ name }) => name.toLowerCase() === "content-type");
|
|
3537
3538
|
const isFirstRequest = requestUrl.toString() === this.firstUrl.toString();
|
|
3538
3539
|
if (isRequestFromAllowedDomain && !isFirstRequest) {
|
|
3540
|
+
logger.log("Archiving request", {
|
|
3541
|
+
url: request.url,
|
|
3542
|
+
statusCode: responseStatusCode,
|
|
3543
|
+
statusText: responseStatusText,
|
|
3544
|
+
contentType: contentTypeHeader?.value
|
|
3545
|
+
});
|
|
3539
3546
|
this.archive[request.url] = {
|
|
3540
3547
|
statusCode: responseStatusCode,
|
|
3541
3548
|
statusText: responseStatusText,
|
|
3542
3549
|
body: Buffer.from(body, base64Encoded ? "base64" : "utf8"),
|
|
3543
3550
|
contentType: contentTypeHeader?.value
|
|
3544
3551
|
};
|
|
3552
|
+
} else {
|
|
3553
|
+
logger.log("Skipping archiving of request", {
|
|
3554
|
+
url: request.url,
|
|
3555
|
+
firstUrl: this.firstUrl.toString(),
|
|
3556
|
+
isFirstRequest,
|
|
3557
|
+
isRequestFromAllowedDomain
|
|
3558
|
+
});
|
|
3545
3559
|
}
|
|
3546
3560
|
await this.clientSend(request, "Fetch.continueRequest", {
|
|
3547
3561
|
requestId
|
|
@@ -3918,8 +3932,9 @@ function createStories(storyTitle, domSnapshots, chromaticStorybookParams) {
|
|
|
3918
3932
|
const title = collapseNewlines(storyTitle);
|
|
3919
3933
|
return {
|
|
3920
3934
|
title,
|
|
3921
|
-
stories: Object.entries(domSnapshots).map(([snapshotName, { viewport }]) => {
|
|
3935
|
+
stories: Object.entries(domSnapshots).map(([snapshotName, { viewport, parameters }]) => {
|
|
3922
3936
|
const name = collapseNewlines(snapshotName);
|
|
3937
|
+
const { chromatic: chromaticParams, ...restParameters } = parameters || {};
|
|
3923
3938
|
return {
|
|
3924
3939
|
name,
|
|
3925
3940
|
// Viewport addon (Storybook 10+): `parameters.viewport.options` registers sizes; `globals.viewport`
|
|
@@ -3937,6 +3952,7 @@ function createStories(storyTitle, domSnapshots, chromaticStorybookParams) {
|
|
|
3937
3952
|
},
|
|
3938
3953
|
chromatic: {
|
|
3939
3954
|
...chromaticStorybookParams,
|
|
3955
|
+
...chromaticParams,
|
|
3940
3956
|
modes: buildStoryModesConfig([
|
|
3941
3957
|
viewport
|
|
3942
3958
|
])
|
|
@@ -3948,7 +3964,8 @@ function createStories(storyTitle, domSnapshots, chromaticStorybookParams) {
|
|
|
3948
3964
|
defaultViewport: viewportToString(findDefaultViewport([
|
|
3949
3965
|
viewport
|
|
3950
3966
|
]))
|
|
3951
|
-
}
|
|
3967
|
+
},
|
|
3968
|
+
...restParameters
|
|
3952
3969
|
}
|
|
3953
3970
|
};
|
|
3954
3971
|
})
|
|
@@ -4026,10 +4043,13 @@ async function writeTestResult(e2eTestInfo, domSnapshots, archive, chromaticStor
|
|
|
4026
4043
|
const archiveFile = new ArchiveFile(url, response, pageUrl);
|
|
4027
4044
|
const origSrcPath = archiveFile.originalSrc();
|
|
4028
4045
|
const fileSystemPath = archiveFile.toFileSystemPath();
|
|
4046
|
+
const responsePath = path2.join(archiveDir, fileSystemPath);
|
|
4029
4047
|
if (origSrcPath !== fileSystemPath) {
|
|
4030
4048
|
sourceMap.set(origSrcPath, fileSystemPath);
|
|
4031
4049
|
}
|
|
4032
|
-
|
|
4050
|
+
if (!fs.existsSync(responsePath)) {
|
|
4051
|
+
await outputFile(responsePath, response.body);
|
|
4052
|
+
}
|
|
4033
4053
|
}));
|
|
4034
4054
|
await Promise.all(Object.entries(domSnapshots).map(async ([name, domSnapshot]) => {
|
|
4035
4055
|
const snapshot = new DOMSnapshot(domSnapshot);
|
|
@@ -4139,6 +4159,7 @@ async function executeSnapshotScript(context) {
|
|
|
4139
4159
|
type: "module",
|
|
4140
4160
|
path: __require.resolve("@chromatic-com/playwright/browser")
|
|
4141
4161
|
});
|
|
4162
|
+
await context.waitForFunction(() => typeof window.__chromatic_takeSnapshot === "function");
|
|
4142
4163
|
const snapshot = await context.evaluate(async () => {
|
|
4143
4164
|
return JSON.stringify(await window.__chromatic_takeSnapshot());
|
|
4144
4165
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -3397,7 +3397,7 @@ var logger = process.env.LOG ? console : {
|
|
|
3397
3397
|
|
|
3398
3398
|
// ../shared/src/resource-archiver/index.ts
|
|
3399
3399
|
var _ResourceArchiver = class _ResourceArchiver {
|
|
3400
|
-
constructor(cdpClient, allowedDomains, httpCredentials) {
|
|
3400
|
+
constructor(cdpClient, allowedDomains, httpCredentials, firstUrl) {
|
|
3401
3401
|
__publicField(this, "archive", {});
|
|
3402
3402
|
__publicField(this, "client");
|
|
3403
3403
|
/**
|
|
@@ -3471,6 +3471,7 @@ var _ResourceArchiver = class _ResourceArchiver {
|
|
|
3471
3471
|
}, "requestPaused"));
|
|
3472
3472
|
this.client = cdpClient;
|
|
3473
3473
|
this.httpCredentials = httpCredentials;
|
|
3474
|
+
this.firstUrl = firstUrl;
|
|
3474
3475
|
this.assetDomains = (allowedDomains || []).map((domain) => {
|
|
3475
3476
|
if (domain.startsWith("http")) {
|
|
3476
3477
|
return domain;
|
|
@@ -3530,12 +3531,25 @@ var _ResourceArchiver = class _ResourceArchiver {
|
|
|
3530
3531
|
const contentTypeHeader = responseHeaders.find(({ name }) => name.toLowerCase() === "content-type");
|
|
3531
3532
|
const isFirstRequest = requestUrl.toString() === this.firstUrl.toString();
|
|
3532
3533
|
if (isRequestFromAllowedDomain && !isFirstRequest) {
|
|
3534
|
+
logger.log("Archiving request", {
|
|
3535
|
+
url: request.url,
|
|
3536
|
+
statusCode: responseStatusCode,
|
|
3537
|
+
statusText: responseStatusText,
|
|
3538
|
+
contentType: contentTypeHeader?.value
|
|
3539
|
+
});
|
|
3533
3540
|
this.archive[request.url] = {
|
|
3534
3541
|
statusCode: responseStatusCode,
|
|
3535
3542
|
statusText: responseStatusText,
|
|
3536
3543
|
body: Buffer.from(body, base64Encoded ? "base64" : "utf8"),
|
|
3537
3544
|
contentType: contentTypeHeader?.value
|
|
3538
3545
|
};
|
|
3546
|
+
} else {
|
|
3547
|
+
logger.log("Skipping archiving of request", {
|
|
3548
|
+
url: request.url,
|
|
3549
|
+
firstUrl: this.firstUrl.toString(),
|
|
3550
|
+
isFirstRequest,
|
|
3551
|
+
isRequestFromAllowedDomain
|
|
3552
|
+
});
|
|
3539
3553
|
}
|
|
3540
3554
|
await this.clientSend(request, "Fetch.continueRequest", {
|
|
3541
3555
|
requestId
|
|
@@ -3912,8 +3926,9 @@ function createStories(storyTitle, domSnapshots, chromaticStorybookParams) {
|
|
|
3912
3926
|
const title = collapseNewlines(storyTitle);
|
|
3913
3927
|
return {
|
|
3914
3928
|
title,
|
|
3915
|
-
stories: Object.entries(domSnapshots).map(([snapshotName, { viewport }]) => {
|
|
3929
|
+
stories: Object.entries(domSnapshots).map(([snapshotName, { viewport, parameters }]) => {
|
|
3916
3930
|
const name = collapseNewlines(snapshotName);
|
|
3931
|
+
const { chromatic: chromaticParams, ...restParameters } = parameters || {};
|
|
3917
3932
|
return {
|
|
3918
3933
|
name,
|
|
3919
3934
|
// Viewport addon (Storybook 10+): `parameters.viewport.options` registers sizes; `globals.viewport`
|
|
@@ -3931,6 +3946,7 @@ function createStories(storyTitle, domSnapshots, chromaticStorybookParams) {
|
|
|
3931
3946
|
},
|
|
3932
3947
|
chromatic: {
|
|
3933
3948
|
...chromaticStorybookParams,
|
|
3949
|
+
...chromaticParams,
|
|
3934
3950
|
modes: buildStoryModesConfig([
|
|
3935
3951
|
viewport
|
|
3936
3952
|
])
|
|
@@ -3942,7 +3958,8 @@ function createStories(storyTitle, domSnapshots, chromaticStorybookParams) {
|
|
|
3942
3958
|
defaultViewport: viewportToString(findDefaultViewport([
|
|
3943
3959
|
viewport
|
|
3944
3960
|
]))
|
|
3945
|
-
}
|
|
3961
|
+
},
|
|
3962
|
+
...restParameters
|
|
3946
3963
|
}
|
|
3947
3964
|
};
|
|
3948
3965
|
})
|
|
@@ -4020,10 +4037,13 @@ async function writeTestResult(e2eTestInfo, domSnapshots, archive, chromaticStor
|
|
|
4020
4037
|
const archiveFile = new ArchiveFile(url, response, pageUrl);
|
|
4021
4038
|
const origSrcPath = archiveFile.originalSrc();
|
|
4022
4039
|
const fileSystemPath = archiveFile.toFileSystemPath();
|
|
4040
|
+
const responsePath = join(archiveDir, fileSystemPath);
|
|
4023
4041
|
if (origSrcPath !== fileSystemPath) {
|
|
4024
4042
|
sourceMap.set(origSrcPath, fileSystemPath);
|
|
4025
4043
|
}
|
|
4026
|
-
|
|
4044
|
+
if (!existsSync(responsePath)) {
|
|
4045
|
+
await outputFile(responsePath, response.body);
|
|
4046
|
+
}
|
|
4027
4047
|
}));
|
|
4028
4048
|
await Promise.all(Object.entries(domSnapshots).map(async ([name, domSnapshot]) => {
|
|
4029
4049
|
const snapshot = new DOMSnapshot(domSnapshot);
|
|
@@ -4133,6 +4153,7 @@ async function executeSnapshotScript(context) {
|
|
|
4133
4153
|
type: "module",
|
|
4134
4154
|
path: __require.resolve("@chromatic-com/playwright/browser")
|
|
4135
4155
|
});
|
|
4156
|
+
await context.waitForFunction(() => typeof window.__chromatic_takeSnapshot === "function");
|
|
4136
4157
|
const snapshot = await context.evaluate(async () => {
|
|
4137
4158
|
return JSON.stringify(await window.__chromatic_takeSnapshot());
|
|
4138
4159
|
});
|
|
@@ -3,7 +3,13 @@ import { addons } from 'storybook/manager-api';
|
|
|
3
3
|
// ../shared/storybook-config/manager.ts
|
|
4
4
|
addons.setConfig({
|
|
5
5
|
sidebar: {
|
|
6
|
-
//
|
|
6
|
+
// Ensures we use folders at the root-level instead of categories
|
|
7
7
|
showRoots: false
|
|
8
|
+
},
|
|
9
|
+
layoutCustomisations: {
|
|
10
|
+
// Hide toolbar options that don't make sense in e2e setup
|
|
11
|
+
showToolbar: () => false,
|
|
12
|
+
// Hide bottom panel that's empty in e2e setup
|
|
13
|
+
showPanel: () => false
|
|
8
14
|
}
|
|
9
15
|
});
|