From 49cdaa665dc6102a1bacfcb4f4b6c8692adff465 Mon Sep 17 00:00:00 2001 From: Demian Katz Date: Tue, 3 Dec 2024 11:45:48 -0500 Subject: [PATCH] Include dimension data in image test failure message. --- .../src/VuFindTest/Mink/RecordCoverImageTest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordCoverImageTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordCoverImageTest.php index caca6faeacb..1ee34f6fcd4 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordCoverImageTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordCoverImageTest.php @@ -165,9 +165,10 @@ public function testCoverLoading( $session->visit($url); $page = $session->getPage(); $this->waitForPageLoad($page); + $coverSelector = 'img.recordcover'; $session->wait( $this->getDefaultTimeout(), - 'document.querySelector("img.recordcover").dataset.loaded !== undefined' + "document.querySelector('$coverSelector').dataset.loaded !== undefined" ); // Verify the expected backlink (or lack thereof): $backlinkSelector = 'p.cover-source'; @@ -185,10 +186,13 @@ public function testCoverLoading( $expectedClasses = 'recordcover' . ($ajaxcovers ? ' ajax' : '') . (empty($noCoverAvailableImage) ? ' hidden' : ''); - $coverImage = $this->findCss($page, 'img.recordcover'); + $coverImage = $this->findCss($page, $coverSelector); + $width = $session->evaluateScript("document.querySelector('$coverSelector').getBoundingClientRect().width"); + $height = $session->evaluateScript("document.querySelector('$coverSelector').getBoundingClientRect().height"); $this->assertEquals( $expectedClasses, - $coverImage?->getAttribute('class') + $coverImage?->getAttribute('class'), + "Unexpected classes on image of dimensions $width x $height" ); // Verify the expected image URL: