Closed (fixed)
Project:
Panopoly
Version:
7.x-1.x-dev
Component:
Tests / Continuous Integration
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
7 Nov 2014 at 18:11 UTC
Updated:
12 Jun 2015 at 22:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dsnopekWhoa, this sounds amazing! I'd really love to be able to share some of the tests between the D7 and D8 versions of Panopoly - that way we won't break important things when we start creating the D8 version.
Comment #2
cboyden commentedComment #3
cboyden commentedThe basics are working, but the tests are running faster than CTools can render its modals. This is supposed to be handled by the AfterStep function. But for some reason, it doesn't run as a tagged hook. It only runs if you remove the @javascript tag.
If you remove the tag, the function throws an exception because it is expecting a Behat\Behat\Hook\Scope\AfterStepScope parameter, but we're sending a StepEvent parameter. It looks like we can't use this function in the same way.
Comment #4
cboyden commentedLooks like this is going to be the replacement for the afterStep function:
assuming we can get the tagged scenarios to work and add the @javascript tag.
Comment #5
cboyden commentedIt appears that BeforeStep and AfterStep hooks no longer work with tags? See https://github.com/Behat/docs/pull/55. So putting the @javascript tag in the @AfterStep annotation will cause it to be skipped.
If the untagged AfterStep hook, as currently coded, tries to run on a non-javascript scenario, it will throw an error.
This could be fixed if there were a way to check whether the parent scenario is tagged and act accordingly.
Comment #6
cboyden commentedOK, this is working for Javascript scenarios and not affecting non-Javascript scenarios:
Comment #7
dsnopek@cboyden: Can you post a "work in progress" patch? After talking so much about it, I'm super curious about how this all looks!
Comment #8
cboyden commentedI'll be working on this today, aiming for a patch in the afternoon.
Proposed architecture:
PanopolyContext includes all (and only) helper methods. No step definitions. That way it can safely be extended by all of the .inc files.
The inc files extend PanopolyContext. Each contains a set of related step definitions.
FeatureContext is empty and extends PanopolyContext.
Open questions:
What does PanopolyContext extend? RawDrupalContext or RawMinkContext? Either way, some helper methods may need to be added.
Should inc files containing steps related to a specific feature such as WYSIWYG be moved to that feature?
Comment #9
cboyden commentedPatch attached. There's a remaining issue on some of the "wait for live preview" steps.
Comment #10
cboyden commentedUpdated patch attached. Everything is passing locally.
There is one hitch remaining: Right now we are pointing our subcontext paths for discovery at profiles/panopoly/modules/. Because of where the panopoly_test module is located, this will include the vendor directory. As of the latest Behat Drupal extension, this will cause a fatal PHP error because an outdated documentation snippet is being discovered and parsed. See https://github.com/jhedstrom/drupalextension/issues/97.
We can't assume that this will be fixed in a way that won't still cause issues for us. So we should make sure to exclude the vendor directory from the subcontext include path. One way to do that would be to put the panopoly_test module into a different subdir from the rest of the Panopoly modules. A patch to drupal-org.make that does that is also attached. This would also require changes to travis-ci.sh - included in the patch.
Comment #11
cboyden commentedThe issue https://github.com/jhedstrom/drupalextension/issues/97 has been fixed by renaming the doc snippet. The patch to the distribution makefile is no longer needed - hiding it.
Comment #12
cboyden commentedHere's a new patch that updates to the Behat Drupal Extension 3.0.10. Notes on some changes:
Tests are passing locally. We'll see what Travis has to say: https://travis-ci.org/cboyden/panopoly/builds/63911476
Comment #13
cboyden commentedTravis of course needs some more changes. Environment variables now need to be JSON, and the behat.travis.yml file needs updating.
Comment #14
dsnopekWow! Thanks for continuing to push this forward. :-)
I haven't had a chance to test and review yet - I've only read your comments.
This makes sense to me. It will also signal to anyone that is currently extending PanopolyContext (ie. Open Atrium) that they can't do that anymore. :-)
Comment #15
cboyden commentedNeeded to adjust the way the BEHAT_PARAMS variable was set in the Travis script. New profile patch attached. Build is here: https://travis-ci.org/cboyden/panopoly/builds/63999010.
Comment #16
dsnopekI did some quick code review on the panopoly_test patch:
Why is this necessary? It feels like a step backwards. Can we get our custom step back?
Looks like debug code that snuck in.
Is the really necessary? It would be better to use the human-readable label than the machine one if possible.
Here a "When" is becoming "Then" - which actually I think Behat doesn't care. But it was better the old way.
This comment is intended for __construct() but is now for private $drupal.
Incorrect indentation.
Same as above!
Comment #17
dsnopekIck! What about doing some magic token replacement using sed?
So, something like:
It's still hacky, but at least easier to read. I haven't actually tested it, though. :-)
Comment #18
cboyden commentedAbout item 1: No, not really. The custom step "Given I am viewing a landing page" used the createNode function from DrupalContext, which is not available when extending RawDrupalContext. And we can't extend DrupalContext because we'll get every step in it throwing an "already defined" exception. So rather that rewriting that step definition in our code, I chose to use the built-in step. I'll see if there's an alternative that will allow us to use a one-liner in the scenario instead of a table.
Comment #19
dsnopekWell, we have the Drupal API! I wouldn't mind using it to programmatically create a new node, even if that's duplicating code that's already in the Behat Drupal extensions somewhere.
Comment #20
cboyden commentedI disagree, I think we create ourselves more work, especially since: a) now a landing page is just another node type; and b) when we start testing Drupal 8 we'll have to recreate all of our custom steps for that. I'd rather use the built-in steps when they're available, and even push some of our custom steps (managed file comes to mind) back into the Behat Drupal Extension, or into Panels and other modules, so they can be of broader use.
Comment #21
cboyden commentedOr, it could be possible to implement communication between contexts as outlined here: http://docs.behat.org/en/latest/cookbooks/context_communication.html
That way the custom Given should be able to call createNode.
Comment #22
cboyden commentedPart of the problem with the Live Preview test appears to be that config fields for different widget types have different IDs, and labels. Some examples are:
This is probably due to differences between Views widgets and FPP widgets.
Also there could be timing issues at work here. Maybe the "wait for javascript" function isn't sufficient to detect the changes to the fields, and the test is getting ahead of itself.
Here's a new patch that addresses some issues from comment #16 (2,4,5,6, and 7), and also attempts to fix the Live Preview test failures.
Comment #23
cboyden commentedHere also is a new patch using the approach to BEHAT_PARAMS suggested by @dsnopek. Travis build with this and the test patch above: https://travis-ci.org/cboyden/panopoly/builds/64035090
Comment #24
cboyden commentedSome of the live preview scenarios are failing consistently every time on Travis - but not all of them. It could be one of several reasons:
Or maybe there are other possibilities.
This is all passing locally. Without being able to see what's happening on the screen at each step, I'm not sure how to get this working.
Is there a way to force live preview to update?
Comment #25
dsnopekThanks, @cboyden! I'm going to looking into using the "context communication" link you sent to implement "I am viewing a landing page" and see if I can figure out the live preview issues.
Comment #26
dsnopekHere is a new (with interdiff!) which brings back the "I am viewing a landing page" step and my first attempt at getting the livepreview.feature tests to work (I'll run on Travis in a moment). I also made a couple of minor spacing fixes and little nit picky things. :-)
EDIT: Here is the Travis build: https://travis-ci.org/dsnopek/panopoly/builds/64093276
Comment #27
dsnopekHeh, so that last build didn't work, but then for the hell of it I tried upgrading Selenium and that appears to have fixed it:
https://travis-ci.org/dsnopek/panopoly/builds/64096172
When that was running I wrote a step for debugging that would let us do:
So, here's a new panopoly_test patch that only adds that step definition, because it could be useful in the future. And a new profile patch that updates Selenium to 2.45 (from 2.41).
Remaining things I'd like to do while I'm at it:
Comment #28
dsnopekHere is a new patch which does the conversion to Turnip syntax and the following clean-up:
I haven't run the full test suite with these changes - I'm going to get Travis to do that for me.
EDIT: Here is the Travis build: https://travis-ci.org/dsnopek/panopoly/builds/64113509
Next I'm going to attempt to kill PanopolyContext and move its code into panopoly_test_fpp.behat.inc and panopoly_test.behat.inc.
Comment #29
cboyden commentedThe test passed, but it's reporting a step as undefined: "And I select the first autocomplete option...", which is in the content item widget scenario.
Comment #30
dsnopekThe last patch passed on Travis! Here's another one that kills PanopolyContext and move its code into panopoly_test_fpp.behat.inc and panopoly_test.behat.inc. This is basically the files and FPP clean-up stuff, which I've tested as working locally.
EDIT: Here's the build on Travis: https://travis-ci.org/dsnopek/panopoly/builds/64121942
Comment #31
dsnopekAh, thanks, I missed that! I'll fix in my next patch.
Comment #32
dsnopekThis patch just fixes the undefined autocomplete step from #29.
EDIT: Here's the Travis build: https://travis-ci.org/dsnopek/panopoly/builds/64122813
Comment #33
dsnopekAlright, here is what might be my last patch for the day. I've removed the "wait" steps that were added in the original conversion - they hopefully shouldn't be necessary after my changes to the Javascript used to wait for AJAX. I was able to test all but one of them, because of issues with my local environment. But Travis will be the real test!
EDIT: Here is the build on Travis: https://travis-ci.org/dsnopek/panopoly/builds/64125589
Comment #34
dsnopekWell, there was one "wait" step that appears to have been necessary afterall (the one I couldn't test, of course!) and some PHP errors in the files/fpp clean-up code if the Scenario doesn't create any users. This patch should fix both things!
EDIT: Here's the Travis build: https://travis-ci.org/dsnopek/panopoly/builds/64136281
Comment #35
dsnopekAnd here is a patch that does some clean up on the behat.*.yml files. Assuming the tests pass, then this will be all the changes I have pending to make!
Next thing we need to take a look at the Behat documentation and see if it needs any updates...
EDIT: Here's the Travis build: https://travis-ci.org/dsnopek/panopoly/builds/64141591
Comment #36
dsnopekThe build for #34 passed! Still waiting on #35, but I really don't expect it to fail (famous last words).
I've already updated the documentation! It needed only super small changes, mostly for examples of behat.yml files or *.features that were out-of-date.
So, unassigning from me so this can get some review!
Comment #37
cboyden commentedRuntime is creeping up again, particularly in the Firefox scenarios. Is there something we can do to the "wait for Ajax" or "wait for live preview" functions to speed them up?
Comment #38
dsnopekMaybe, but that would need its own investigation. So long as we're not significantly slower than with Behat 2, I'd rather not hold this up and work on performance in a follow up issue.
Comment #39
cboyden commentedWhen running the tests locally, I'm getting some failures:
advanced_widgets only failed the once. basic_ipe fails every time (the "Phelan" link isn't available when the test tries to click it). contentitem_widget fails occasionally, sometimes in different places. livepreview also fails regularly, sometimes in different places.
These are all timing issues. Some places that are prone to failure are when saving the page after having saved a pane update, when waiting for the "customize" button to appear on a new landing page, or when waiting for live preview to finish.
Comment #40
dsnopekHmm, weird! All those tests pass for me locally. What versions of Firefox, Selenium and PHP are you running? Since Travis had timing issues with an older Selenium, that's my best guess at the moment.
Since it works for me locally and on Travis, I'm not sure if I'll be able to help debug... :-/
Comment #41
cboyden commentedThis is in behat.common - does it need to be here? Should it be removed from behat.common?
As above in behat.template.
Maybe this could be shortened. It's one of the common timing failure points, so I don't think it can be removed entirely.
As above for the too-small scenario.
This was because I couldn't figure out how to send in escaped characters like \n.
Ideally this would go into the Drupal extension, it's one of a piece with all of the other steps in MarkupContext. But it's fine here for now.
The trailing $/ is left over from a regex and can be removed.
Comment #42
cboyden commentedI'm on Selenium 2.44. There were some issues between Firefox and Selenium a while back, so I had to keep an older version of Firefox around just for testing. It sounds like those must have been resolved. I'll try updating both.
Edit: Basic IPE test is no longer failing, but I'm still getting occasional failures on live preview and content item widget. This is with Selenium 2.45, Firefox 38, PHP 5.4.38 on the command line and 5.4.8 on the server.
Comment #43
dsnopek@cboyden: Thanks for the review! :-)
#41.1/2: Ah, good catch, thanks! My intention was to remove that from behat.common.yml. If you do fun things with symlinks or keep two copies of the modules in both "profiles/panopoly" and "sites/all/modules" this is something that needs to be customized, and this came up at the DrupalCon sprint. Having it in the behat.yml rather than behat.common.yml will make that easier to notice and explain. Anyway, fixed!
#41.3/4: Right, this "wait" step was the one I couldn't remove. Trying at 2 seconds, instead of 5.
#41.5: Yeah, and I was OK with that solution. But looking into it more, I found @Transform which can handle this! I was able to use it to restore the escaped quotes in wysiwyg_media.feature as well.
#41.6: I concur! Here's a follow-up for looking at Behat steps we can move upstream: #2495739: Evaluate custom Behat steps and move them upstream
#41.7: Fixed!
EDIT: Here's the build on Travis: https://travis-ci.org/dsnopek/panopoly/builds/64250159
Comment #44
dsnopekThe last build on Travis failed:
bin/behat -dlas it's easier to read, but I'll just remove it in the next patch.Comment #45
dsnopekHere's an attempt to fix the issues outlined in #44. I removed the "wait" steps entirely to see if the AJAX waiting triggers.
EDIT: Here is the Travis build: https://travis-ci.org/dsnopek/panopoly/builds/64261195
Comment #46
dsnopekThe last Travis build passed! So, now there are pratically no changes to the *.feature files! Thanks for the review @cboyden, because now this patch is even better. :-)
Marking as "Needs review" for any additional review/testing.
Comment #47
dsnopekHere's a new patch that gets rid of the inter-context communication for implementing the "I am viewing a landing page" step. It turns out that is totally unnecessary because RawDrupalContext has the
nodeCreate()function which does all the magic! And by removing the dependency on DrupalContext, it's possible for a test suite to extend and replace it, which I just found a use case for on a child distribution.EDIT: Here is the Travis build: https://travis-ci.org/dsnopek/panopoly/builds/64284977
Comment #48
cboyden commentedThis is looking good! I'm still getting timing-related failures on the content item widget and live preview features, but since they're running OK on Travis, we could probably chalk that up to local gremlins and move forward with this. If they weren't occasionally failing in different places, I might say we should add a "wait" step.
Comment #49
dsnopek@cboyden: And you tried updating your Firefox and Selenium to the latest stable versions?
Anyway, I'm happy to move forward and commit this. :-) I'll do it tomorrow if there are no objections!
Comment #50
dsnopekCommitted!
Comment #52
cboyden commentedYes, I'm on Selenium 2.45 and Firefox 38.0.1.
Comment #53
dsnopekHrm. I guess we'll see as others try running the tests after this update and see who else can reproduce. This might be something I'll have to try and figure out next time there's a sprint and someone has got a Mac. :-)
Comment #54
cboyden commentedI've run the problematic tests on Chrome a few times, and it seems to go much better. No failures yet on contentitem or livepreview.