Skip to content

Commit

Permalink
fix: couple e2e ci fixes (openemr#7777)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradymiller authored Oct 22, 2024
1 parent 4135a14 commit 7af700a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/Tests/E2e/IiPatientContextMainMenuLinksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static function menuLinkProvider()
{
return [
'Patient -> Dashboard menu link' => ['Patient||Dashboard', 'Dashboard', false],
'Patient -> Visits -> Create Visit menu link' => ['Patient||Visits||Create Visit', 'Patient Encounter', false, 'Visit History', true],
'Patient -> Visits -> Create Visit menu link' => ['Patient||Visits||Create Visit', 'Patient Encounter', false, 'Visit History||Loading', true],
'Patient -> Visits -> Visit History menu link' => ['Patient||Visits||Visit History', 'Visit History', false],
'Patient -> Records -> Patient Record Request menu link' => ['Patient||Records||Patient Record Request', 'Patient Records Request', false, 'Visit History||Loading'],
'Popups -> Issues menu link' => ['Popups||Issues', 'Issues', true],
Expand Down
30 changes: 28 additions & 2 deletions tests/Tests/E2e/User/UserAddTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,40 @@ private function userAddIfNotExist(string $username): void
$this->client->waitFor(XpathsConstantsUserAddTrait::CREATE_USER_BUTTON_USERADD_TRAIT);
$this->crawler = $this->client->refreshCrawler();
$this->crawler->filterXPath(XpathsConstantsUserAddTrait::CREATE_USER_BUTTON_USERADD_TRAIT)->click();
// assert the new user is in the database (check 3 times with 5 second delay prior each check to
// ensure allow enough time)
$userExistDatabase = false;
$counter = 0;
while (!$userExistDatabase && $counter < 3) {
if ($counter > 0) {
echo "TRY " . ($counter + 1) . " of 3 to see if new user is in database";
}
sleep(5);
if ($this->userExistDatabase($username)) {
$userExistDatabase = true;
}
$counter++;
}
$this->assertTrue($userExistDatabase, 'New user is not in database, so FAILED');
// assert the new user can be seen in the gui
$this->client->switchTo()->defaultContent();
// assert the new user has been added
$this->client->waitFor(XpathsConstants::ADMIN_IFRAME);
$this->switchToIFrame(XpathsConstants::ADMIN_IFRAME);
// below line will throw a timeout exception and fail if the new user is not listed
$this->client->waitFor("//table//a[text()='$username']");
$this->client->switchTo()->defaultContent();
}

private function userExistDatabase(string $username): bool
{
if (empty($username)) {
return false;
}
$usernameDatabase = sqlQuery("SELECT `username` FROM `users` WHERE `username` = ?", [$username]);
$this->assertSame(($usernameDatabase['username'] ?? ''), $username, 'New user is not in database, so FAILED');
if (($usernameDatabase['username'] ?? '') != $username) {
return false;
} else {
return true;
}
}
}

0 comments on commit 7af700a

Please sign in to comment.