Problem/Motivation
This issue is part of #2974445: [Meta] Refactor Migrate Drupal UI Functional tests.
Currently, the base classes MigrateUpgradeTestBase and MigrateUpgradeExecuteTestBase define test methods, and these are customized by other methods that are overridden in the child classes. We want to move to a more common structure, where the base classes define assertion methods and other helper functions and the child classes define the tests.
This issue adds those assertion methods and other helper functions to MigrateUpgradeTestBase. Eventually, we plan to remove MigrateUpgradeExecuteTestBase.
Proposed resolution
Add helper methods to test
- IdConflictForm
- ReviewForm
Note that there are assertions in the old assertReviewPage()
regarding the source provider that are not moved to assertReviewForm()
. Those assertions are still done in MultilingualReviewPageTestBase and NoMultilingualReviewPageTestBase, so we have not lost test coverage. There is a new issue to create a separate test of the source provider: #3143721: Create a separate SourceProviderTest.
In addition,
- Move the
$destinationSiteVersion
property from MigrateUpgradeExecuteTestBase to MigrateUpgradeTestBase. - Add the helper function
assertUserLogIn()
.
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
Original report by [username]
Create methods for each form to do any assertions needed for that form.
Comment | File | Size | Author |
---|---|---|---|
#34 | 3143717-34.patch | 17.26 KB | quietone |
#34 | interdiff-31-34.txt | 1.12 KB | quietone |
#32 | 3143717-32.patch | 17.25 KB | quietone |
#32 | interdiff-26-32.txt | 14.42 KB | quietone |
#26 | 3143717-26.patch | 25.52 KB | quietone |
Comments
Comment #2
quietone CreditAttribution: quietone as a volunteer commentedComment #4
quietone CreditAttribution: quietone as a volunteer commentedComment #5
quietone CreditAttribution: quietone as a volunteer commentedRemove out of scope changes
Comment #6
quietone CreditAttribution: quietone as a volunteer commentedFix hard coded instance of 'Drupal 9'.
Comment #7
benjifisherI started looking at this patch. Here are some initial suggestions. I may have more when I re-review.
Let me add some lines of context to what I see in the patch:
Without looking at it too closely: if we are moving this property to the parent class, should we also move the lines in
setUp()
that set its value?Search for "assertIdConflict". It is used in an assertion message in this file. I have not checked other files.
Do we need an
@throw
annotation when an exception might be thrown indirectly (i.e., from a function that this function calls)? Do we need this function at all, or can we add the additional assertion toassertUpgradePaths()
? (I have not checked.) If we do need this function, then why not use$session
instead of$this->assertSession()
?It looks as though that last assertion is not replaced.
Comment #8
quietone CreditAttribution: quietone as a volunteer commented1. Yes, that makes sense. Done.
2. I don't think the message is needed so have removed it.
3. Adding the @throws PhpStorm to stop complaining. Passing $session and using it in all the helpers now.
4. Yes, this is another case where assertions are repeated in several tests. These assertions still exist in MultilingualReviewPageTestBase and NoMultilingualReviewPageTestBase and they will be moved to their own test in #3143721: Create a separate SourceProviderTest.
Comment #9
quietone CreditAttribution: quietone as a volunteer commentedUpdate IS with info from #8.4.
Comment #10
benjifisherThanks for making those changes. I have a few more suggestions.
Do we need two helper functions, where one does a single assertion and then calls the other? In other words, is there any harm in asserting "What will be upgraded?" every time we call
assertUpgradePaths()
?If the answers are "no", then I would like to add the assertion to
assertUpgradePaths()
and then rename it toassertReviewForm()
.Related: almost every time that
assertUpgradePaths()
is called, it looks like this:Can we make the two array arguments optional, using those methods as defaults? Maybe this change is out of scope for this issue, but if we do (1) then I think we can call it in scope.
The doc blocks are identical. The second function is called only once; like the first function, it is called immediately after
$this->drupalGet('/upgrade');
. The name of the second function is problematic, since it suggests that there is an Incremental form.I suggest that we solve all of these annoyances by adding an optional boolean parameter, perhaps
$is_incremental
, to the first of these functions and eliminate the second function. I think we can always test for "Upgrade a site …" and conditionally test for the second string.Is there a reason to use
responseContains()
instead ofpageTextContains()
? For HTML responses, they are equivalent, right?Is there any reason to vary from the pattern of the other short descriptions?
Again, do we need both methods? I searched for
assertMigrationResults()
, and it is not called except for here. Why not just add the assertion to that function?Comment #11
benjifisherFollow-up to #7.2: After applying the patch in #8, I still see the line
in MigrateUpgradeTestBase.
Comment #12
quietone CreditAttribution: quietone as a volunteer commented#10
1. Fixed
2. Yes, l let's do this.
3. Ah, there really is an Incremental form I have updated the summary line.
4. Oops. Fixed now.
5. Not really. Fixed.
#11. Should be fixed this time.
Comment #13
benjifisherThanks, the patch in #12 looks great! RTBC
I rewrote the issue summary using the standard template, in order to help the final review. The last couple of points might be considered out of scope; I made the issue title a little more generic in the hope that at least
assertUserLogIn()
will be considered in scope. If we want to avoid objections to the scope, we might preemptively revert the move of$destinationSiteVersion
until we remove MigrateUpgradeExecuteTestBase.Comment #14
benjifisherOops, I forgot to update the status.
Comment #15
quietone CreditAttribution: quietone as a volunteer commentedFYI, According to http://grep.xnddx.ru/ there are no usages MigrateUpgradeExecuteTestBase in contrib and two for MigrateUpgradeTestBase, migrate_media and migrate_upgrade.
Comment #17
benjifisherTwo unrelated tests are failing. (At least, I think they are unrelated.) I will ask the testbot to try again.
Comment #18
quietone CreditAttribution: quietone as a volunteer commentedTests passing again. Setting back to RTBC
Comment #19
quietone CreditAttribution: quietone as a volunteer commentedComment #20
quietone CreditAttribution: quietone as a volunteer commentedRerolled.
Comment #21
benjifisherThanks for the reroll! I see just one problem:
The patch in #12 removed the first
drupalGet()
line. After the patch in #20, that function is called twice.This reroll makes me think I was right to put off reviewing the other children of #2974445: [Meta] Refactor Migrate Drupal UI Functional tests until the first two are committed.
Comment #22
quietone CreditAttribution: quietone as a volunteer commentedThanks again. And yes, you were right to wait. Good planning.
Comment #23
benjifisherNice work. Back to RTBC.
Comment #24
quietone CreditAttribution: quietone as a volunteer commentedDidn't know this needed a reroll.
Comment #26
quietone CreditAttribution: quietone as a volunteer commentedOh dear, bad reroll. I wasn't paying attention and I forgot that #3134300: Simplify ReviewForm::buildForm() and the resulting markup was in.
Comment #27
quietone CreditAttribution: quietone as a volunteer commentedComment #28
benjifisherI compared (diff, not interdiff) the patches in #12 and #26. Aside from routine stuff (different line numbers and commit hashes, changes to context lines, etc.) the main difference was to change
span
totd
in CSS selectors: moved fromassertUpgradePaths()
toassertReviewForm()
. As you say, that change comes from #3134300: Simplify ReviewForm::buildForm() and the resulting markup.I then re-reviewed the patch as a whole, looking for reroll problems like the one I pointed out in #21. To make the review of MigrateUpgradeTestBase easier, I moved
assertReviewForm()
beforegetSourceBasePath()
so that I could compare it toassertUpgradePaths()
.I did not remember why the assertions in
assertReviewPage()
were not added to one of the new helper functions, but I see that we already discussed one of them in #7.4, and I see the otherpageTextNotContains()
lines are still repeated in MigrateUpgradeExecuteTestBase.Back to RTBC.
Comment #30
quietone CreditAttribution: quietone as a volunteer commentedThere was a random test failure, retested and tests are passing. Back to RTBC.
Comment #31
alexpottI'm not convinced this tiny assert methods are a good idea. The abstraction make tests harder to read, an extra thing to know about, an extra thing to maintain. DRY is not always correct - especially in tests. I guess it makes the UI easier to update BUT find/replace does exist. Plus as said below i really don't think we should be passing in $session if we do do this.
I don't think we should be passing $session into these methods because:
Yes other asserts added here do pass in $session already but two wrongs...
Comment #32
quietone CreditAttribution: quietone as a volunteer commented31.1 Removed the assert helpers, assertOverviewForm, assertIncrementalForm, and assertCredentialForm. For me, having these makes the test easier to read and work with but I am not going to argue the point.
31.2 Removed passing $session.
Comment #34
quietone CreditAttribution: quietone as a volunteer commentedI had a feeling I missed something.
Comment #35
quietone CreditAttribution: quietone as a volunteer commentedUpdate to IS to reflect changes due to #31.
Comment #36
benjifisher(facepalm) I was reviewing the patch from #32 and explaining the difference between
?:
and??
. The patch in #34 fixes that. I am glad that the testbot caught the difference, too: a sign that our test coverage is pretty good!I compared the patch in #34 to the one in #26. (Almost true.) It makes the changes requested in #31. As for whether or not the 1- or 2-line helper methods are useful, I will just check that they work. I defer to both @alexpott and @quietone on general testing strategy.
I also did a quick review of the patch in #34 as a whole. Most of it looks familiar. ;)
Looking at the changes to the issue summary, I am reminded that it already mentions some of the points that worried me a bit in #28. I also see that it now mentions "helper classes" instead of "helper functions". If that mistake were in the patch, I would have to send the issue back to NW, but I can fix the issue summary myself .
Back to RTBC.
Comment #37
alexpottCommitted b4dbfc1 and pushed to 9.1.x. Thanks!