Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
We should improve the internal documentation.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#30 | interdiff.txt | 2.16 KB | Gábor Hojtsy |
#30 | 2810621-30.patch | 4.79 KB | Gábor Hojtsy |
#22 | 2810621-22.patch | 4.39 KB | Gábor Hojtsy |
#11 | interdiff.txt | 2.06 KB | Gábor Hojtsy |
#8 | interdiff.txt | 2.46 KB | Gábor Hojtsy |
Comments
Comment #2
dawehnerHere is a quick start
Comment #3
jhodgdonI will read this later in detail, probably... nitpick: the correct capitalization: JavaScript
Comment #4
dawehnerJust some small nitpicks
Comment #5
jhodgdonHi, back from vacation...
This is a pretty good start. I took a look at the text and have some proofreading suggestions... if you want to do some rewriting I think that would be a good idea. In a few days when I get done with more of the mounds of other tasks that have accumulated in my 3 weeks off, I may have time to rewrite also...
Meanwhile, here is a nitpicky review:
Rewrite of this first sentence:
Functional tests are written using the BrowserTestBase base class, and use PHPUnit as their underlying framework. They use a simulated browser, in which the test can click links, visit URLs, post to forms, etc.
Take out "You need to"
I'm not sure what this means and how it relates to extending BrowserTestBase?
This is a bit garbled... and should it be two bullet points (one about the folder and namespace, and one about the @group)?
Also use the word "directory" not "folder" as a general rule in Drupal docs
==> which can be used
[take out word "set" near end of line]
==>
provide functional test coverage for this, Drupal provides...
Is this the correct namespace?
The end of this sentence is garbled
ajax => Ajax
Comment #6
Gábor Hojtsy@jhodgdon: took all your input and updated the docs with that. Also carried some of the info to https://www.drupal.org/node/2716803. There is an interdiff, but not much clearer than just reading the new patch ;)
Comment #7
Wim Leerss/phpunit/PHPUnit/
functional PHP
functional JavaScript
Should this say "But don't forget to call the parent method."?
s/under/in/
s/phantomjs/PhantomJS/
s/behaviour/behavior/ :)
Comment #8
Gábor HojtsyUpdated for everything but 3.
I contest 3, because the modules would not be directly put *in* that directory I think but rather in directories *under* that directory, no?
Comment #9
Wim Leers#8: I think a native speaker should look at this — I honestly don't know :) I'm just used to reading
, not .Comment #10
jhodgdonI agree with Gabor -- I would say "under", because ... well... actually I think I would say that each test module would go in its own subdirectory of yourmodule/tests/modules.
Some other thoughts:
invoke => call
grammar: "works really similar" is not really quite right.
I think I would actually rewrite this whole sentence to only say:
To write a functional test that relies on JavaScript:
(because the first bullet point already says to use this JavascriptTestBase class)
To be similar to the above section, this should say:
Place the test in the yourmodule/tests/src/FunctionalJavascript directory ...
end in .
; not , before see.
Also... the readme.md file doesn't actually explain how to *set up* PhantomJS. It only includes a command for starting it. So maybe give a link to more information about PhantomJS?
Comment #11
Gábor HojtsyGreat comments :) I was not sure setting up phantomjs is just about downloading it, but https://www.drupal.org/node/2716803 also just links there, so I think we can do that too. Fixed all the concerns raised.
Comment #12
jhodgdonThe documentation reads very well now, IMO.
I cannot really review it for accuracy though... so I hesitate to mark it RTBC.
Comment #13
klausiLooks good!
Minor things that should not hold up this patch:
Over 80 characters, but this probably has to be on one line. I would just call it write_functional_js.
Should we correctly capitalize PHPUnit everywhere?
The important part here is that you never wait blindly a certain amount of milli seconds but always have a JS condition attached to it. assertWaitOnAjaxRequest() already does that for you, but if you want to test a non-Ajax user interaction on the page you will use $this->getSession()->wait(). Always use a JS condition as the second parameter there, for example to check if something is visible after triggering the JS interaction.
But maybe that is too detailed for this section here? Should not hold up this patch.
Comment #14
xjmThis is a huge improvement!
We can replace the words "are written using" here with "extend".
Missing leading slash here.
I think the comma here is incorrect and makes the sentence confusing. To make it clearer, let's flip the sentence around:
This sentence is a bit of a run-on. Let's start a new sentence with "Each one runs in a new..." and instead say "Each method runs in a new..."
Do we really need to tell people that "A lot of functionality relies on JavaScript"?
We can remove the words "you need to" here.
I'd suggest "might take time" instead of "might need a while".
Instead of "for that" maybe "for the Ajax request to finish"?
Comment #15
xjm(Fixing issue credit.)
Comment #16
dawehnerWorking on it.
Comment #17
dawehnerComment #18
Wim Leers#17 addressed everything in #14, except point 9. It also did a little bit extra. One mistake was made though:
This now has a trailing slash, but it needed a trailing slash :D
Comment #19
Gábor HojtsyIs there a full docs page other than https://www.drupal.org/node/2716803 and https://www.drupal.org/node/2469723 (both change notices)?
Comment #20
klausiDoc pages:
https://www.drupal.org/docs/8/phpunit
https://www.drupal.org/docs/8/phpunit/running-phpunit-tests
https://www.drupal.org/docs/8/phpunit/phpunit-browser-test-tutorial
Currently missing is a JavascriptTestBase setup + tutorial.
Comment #21
klausiImproving the last bits of this issue is a novice task.
Comment #22
Gábor HojtsyTook this because I think solving this soon is important for the understandability of this system.
Fixed the slash found by @wimleers.
Added a link to the PHPUnit tutorial. The parent page is already linked in the PHPUnit section so no point in linking it here (again).
Anything else?
Comment #23
klausiThanks, looks good!
Comment #24
xjmThese are still missing the leading slash, and still have a trailing slash that they should not.
The formatting here is weird (why a single-element list?) and we should use @link/@endlink instead. I guess it is being copied from elsewhere in the class?
I guess point 2 is repeating a pattern from elsewhere but point 1 (which is also #14.2) is still not addressed.
Thanks!
Comment #25
xjmAlso, I do think it is worth repeating links from the previous section, since we should not assume people have read the entire thing if they only want to write a browser test; and also referencing handbook resources for writing and running the JSTB tests (even if we just add a stub for now that links the CR and alexpott's blog post or whatever).
Comment #26
dawehnerSure, let's get someone to improve it.
Comment #27
xjmGood idea @dawehner.
Comment #28
jhodgdon@link/@endlink should only be used if you want to have link text. Otherwise, just putting the URL in alone is good. Agreed that a one-item list is silly though! :)
Comment #29
Gábor HojtsyAll right, I created a page at https://www.drupal.org/docs/8/phpunit/phpunit-javascript-testing-tutorial where I copied the change notice from https://www.drupal.org/node/2716803. I personally believe that an inviting empty stub is more harmful than not having anything there at all. This is at least marked incomplete so people MAY help update it. Still don't think creating that page was novice and it was required to fix @xjm's concerns.
Comment #30
Gábor Hojtsy- Updating the namespaces as suggested (there are several other namespaces documented in this file without a leading slash but those are out of scope for the patch).
- Repeated the phpunit general docs link as suggested by @xjm.
- Added a link to the newly existing JS testing doc page.
Comment #31
dawehnerThank you @Gábor Hojtsy for the improvements! I strongly believe getting the information out rather sooner than later is helpful. We can and should improve continuously.
Comment #32
alexpottNice.
Committed and pushed ea1bc99 to 8.3.x and 8ab9f5c to 8.2.x. Thanks!