-
-
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?
Conversation
Extra test scenarios proved DrupalExtension doesn't work well for Authenticated user and BigPipe enabled. In next commit I will suggest how can we fix it. |
As you can see first failing step ( In the same time extra scenarios have revealed that [email protected] doesn't work well with BigPipe. I tested that scenario locally with PhantomJS and it works perfect. Did you consider switching from zombiejs to phantomjs? |
I copied the |
Sorry for the long delay in getting to this. It looks like a great start! It needs to be rebased/merged with the latest |
Is there no official way to check if a driver supports JS or not? Using a try/catch for that is not exactly a clean way. Also wondering if this really should be an optional context, everyone will have to figure out then that this exists and add it to this project, should at least be documented then somehere. I'll also ping Wim Leers about this. |
From what I can tell, no. The JS drivers don't implement any additional interfaces or anything to differentiate themselves from the non-JS drivers... |
That's pretty unfortunate then, in my project I could obviously just check the actual driver class since I know what it is. Could we maybe somehow store this on a property or so so we don't have to throw and catch an exception for every single scenario? I guess it won't make a measurable difference The thing is that big pipe should be compatible with non-JS clients by redirecting them through a meta tag and then sets that cookie itself IIRC. But it looks like the driver doesn't support that. |
That'd be great! But I think catching
Correct. But if the driver doesn't support that, then it's violating one of the foundational features of web browsers: it doesn't respect Finally: when does Behat run the assertions? Does it wait for the |
I've merged the latest |
I opened FriendsOfPHP/Goutte#329 for the Goutte browser. |
In local testing, it would appear that the attempt to just set the cookie in a |
This PR was squashed before being merged into the 4.2-dev branch (closes #27118). Discussion ---------- [BrowserKit] Adds support for meta refresh | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27117 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> This adds support for following redirects defined by the `http-equiv=refresh` meta tag, such as ``` <meta http-equiv="Refresh" content="0; URL=http://example.com/somewhere"> ``` Additional background at jhedstrom/drupalextension#325 (comment) <!-- Write a short README entry for your feature/bugfix here (replace this comment block.) This will help people understand your PR and can be used as a start of the Doc PR. Additionally: - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch. --> Commits ------- 1c64c82 [BrowserKit] Adds support for meta refresh
We are definitely experiencing this a lot recently:
|
After applying the patch it solved a pretty mean issue for me. #258 (comment) |
Previously this didn't seem to resolve the issue (see my comments above regarding losing cookies on login), but if it's working for others, and we can get the tests passing, I'm all for this workaround until the fix in browserkit above makes its way into Mink, etc. |
Worth mentioning the patch results in an exception to be thrown on ┌─ @BeforeScenario # Drupal\DrupalExtension\Context\BigPipeContext::prepareBigPipeNoJsCookie()
│
╳ Fatal error: Class 'Drupal\big_pipe\Render\Placeholder\BigPipeStrategy' not found (Behat\Testwork\Call\Exception\FatalThrowableError) I'm actually quite surprised by that behavior. How smart this extension is that it won't load the class of a disabled module?! After re-enabling BigPipe it works just fine again. |
* | ||
* @BeforeScenario | ||
*/ | ||
public function prepareBigPipeNoJsCookie() |
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?
Thanks for this example @Berdir |
@vever001 can you post how you overrode the |
Sure, this is the context I added to the
|
@vever001 thanks, it's working! |
Hello, Edit:
I am writting (my almost first) Behat tests on a comment form for anonymous users and I wanted to test that after submitting the form, the approbation message is displayed and the admin receives an email. So I encountered this issue. I have not tested the code of this PR yet. #325 (comment) is not working for me because in my case, I am with an anonymous user. So I guess the And I have another problem, if I write a context in a module, either in I find out that for example Search API has a search_api.behat.inc file but I would really like to avoid .inc files. And no problem for a custom context inside a I can't find anything about that in the documentation. Thanks for any help. |
Hello, I add manually tested the new context. It fixed my usage. Thanks! Waiting for the PR to be merged when possible. |
{ | ||
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 comment
The 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 @BeforeScenario
)
#259 doesn't test messages for authenticated users. This follow-up PR should prove that messages work only for anonymous users.
In next commits to branch I will suggest how can we fix it (based on workaround proposed here: #258 (comment))