Skip to content

Commit

Permalink
Merge pull request vufind-org#4131 from demiankatz/image-dimensions-i…
Browse files Browse the repository at this point in the history
…n-test

Include dimension data in image test failure message.
  • Loading branch information
ThoWagen authored Dec 4, 2024
2 parents beb7b8d + 49cdaa6 commit b9ff53e
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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:
Expand Down

0 comments on commit b9ff53e

Please sign in to comment.