@testivai/witness-playwright 0.1.4 → 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,17 +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
- // Ensure lazy-loaded content is loaded by scrolling to bottom and back
83
- try {
84
- await page.evaluate('window.scrollTo(0, Math.max(document.body.scrollHeight, document.documentElement.scrollHeight))');
85
- await page.waitForTimeout(100);
86
- await page.evaluate('window.scrollTo(0, 0)');
87
- await page.waitForTimeout(100);
88
- }
89
- catch (err) {
90
- // Ignore scroll errors
91
- }
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
92
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
+ `);
93
113
  // 2. Dump full-page DOM
94
114
  const domPath = path.join(outputDir, `${baseFilename}.html`);
95
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.4",
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
@@ -56,17 +56,40 @@ export async function snapshot(
56
56
  // 1. Capture full-page screenshot
57
57
  const screenshotPath = path.join(outputDir, `${baseFilename}.png`);
58
58
 
59
- // Ensure lazy-loaded content is loaded by scrolling to bottom and back
60
- try {
61
- await page.evaluate('window.scrollTo(0, Math.max(document.body.scrollHeight, document.documentElement.scrollHeight))');
62
- await page.waitForTimeout(100);
63
- await page.evaluate('window.scrollTo(0, 0)');
64
- await page.waitForTimeout(100);
65
- } catch (err) {
66
- // Ignore scroll errors
67
- }
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
+ `);
68
76
 
77
+ // Wait for layout to stabilize
78
+ await page.waitForTimeout(200);
79
+
80
+ // Take full-page screenshot
69
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
+ `);
70
93
 
71
94
  // 2. Dump full-page DOM
72
95
  const domPath = path.join(outputDir, `${baseFilename}.html`);