From e65fe187412a7e5ad787c88f321bdbf6315af7c4 Mon Sep 17 00:00:00 2001 From: montehurd Date: Mon, 1 Jul 2024 18:39:02 -0700 Subject: [PATCH] Placeholder group index file while group runs If user tried to view a group's report while that group was running, its images could be missing since Backstop clears out a group's images when it begins a run This commit updates the group's index file when the run begins indicating the group's run is in progress This placeholder info persists until the run completes The actual report appears when the run is done --- pixel.js | 14 ++++++++ src/run-in-progress-template.html | 55 +++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 src/run-in-progress-template.html diff --git a/pixel.js b/pixel.js index 845e6b1f..1fd3bc64 100755 --- a/pixel.js +++ b/pixel.js @@ -244,12 +244,26 @@ async function runA11yRegressionTests( type, configFile, logResults, opts ) { } ); } +function writeRunInProgressTemplateToIndexFile(indexFileFullPath, group) { + try { + let template = fs.readFileSync('./src/run-in-progress-template.html', 'utf8'); + const startTime = Date.now(); + template = template.replace('START_TIME_PLACEHOLDER', startTime); + template = template.replace('GROUP_NAME_PLACEHOLDER', group); + fs.writeFileSync(indexFileFullPath, template); + } catch (e) { + console.log(`Could not write 'run in progress' template to ${indexFileFullPath}`); + console.error(e); + } +} + async function runVisualRegressionTests( type, config, group, runSilently, configFile, resetDb ) { if ( type === 'test' ) { removeFolder( config.paths.bitmaps_test ); } const indexFileFullPath = `${__dirname}/${config.paths.html_report}/index.html`; + writeRunInProgressTemplateToIndexFile( indexFileFullPath, group ); const finished = await simpleSpawn.spawn( 'docker', diff --git a/src/run-in-progress-template.html b/src/run-in-progress-template.html new file mode 100644 index 00000000..ce0b18a2 --- /dev/null +++ b/src/run-in-progress-template.html @@ -0,0 +1,55 @@ + + + + +
+ Running 'GROUP_NAME_PLACEHOLDER' +
+ Started at: +
+ Time elapsed: +
+ The Backstop report will appear when the run finishes +
+ + + + + \ No newline at end of file