@applitools/eyes-playwright 1.46.8 → 1.47.1

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 CHANGED
@@ -1,5 +1,55 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.47.1](https://github.com/Applitools-Dev/sdk/compare/js/eyes-playwright@1.47.0...js/eyes-playwright@1.47.1) (2026-05-04)
4
+
5
+
6
+ ### Dependencies
7
+
8
+ * @applitools/tunnel-client bumped to 1.11.12
9
+ #### Bug Fixes
10
+
11
+ * remove deprecated uuid dependency | FLD-4179 ([#3796](https://github.com/Applitools-Dev/sdk/issues/3796)) ([b3511f0](https://github.com/Applitools-Dev/sdk/commit/b3511f070645d356aa8edf43dd57332b5917c41e))
12
+ * @applitools/ec-client bumped to 1.12.27
13
+
14
+ * @applitools/core bumped to 4.61.1
15
+
16
+ * @applitools/eyes bumped to 1.40.1
17
+
18
+
19
+ ## [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)
20
+
21
+
22
+ ### Features
23
+
24
+ * new render target entities | AD 13251 ([#3775](https://github.com/Applitools-Dev/sdk/issues/3775)) ([18b6107](https://github.com/Applitools-Dev/sdk/commit/18b6107937ff0f18ba0a256fec1adc6d423f03dc))
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * 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))
30
+
31
+
32
+ ### Dependencies
33
+
34
+ * @applitools/ufg-client bumped to 1.22.0
35
+ #### Features
36
+
37
+ * new render target entities | AD 13251 ([#3775](https://github.com/Applitools-Dev/sdk/issues/3775)) ([18b6107](https://github.com/Applitools-Dev/sdk/commit/18b6107937ff0f18ba0a256fec1adc6d423f03dc))
38
+ * @applitools/core bumped to 4.61.0
39
+ #### Features
40
+
41
+ * new render target entities | AD 13251 ([#3775](https://github.com/Applitools-Dev/sdk/issues/3775)) ([18b6107](https://github.com/Applitools-Dev/sdk/commit/18b6107937ff0f18ba0a256fec1adc6d423f03dc))
42
+
43
+
44
+
45
+ * @applitools/eyes bumped to 1.40.0
46
+ #### Features
47
+
48
+ * new render target entities | AD 13251 ([#3775](https://github.com/Applitools-Dev/sdk/issues/3775)) ([18b6107](https://github.com/Applitools-Dev/sdk/commit/18b6107937ff0f18ba0a256fec1adc6d423f03dc))
49
+
50
+
51
+
52
+
3
53
  ## [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
54
 
5
55
 
@@ -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' ? reportData : (_a = reportData === null || reportData === void 0 ? void 0 : reportData.textContent) !== null && _a !== void 0 ? _a : '';
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
- * Restores the playwrightReportBase64 script tag if it's been removed by Playwright's host code.
11
- * This is necessary for Playwright 1.57+ where the host removes the tag after reading it in window.onload.
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
- * When we invoke window.onload() to trigger React re-renders, the host code expects the script tag
14
- * to exist. If it doesn't exist, we recreate it from the data stored in window.playwrightReportBase64.
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
- // Extract the base64 string (handles both string and object with textContent)
32
- const base64String = typeof reportData === 'string' ? reportData : (_a = reportData === null || reportData === void 0 ? void 0 : reportData.textContent) !== null && _a !== void 0 ? _a : '';
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
- // Create and insert the script tag
38
- const applicationZipAttribute = document.createAttribute('type');
39
- applicationZipAttribute.value = 'application/zip';
40
- scriptTag = document.createElement('script');
41
- scriptTag.id = scriptTagId;
42
- scriptTag.attributes.setNamedItem(applicationZipAttribute);
43
- scriptTag.textContent = base64String;
44
- // Insert at the beginning of the head or body
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('Successfully restored playwrightReportBase64 script tag');
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');