Skip to content

Commit 0099025

Browse files
committed
fix
1 parent 6021b5c commit 0099025

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ services:
3636
HOST_PWD: ${PWD}
3737
SYMFONY_IDE: "%env(IDE_USED)%://open?url=file://%%f&line=%%l&/var/www/html/>%env(HOST_PWD)%/"
3838
PANTHER_NO_SANDBOX: 1
39-
PANTHER_CHROME_ARGUMENTS: '--disable-dev-shm-usage --disable-features=IsolateOrigins,site-per-process,TrackingProtection3pcd'
39+
PANTHER_CHROME_ARGUMENTS: '--disable-dev-shm-usage --disable-features=IsolateOrigins,site-per-process,TrackingProtection3pcd --window-size=1920,1080'
4040
env_file:
4141
.env
4242
volumes:

tests/behat/bootstrap/WaitContext.php

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
trait WaitContext
1818
{
19-
private const DEFAULT_TIMEOUT_MS = 10000;
19+
private const DEFAULT_TIMEOUT_MS = 12000;
2020
private const DEFAULT_POLL_INTERVAL_MS = 100;
2121

2222
/**
@@ -69,6 +69,42 @@ public function pressButtonAndWaitToSee(string $button, string $text, ?string $t
6969
$this->waitToSeeText($text, $timeout);
7070
}
7171

72+
#[When('/^I follow the button of tooltip "(?P<tooltip>[^"]*)" and wait until I see "(?P<text>[^"]*)"(?:| within (?P<timeout>\d+)ms)$/')]
73+
public function clickLinkOfTooltipAndWaitToSee(string $tooltip, string $text, ?string $timeout = null): void
74+
{
75+
$link = $this->minkContext->getSession()->getPage()->find('css', sprintf('a[data-tooltip="%s"]', $tooltip));
76+
77+
if (null === $link) {
78+
throw new ExpectationException(
79+
sprintf('Link of tooltip "%s" not found', $tooltip),
80+
$this->minkContext->getSession()->getDriver(),
81+
);
82+
}
83+
84+
$session = $this->minkContext->getSession();
85+
86+
if ($session->getDriver() instanceof \Behat\Mink\Driver\PantherDriver) {
87+
$href = $link->getAttribute('href');
88+
$session->executeScript(sprintf('window.location.href = %s;', json_encode($href)));
89+
90+
$timeoutMs = $timeout !== null ? (int) $timeout : self::DEFAULT_TIMEOUT_MS;
91+
$this->waitForCondition(
92+
fn() => str_contains($session->getPage()->getContent(), $text),
93+
sprintf(
94+
'Text "%s" did not appear within %dms. Current URL: %s. Page excerpt: %s',
95+
$text,
96+
$timeoutMs,
97+
$session->getCurrentUrl(),
98+
substr(strip_tags($session->getPage()->getContent()), 0, 500),
99+
),
100+
$timeoutMs,
101+
);
102+
} else {
103+
$link->click();
104+
$this->waitToSeeText($text, $timeout);
105+
}
106+
}
107+
72108
/**
73109
* Generic wait-for-condition method that polls until timeout.
74110
*

tests/behat/features/Admin/Tresorerie/DevisFactures.feature

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ Feature: Administration - Trésorerie - Devis/Facture
9292
And I should see "Paris Cedex 1"
9393
And I should see a yellow label "En attente"
9494
# Modification de la facture
95-
Then I follow the button of tooltip "Modifier la ligne ESN dev en folie"
96-
And I should see "Modifier une facture"
95+
When I follow the button of tooltip "Modifier la ligne ESN dev en folie" and wait until I see "Modifier une facture"
9796
Then I fill in "ville" with "Paris Cedex 7"
9897
Then I select "1" from "etat_paiement"
9998
When I press "Modifier" and wait until I see "L'écriture a été modifiée"

0 commit comments

Comments
 (0)