@testivai/witness-playwright 0.1.3 → 0.1.5

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/snapshot.js CHANGED
@@ -79,7 +79,37 @@ async function snapshot(page, testInfo, name, config) {
79
79
  const baseFilename = `${timestamp}_${safeName}`;
80
80
  // 1. Capture full-page screenshot
81
81
  const screenshotPath = path.join(outputDir, `${baseFilename}.png`);
82
+ // Temporarily disable overflow constraints to enable full-page capture
83
+ await page.evaluate(`
84
+ window.__testivaiOriginalStyles = [];
85
+ document.querySelectorAll('*').forEach((el) => {
86
+ const computed = window.getComputedStyle(el);
87
+ if (computed.overflow === 'auto' || computed.overflow === 'scroll' ||
88
+ computed.overflowY === 'auto' || computed.overflowY === 'scroll') {
89
+ window.__testivaiOriginalStyles.push({
90
+ element: el,
91
+ overflow: el.style.overflow,
92
+ height: el.style.height
93
+ });
94
+ el.style.overflow = 'visible';
95
+ el.style.height = 'auto';
96
+ }
97
+ });
98
+ `);
99
+ // Wait for layout to stabilize
100
+ await page.waitForTimeout(200);
101
+ // Take full-page screenshot
82
102
  await page.screenshot({ path: screenshotPath, fullPage: true });
103
+ // Restore original styles
104
+ await page.evaluate(`
105
+ if (window.__testivaiOriginalStyles) {
106
+ window.__testivaiOriginalStyles.forEach((item) => {
107
+ item.element.style.overflow = item.overflow;
108
+ item.element.style.height = item.height;
109
+ });
110
+ delete window.__testivaiOriginalStyles;
111
+ }
112
+ `);
83
113
  // 2. Dump full-page DOM
84
114
  const domPath = path.join(outputDir, `${baseFilename}.html`);
85
115
  const htmlContent = await page.content();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testivai/witness-playwright",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Playwright sensor for Testivai Visual Regression Test system",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/snapshot.ts CHANGED
@@ -55,7 +55,41 @@ export async function snapshot(
55
55
 
56
56
  // 1. Capture full-page screenshot
57
57
  const screenshotPath = path.join(outputDir, `${baseFilename}.png`);
58
+
59
+ // Temporarily disable overflow constraints to enable full-page capture
60
+ await page.evaluate(`
61
+ window.__testivaiOriginalStyles = [];
62
+ document.querySelectorAll('*').forEach((el) => {
63
+ const computed = window.getComputedStyle(el);
64
+ if (computed.overflow === 'auto' || computed.overflow === 'scroll' ||
65
+ computed.overflowY === 'auto' || computed.overflowY === 'scroll') {
66
+ window.__testivaiOriginalStyles.push({
67
+ element: el,
68
+ overflow: el.style.overflow,
69
+ height: el.style.height
70
+ });
71
+ el.style.overflow = 'visible';
72
+ el.style.height = 'auto';
73
+ }
74
+ });
75
+ `);
76
+
77
+ // Wait for layout to stabilize
78
+ await page.waitForTimeout(200);
79
+
80
+ // Take full-page screenshot
58
81
  await page.screenshot({ path: screenshotPath, fullPage: true });
82
+
83
+ // Restore original styles
84
+ await page.evaluate(`
85
+ if (window.__testivaiOriginalStyles) {
86
+ window.__testivaiOriginalStyles.forEach((item) => {
87
+ item.element.style.overflow = item.overflow;
88
+ item.element.style.height = item.height;
89
+ });
90
+ delete window.__testivaiOriginalStyles;
91
+ }
92
+ `);
59
93
 
60
94
  // 2. Dump full-page DOM
61
95
  const domPath = path.join(outputDir, `${baseFilename}.html`);