diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e7c2d70a134e3fa1d049a5b31c430ef5946ea713 --- /dev/null +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordTest.php @@ -0,0 +1,91 @@ +<?php +/** + * Mink test class for basic record functionality. + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFindTest\Mink; +use Behat\Mink\Session; + +/** + * Mink test class for basic record functionality. + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class RecordTest extends \VuFindTest\Unit\MinkTestCase +{ + /** + * Test record tabs for a particular ID. + * + * @param Session $session Session + * @param string $id ID to load + * + * @return void + */ + protected function tryRecordTabsOnId(Session $session, $id) + { + $url = $this->getVuFindUrl('/Record/' . str_replace('+', '%20', urlencode($id))); + $session->visit($url); + $this->assertEquals(200, $session->getStatusCode()); + $page = $session->getPage(); + $staffViewTab = $page->findById('details'); + $this->assertTrue(is_object($staffViewTab)); + $this->assertEquals('Staff View', $staffViewTab->getText()); + $staffViewTab->click(); + $this->assertEquals($url . '#details', $session->getCurrentUrl()); + $staffViewTable = $page->find('css', '#details-tab table.citation'); + $this->assertTrue(is_object($staffViewTable)); + $this->assertEquals('LEADER', substr($staffViewTable->getText(), 0, 6)); + } + + /** + * Test that record tabs work with a "normal" ID. + * + * @return void + */ + public function testRecordTabsOnNormalId() + { + $session = $this->getMinkSession(); + $session->start(); + $this->tryRecordTabsOnId($session, 'testsample1'); + $session->stop(); + } + + /** + * Test that record tabs work with a "weird" ID. + * + * @return void + */ + public function testRecordTabsOnWeirdId() + { + $session = $this->getMinkSession(); + $session->start(); + $this->tryRecordTabsOnId($session, 'dot.dash-underscore__3.space suffix'); + $session->stop(); + } +} diff --git a/themes/bootstrap3/js/record.js b/themes/bootstrap3/js/record.js index 035785eeb81fd196f97ace8e8284f13fdf3293c1..6b654f3a96a173b487f62be3db6bbcc2ee21368c 100644 --- a/themes/bootstrap3/js/record.js +++ b/themes/bootstrap3/js/record.js @@ -151,7 +151,7 @@ function ajaxLoadTab(tabid) { // Try to parse out the controller portion of the URL. If this fails, or if // we're flagged to skip AJAX for this tab, just return true and let the // browser handle it. - var urlroot = document.URL.match(new RegExp('/[^/]+/'+id)); + var urlroot = document.URL.match(new RegExp('/[^/]+/' + encodeURIComponent(id))); if(!urlroot || document.getElementById(tabid).parentNode.className.indexOf('noajax') > -1) { return true; }