Closed (duplicate)
Project:
Drupal core
Version:
8.0.x-dev
Component:
simpletest.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
12 Dec 2008 at 05:37 UTC
Updated:
23 Mar 2015 at 17:56 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
beginner commented#ahah is part of Drupal's Form API.
There ought to be a way to test it.
Comment #2
calebgilbert commentedSelenium has a robust api for testing AHAH/JS/AJAX. I've written an article with accompanying screencast about using Selenium on a Drupal site.
Interestingly enough, Simpletest's own documentation encourages people to look elsewhere for testing AHAH/JS/AJAX (bottom of page):
Comment #3
damien tournoud commentedHere is a first patch to test AHAH replacements.
We implement the drupalAHAH() that simulate AHAH replacement in our SimpleTest internal browser.
Completely untested at this point.
Comment #4
damien tournoud commentedOh, and this depends on #348634: Ease AHAH testing: allow direct posting.
Comment #6
damien tournoud commentedThis is the first working patch. It still depends on #348634: Ease AHAH testing: allow direct posting.
The API for AHAH testing is very simple. Simply call $this->drupalAHAH() with the label of the button you want to activate (this will require some light refactoring to allow other types of widgets to be tested):
drupalAHAH() does everything for you: identifying where to perform the request, loading the JSON and replacing the correct DOM node. If drupalAHAH(), the content of the internal browser is changed, and you can perform assertion on it, or even using drupalPost() if you want.
Comment #7
damien tournoud commentedNew version of the same patch, now with an extended API (and slightly less kitten killed in the process).
You know have to pass an element ID to drupalAHAH(). The benefit of this is that it now works with every element type. So if I have:
I will call:
And enjoy dynamic AHAH replacement in SimpleTest :)
Comment #9
dmitrig01 commentedYou have this:
<div id="ahah5_external"><div id="ahah5_internal">original content</div></div>Only one id per page - they are unique.
Dmitri
Comment #10
beginner commentedRe #9: Those are different IDs. one says: external, the other says: internal.
Comment #11
damien tournoud commentedThis is a merge of #348634: Ease AHAH testing: allow direct posting with this patch.
Comment #12
damien tournoud commentedTook care of some comments by Dries in #348634: Ease AHAH testing: allow direct posting:
Exactly, clarified.
That's a bit kitten killing, but I renamed this to drupalSetResponse(), fixed and updated the PHPDoc accordingly.
Agreed. Fixed.
This is because drupalPostDirect() bypass the internal browser completely. I updated the PHPDoc to clarify this.
Comment #13
damien tournoud commentedForgot to merge the other uses of drupalSetContent().
Comment #14
damien tournoud commentedAnd fixed the patch description.
Comment #15
damien tournoud commentedRerolled. Ran the test suite manually on this, 100% pass.
Comment #17
damien tournoud commentedRerolled following the node/8 patch.
Comment #18
damien tournoud commentedExtracted the renaming of SimpleTestTestCase in a separate issue (#357595: Rename SimpleTestTestCase to SimpleTestFunctionalTest).
Comment #20
damien tournoud commentedFree reroll.
Comment #21
damien tournoud commentedComment #23
wim leersSubscribing.
Comment #24
boombatower commentedI would really like to see #340283: Abstract SimpleTest browser in to its own object get in and integrated with SimpleTest then make the changes to it.
Comment #25
rfayOK, so now #340283: Abstract SimpleTest browser in to its own object is in. Can we get this in?
Comment #26
rfayLet's have BOF about this subject at Drupalcon Paris. This is terribly important stuff: Drupal depends on javascript, and we're not testing any behaviors that involve JS. For example, HEAD was broken day before yesterday because a new JS piece was introduced that broke install.php. Our automated test framework did not tell us this, because there's no JS piece.
Imitating or simulating JS is not really adequate, although it's something. Unfortunately, when the JS changes (as it will) the test breaks. Since we aim to test the code, not code to the test, this really isn't right. Let's take a look at Selenium, let's talk about what has to be done here.
#237566: Automated JavaScript unit testing framework proposes an automated JS test framework. I'll note the idea of a BOF there too.
Comment #27
rfayThere is some nice work going on to support Javascript testing #237566: Automated JavaScript unit testing framework. Reviews there are welcome. With a little more progress we may be able to do functional testing, allowing us to test #ajax.
Comment #28
boombatower commentedI discussed this with webchick and we decided the best approach was to test the autocomplete widget generically (once) through js testing framework and test all the callbacks and such through SimpleTest since it has access to the data and can easily parse json.
Other areas of js testing like proper AHAH form building and such will need to wait until we have the proper environment separation for functional testing, which will be a followup to #237566: Automated JavaScript unit testing framework.
Comment #29
rfayComment #30
rfayIf you're interested in this one you may be interested in:
#825436: Create selenium-RC PIFR plugin for full functional testing
and
#789186: Improve drupalPostAJAX() to be used more easily, leading to better AJAX test coverage
Comment #31
nod_just putting the right name, not called ahah for a few years now :)
Comment #32
nod_We want to test ajax stuff, but not by messing with our API too much, by using behat #2232271: [Meta] Use Behat for validation testing.