mirror of
https://github.com/DeNNiiInc/Web-Page-Performance-Test.git
synced 2026-04-17 20:05:58 +00:00
Feat: Add backend support for filmstrip capture
This commit is contained in:
@@ -60,6 +60,7 @@ async function _executeTest(url, options) {
|
|||||||
const { v4: uuidv4 } = await import('uuid');
|
const { v4: uuidv4 } = await import('uuid');
|
||||||
|
|
||||||
const isMobile = options.isMobile ?? false; // Default to desktop (matches frontend)
|
const isMobile = options.isMobile ?? false; // Default to desktop (matches frontend)
|
||||||
|
const captureFilmstrip = options.captureFilmstrip ?? false;
|
||||||
const reportDir = path.join(__dirname, '..', 'reports');
|
const reportDir = path.join(__dirname, '..', 'reports');
|
||||||
|
|
||||||
// Ensure reports directory exists
|
// Ensure reports directory exists
|
||||||
@@ -111,8 +112,22 @@ async function _executeTest(url, options) {
|
|||||||
},
|
},
|
||||||
throttlingMethod: 'provided'
|
throttlingMethod: 'provided'
|
||||||
},
|
},
|
||||||
|
passes: [{
|
||||||
|
passName: 'defaultPass',
|
||||||
|
recordTrace: true, // Required for filmstrip
|
||||||
|
useThrottling: true,
|
||||||
|
pauseAfterFcpMs: 0,
|
||||||
|
pauseAfterLoadMs: 0,
|
||||||
|
networkQuietThresholdMs: 0,
|
||||||
|
cpuQuietThresholdMs: 0,
|
||||||
|
gatherers: []
|
||||||
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!captureFilmstrip) {
|
||||||
|
config.settings.skipAudits = ['screenshot-thumbnails', 'final-screenshot'];
|
||||||
|
}
|
||||||
|
|
||||||
const runnerOptions = {
|
const runnerOptions = {
|
||||||
logLevel: 'info',
|
logLevel: 'info',
|
||||||
output: 'html',
|
output: 'html',
|
||||||
@@ -148,7 +163,9 @@ async function _executeTest(url, options) {
|
|||||||
tbt: lhr.audits['total-blocking-time'].numericValue,
|
tbt: lhr.audits['total-blocking-time'].numericValue,
|
||||||
},
|
},
|
||||||
userAgent: lhr.userAgent,
|
userAgent: lhr.userAgent,
|
||||||
isMobile: isMobile
|
isMobile: isMobile,
|
||||||
|
filmstrip: captureFilmstrip ? (lhr.audits['screenshot-thumbnails']?.details?.items || []) : []
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Save JSON Summary
|
// Save JSON Summary
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ app.get("/api/git-info", (req, res) => {
|
|||||||
|
|
||||||
// API Endpoint: Run Test (supports multi-run)
|
// API Endpoint: Run Test (supports multi-run)
|
||||||
app.post("/api/run-test", async (req, res) => {
|
app.post("/api/run-test", async (req, res) => {
|
||||||
const { url, isMobile, runs = 1 } = req.body;
|
const { url, isMobile, runs = 1, captureFilmstrip = false } = req.body;
|
||||||
const userUuid = req.headers['x-user-uuid'];
|
const userUuid = req.headers['x-user-uuid'];
|
||||||
const userIp = req.headers['x-forwarded-for'] || req.socket.remoteAddress;
|
const userIp = req.headers['x-forwarded-for'] || req.socket.remoteAddress;
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ app.post("/api/run-test", async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
// Single run (original behavior)
|
// Single run (original behavior)
|
||||||
if (runs === 1) {
|
if (runs === 1) {
|
||||||
const result = await runner.runTest(url, { isMobile, userUuid, userIp });
|
const result = await runner.runTest(url, { isMobile, userUuid, userIp, captureFilmstrip });
|
||||||
return res.json(result);
|
return res.json(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,13 +60,13 @@ app.post("/api/run-test", async (req, res) => {
|
|||||||
const suiteId = runner.generateTestId();
|
const suiteId = runner.generateTestId();
|
||||||
|
|
||||||
// Create suite record
|
// Create suite record
|
||||||
await multiRun.createSuite(suiteId, userUuid, url, isMobile ? 'mobile' : 'desktop', runs);
|
await multiRun.createSuite(suiteId, userUuid, url, isMobile ? 'mobile' : 'desktop', runs, captureFilmstrip);
|
||||||
|
|
||||||
// Return suite ID immediately
|
// Return suite ID immediately
|
||||||
res.json({ suiteId, runs, status: 'running' });
|
res.json({ suiteId, runs, status: 'running' });
|
||||||
|
|
||||||
// Execute runs asynchronously
|
// Execute runs asynchronously
|
||||||
multiRun.executeMultipleRuns(suiteId, url, isMobile, runs, userUuid, userIp)
|
multiRun.executeMultipleRuns(suiteId, url, isMobile, runs, userUuid, userIp, captureFilmstrip)
|
||||||
.catch(error => console.error('Multi-run execution failed:', error));
|
.catch(error => console.error('Multi-run execution failed:', error));
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user