Skip to content
Snippets Groups Projects
Commit 9feee4ed authored by Demian Katz's avatar Demian Katz Committed by Robert Lange
Browse files

Prevent print dialogs from popping up during testing. (#1439)

- This prevents some versions of Chrome from getting stuck during automated tests.
parent 26335d7a
No related merge requests found
...@@ -306,12 +306,13 @@ ...@@ -306,12 +306,13 @@
</else> </else>
</if> </if>
<!-- Update config.ini to activate DB connection and exception logging --> <!-- Update config.ini to activate DB connection, exception logging and test mode -->
<copy file="${srcdir}/config/vufind/config.ini" tofile="${srcdir}/local/config/vufind/config.ini"> <copy file="${srcdir}/config/vufind/config.ini" tofile="${srcdir}/local/config/vufind/config.ini">
<filterchain> <filterchain>
<replaceregexp> <replaceregexp>
<regexp pattern="mysql://root@localhost/vufind" replace="${db_connection_string}" /> <regexp pattern="mysql://root@localhost/vufind" replace="${db_connection_string}" />
<regexp pattern=";file\s+= /var/log/vufind.log:alert,error,notice,debug" replace="file = ${srcdir}/vufind-exception.log:alert-5,error-5" /> <regexp pattern=";file\s+= /var/log/vufind.log:alert,error,notice,debug" replace="file = ${srcdir}/vufind-exception.log:alert-5,error-5" />
<regexp pattern="(\[System\]\s+)" replace="\1runningTestSuite=1" />
</replaceregexp> </replaceregexp>
</filterchain> </filterchain>
</copy> </copy>
......
...@@ -103,6 +103,25 @@ class Bootstrapper ...@@ -103,6 +103,25 @@ class Bootstrapper
$this->config = $sm->get(\VuFind\Config\PluginManager::class)->get('config'); $this->config = $sm->get(\VuFind\Config\PluginManager::class)->get('config');
} }
/**
* Set up cookie to flag test mode.
*
* @return void
*/
protected function initTestMode()
{
// If we're in test mode (as determined by the config.ini property installed
// by the build.xml startup process), set a cookie so the front-end code can
// act accordingly. (This is needed to work around a problem where opening
// print dialogs during testing stalls the automated test process).
if ($this->config->System->runningTestSuite ?? false) {
$app = $this->event->getApplication();
$sm = $app->getServiceManager();
$cm = $sm->get(\VuFind\Cookie\CookieManager::class);
$cm->set('VuFindTestSuiteRunning', '1', 0, false);
}
}
/** /**
* Initialize dynamic debug mode (debug initiated by a ?debug=true parameter). * Initialize dynamic debug mode (debug initiated by a ?debug=true parameter).
* *
......
...@@ -428,7 +428,14 @@ $(document).ready(function commonDocReady() { ...@@ -428,7 +428,14 @@ $(document).ready(function commonDocReady() {
if (url.indexOf('?' + 'print' + '=') !== -1 || url.indexOf('&' + 'print' + '=') !== -1) { if (url.indexOf('?' + 'print' + '=') !== -1 || url.indexOf('&' + 'print' + '=') !== -1) {
$("link[media='print']").attr("media", "all"); $("link[media='print']").attr("media", "all");
$(document).ajaxStop(function triggerPrint() { $(document).ajaxStop(function triggerPrint() {
window.print(); // Print dialogs cause problems during testing, so disable them
// when the "test mode" cookie is set. This should never happen
// under normal usage outside of the Phing startup process.
if (document.cookie.indexOf('VuFindTestSuiteRunning=') === -1) {
window.print();
} else {
console.log("Printing disabled due to test mode.");
}
}); });
// Make an ajax call to ensure that ajaxStop is triggered // Make an ajax call to ensure that ajaxStop is triggered
$.getJSON(VuFind.path + '/AJAX/JSON', {method: 'keepAlive'}); $.getJSON(VuFind.path + '/AJAX/JSON', {method: 'keepAlive'});
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment