Skip to content

Commit

Permalink
Revert "Bottom button tests: fallback with Javascript. (#4253)"
Browse files Browse the repository at this point in the history
This reverts commit a038f30.
  • Loading branch information
demiankatz committed Feb 17, 2025
1 parent a038f30 commit a86b17f
Showing 1 changed file with 2 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,21 +312,6 @@ protected function retryClickWithResizedWindow(Session $session, Element $page,
$session->resizeWindow(1280, 768, 'current');
}

/**
* After a failed button click has been detected, try again with Javascript
*
* @param Session $session Mink session
* @param string $selector Selector to click
*
* @return void
*/
protected function retryClickWithJavascript(Session $session, string $selector): void
{
// If retryClickWithResizedWindow() failed, we can force a click with Javascript.
echo "\n\nMink click failed; retrying with Javascript!\n";
$session->evaluateScript('$("' . $selector . '").click()');
}

/**
* Test that the export control works.
*
Expand All @@ -353,21 +338,11 @@ public function testBulkExport(string $idPrefix): void
$this->clickCss($page, $buttonSelector);

// Select EndNote option
$error = false;
try {
$select = $this->findCss($page, '#format', 100);
} catch (\Exception $e) {
$error = true;
}
// Fallback logic in case of unexpected (but occasionally encountered) random failures:
if ($error) {
try {
$this->retryClickWithResizedWindow($session, $page, $buttonSelector);
$select = $this->findCss($page, '#format');
} catch (\Exception $e) {
$this->retryClickWithJavascript($session, $buttonSelector);
$select = $this->findCss($page, '#format');
}
$this->retryClickWithResizedWindow($session, $page, $buttonSelector);
$select = $this->findCss($page, '#format');
}
$select->selectOption('EndNote');

Expand Down Expand Up @@ -403,15 +378,10 @@ public function testBulkPrint(string $idPrefix): void
$this->waitStatement('$("input.checkbox-select-item:checked").length === 2');
$this->clickCss($page, $buttonSelector);
[, $params] = explode('?', $session->getCurrentUrl());
// Fallback logic in case of unexpected (but occasionally encountered) random failures:
if (str_starts_with($params, 'lookfor')) {
$this->retryClickWithResizedWindow($session, $page, $buttonSelector);
[, $params] = explode('?', $session->getCurrentUrl());
}
if (str_starts_with($params, 'lookfor')) {
$this->retryClickWithJavascript($session, $buttonSelector);
[, $params] = explode('?', $session->getCurrentUrl());
}
$this->assertEquals(
'print=true&id[]=Solr|testsample1&id[]=Solr|testsample2',
str_replace(['%5B', '%5D', '%7C'], ['[', ']', '|'], $params)
Expand Down

0 comments on commit a86b17f

Please sign in to comment.