-
-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Big pipe compatibility follow-up #325
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Drupal\DrupalExtension\Context; | ||
|
||
use Drupal\big_pipe\Render\Placeholder\BigPipeStrategy; | ||
use Behat\Mink\Exception\UnsupportedDriverActionException; | ||
|
||
/** | ||
* Big Pipe context. | ||
*/ | ||
class BigPipeContext extends RawDrupalContext { | ||
|
||
/** | ||
* Prepares Big Pipe NOJS cookie if needed. | ||
* | ||
* @BeforeScenario | ||
*/ | ||
public function prepareBigPipeNoJsCookie() | ||
{ | ||
try { | ||
// Check if JavaScript can be executed by Driver. | ||
$this->getSession()->getDriver()->executeScript('true'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We were using a similar approach (https://github.com/drupaltest/behat-traits/blob/8.x-1.x/src/Traits/BrowserCapabilityDetectionTrait.php#L42) but this doesn't work with ChromeDriver which throws a fatal error when no page has been loaded yet (which is the case when running |
||
} | ||
catch (UnsupportedDriverActionException $e) { | ||
// Set NOJS cookie. | ||
$this | ||
->getSession() | ||
->setCookie(BigPipeStrategy::NOJS_COOKIE, true); | ||
|
||
} | ||
catch (\Exception $e) { | ||
// Mute exceptions. | ||
} | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did have something like this in a custom project, but it stopped working with behat-extension 4, due to the authentication manager. That now does a fast logout unconditionally before login which kills the session and with that, the cookie.
I actually already did the same in my overriden logout() method with drupal-extension 3 but I thn also re-set the cookie there.
I switched to an @afterstep and adding the cookie if I have a user and the cookie isn't there yet, but that doesn't seem like a very efficient approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can solve it by emitting an event when we do the fast logout in the authentication manager?