@applitools/eyes-playwright 1.46.8 → 1.47.0
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/CHANGELOG.md +34 -0
- package/dist/fixture/report-plugin/data/dataParser.js +5 -1
- package/dist/fixture/report-plugin/reportRenderer.js +2 -0
- package/dist/fixture/report-plugin/utils/scriptTagRestorer.js +48 -19
- package/dist/fixture/reportRenderer.js +1 -1
- package/dist/fixture/reportRenderer.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.47.0](https://github.com/Applitools-Dev/sdk/compare/js/eyes-playwright@1.46.8...js/eyes-playwright@1.47.0) (2026-04-29)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* new render target entities | AD 13251 ([#3775](https://github.com/Applitools-Dev/sdk/issues/3775)) ([18b6107](https://github.com/Applitools-Dev/sdk/commit/18b6107937ff0f18ba0a256fec1adc6d423f03dc))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* support Playwright >= 1.59 template element in HTML report plugin | AD-13209 ([#3770](https://github.com/Applitools-Dev/sdk/issues/3770)) ([8f2ed26](https://github.com/Applitools-Dev/sdk/commit/8f2ed264298d91621ad898cf324bbbc208e15b65))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Dependencies
|
|
17
|
+
|
|
18
|
+
* @applitools/ufg-client bumped to 1.22.0
|
|
19
|
+
#### Features
|
|
20
|
+
|
|
21
|
+
* new render target entities | AD 13251 ([#3775](https://github.com/Applitools-Dev/sdk/issues/3775)) ([18b6107](https://github.com/Applitools-Dev/sdk/commit/18b6107937ff0f18ba0a256fec1adc6d423f03dc))
|
|
22
|
+
* @applitools/core bumped to 4.61.0
|
|
23
|
+
#### Features
|
|
24
|
+
|
|
25
|
+
* new render target entities | AD 13251 ([#3775](https://github.com/Applitools-Dev/sdk/issues/3775)) ([18b6107](https://github.com/Applitools-Dev/sdk/commit/18b6107937ff0f18ba0a256fec1adc6d423f03dc))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
* @applitools/eyes bumped to 1.40.0
|
|
30
|
+
#### Features
|
|
31
|
+
|
|
32
|
+
* new render target entities | AD 13251 ([#3775](https://github.com/Applitools-Dev/sdk/issues/3775)) ([18b6107](https://github.com/Applitools-Dev/sdk/commit/18b6107937ff0f18ba0a256fec1adc6d423f03dc))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
3
37
|
## [1.46.8](https://github.com/Applitools-Dev/sdk/compare/js/eyes-playwright@1.46.7...js/eyes-playwright@1.46.8) (2026-04-23)
|
|
4
38
|
|
|
5
39
|
|
|
@@ -13,8 +13,12 @@ const logger = (0, log_js_1.default)('[Eyes Data Parser]');
|
|
|
13
13
|
async function getTestResults() {
|
|
14
14
|
var _a;
|
|
15
15
|
// Step 1: Get Playwright report data from window object
|
|
16
|
+
// Playwright < 1.59 uses <script type="application/zip" id="playwrightReportBase64"> (readable via .textContent)
|
|
17
|
+
// Playwright >= 1.59 uses <template id="playwrightReportBase64"> (content lives in .content fragment, .textContent is empty)
|
|
16
18
|
const reportData = window.playwrightReportBase64;
|
|
17
|
-
const playwrightReportBase64 = typeof reportData === 'string'
|
|
19
|
+
const playwrightReportBase64 = typeof reportData === 'string'
|
|
20
|
+
? reportData
|
|
21
|
+
: (_a = (reportData instanceof HTMLTemplateElement ? reportData.content.textContent : reportData === null || reportData === void 0 ? void 0 : reportData.textContent)) !== null && _a !== void 0 ? _a : '';
|
|
18
22
|
if (!playwrightReportBase64) {
|
|
19
23
|
logger.error('[Eyes Data Parser] No playwrightReportBase64 found in window');
|
|
20
24
|
return {
|
|
@@ -102,6 +102,8 @@ class ReportRenderer {
|
|
|
102
102
|
}
|
|
103
103
|
window.__initEyesReport = (options = {}) => {
|
|
104
104
|
const useTestMode = options.useTestMode || false;
|
|
105
|
+
// Capture original element type while it's still in the DOM (before React removes it)
|
|
106
|
+
(0, scriptTagRestorer_js_1.initScriptTagRestorer)();
|
|
105
107
|
logger.log('Before Initialized');
|
|
106
108
|
const waitForResults = (0, dataParser_js_1.getTestResults)();
|
|
107
109
|
const reportRenderer = new ReportRenderer(waitForResults, { useTestMode });
|
|
@@ -3,49 +3,78 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ensureScriptTagExists = void 0;
|
|
6
|
+
exports.ensureScriptTagExists = exports.initScriptTagRestorer = void 0;
|
|
7
7
|
const log_js_1 = __importDefault(require("../core/log.js"));
|
|
8
8
|
const logger = (0, log_js_1.default)('[Script Tag Restorer]');
|
|
9
|
+
const scriptTagId = 'playwrightReportBase64';
|
|
10
|
+
// Captured once at init time, before React removes the element.
|
|
11
|
+
// Defaults to 'SCRIPT' (Playwright < 1.59 format) so that c.textContent is readable.
|
|
12
|
+
let originalElementTagName = 'SCRIPT';
|
|
9
13
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
14
|
+
* Must be called early (before window.onload / React mount) while the original
|
|
15
|
+
* playwrightReportBase64 element is still in the DOM. Records its tag name so
|
|
16
|
+
* ensureScriptTagExists() can recreate it in the same format:
|
|
17
|
+
* <script type="application/zip"> – Playwright < 1.59: Playwright reads .textContent
|
|
18
|
+
* <template> – Playwright >= 1.59: Playwright reads .content.textContent
|
|
19
|
+
*/
|
|
20
|
+
function initScriptTagRestorer() {
|
|
21
|
+
const el = document.getElementById(scriptTagId);
|
|
22
|
+
if (el != null) {
|
|
23
|
+
originalElementTagName = el.tagName; // 'SCRIPT' or 'TEMPLATE'
|
|
24
|
+
logger.log(`Original element tag: ${originalElementTagName}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.initScriptTagRestorer = initScriptTagRestorer;
|
|
28
|
+
/**
|
|
29
|
+
* Restores the playwrightReportBase64 element if it's been removed by Playwright's host code.
|
|
30
|
+
* This is necessary for Playwright 1.57+ where the host removes the element after reading it.
|
|
12
31
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
32
|
+
* Recreates the element using the same tag that was originally in the HTML so Playwright's
|
|
33
|
+
* internal code can read it correctly on subsequent window.onload() calls.
|
|
15
34
|
*/
|
|
16
35
|
function ensureScriptTagExists() {
|
|
17
36
|
var _a;
|
|
18
|
-
const scriptTagId = 'playwrightReportBase64';
|
|
19
37
|
let scriptTag = document.getElementById(scriptTagId);
|
|
20
|
-
// If the script tag already exists, no action needed
|
|
21
38
|
if (scriptTag) {
|
|
22
39
|
logger.log('Script tag already exists, no restoration needed');
|
|
23
40
|
return;
|
|
24
41
|
}
|
|
25
|
-
// Get the data from window.playwrightReportBase64
|
|
26
42
|
const reportData = window.playwrightReportBase64;
|
|
27
43
|
if (!reportData) {
|
|
28
44
|
logger.warn('No playwrightReportBase64 data found in window, cannot restore script tag');
|
|
29
45
|
return;
|
|
30
46
|
}
|
|
31
|
-
|
|
32
|
-
|
|
47
|
+
const base64String = typeof reportData === 'string'
|
|
48
|
+
? reportData
|
|
49
|
+
: (_a = (reportData instanceof HTMLTemplateElement ? reportData.content.textContent : reportData === null || reportData === void 0 ? void 0 : reportData.textContent)) !== null && _a !== void 0 ? _a : '';
|
|
33
50
|
if (!base64String) {
|
|
34
51
|
logger.warn('playwrightReportBase64 data is empty, cannot restore script tag');
|
|
35
52
|
return;
|
|
36
53
|
}
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
// Recreate using the same element type that was originally in the HTML.
|
|
55
|
+
// Playwright < 1.59 uses <script type="application/zip"> and reads .textContent.
|
|
56
|
+
// Playwright >= 1.59 uses <template> and reads .content.textContent.
|
|
57
|
+
// Using the wrong element type causes .textContent to return "" for <template>,
|
|
58
|
+
// which makes Playwright fall through to the localStorage HMR path and show an alert.
|
|
59
|
+
if (originalElementTagName === 'TEMPLATE') {
|
|
60
|
+
const templateEl = document.createElement('template');
|
|
61
|
+
templateEl.id = scriptTagId;
|
|
62
|
+
// Use content.appendChild — do NOT use template.textContent= (setter behaviour varies)
|
|
63
|
+
templateEl.content.appendChild(document.createTextNode(base64String));
|
|
64
|
+
scriptTag = templateEl;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// Default: <script type="application/zip"> for Playwright < 1.59
|
|
68
|
+
const scriptEl = document.createElement('script');
|
|
69
|
+
scriptEl.id = scriptTagId;
|
|
70
|
+
scriptEl.type = 'application/zip';
|
|
71
|
+
scriptEl.textContent = base64String;
|
|
72
|
+
scriptTag = scriptEl;
|
|
73
|
+
}
|
|
45
74
|
const targetElement = document.head || document.body;
|
|
46
75
|
if (targetElement) {
|
|
47
76
|
targetElement.insertBefore(scriptTag, targetElement.firstChild);
|
|
48
|
-
logger.log(
|
|
77
|
+
logger.log(`Successfully restored playwrightReportBase64 as <${originalElementTagName.toLowerCase()}>`);
|
|
49
78
|
}
|
|
50
79
|
else {
|
|
51
80
|
logger.error('Cannot find head or body element to insert script tag');
|