-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add fxa/sync integration tests #5633
Add fxa/sync integration tests #5633
Conversation
@rpappalax, @npark-mozilla once the checks are green I would like to ask you to take a first look at the changes in this PR about adding the sync integration tests. |
@@ -0,0 +1 @@ | |||
pytest-28f90ad8b4@restmail.net |
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.
Note that this is not a permanent account, while running the tests via pipenv run pytest
a new account will be created, written in this file and read after that for the test to be used to sync in Fenix app.
Same for the password below.
@@ -33,6 +33,9 @@ gcloud: | |||
- /sdcard/screenshots | |||
performance-metrics: true | |||
|
|||
test-targets: |
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.
Adding this line and below we avoid running these sync integration tests as part as the regular UI tests.
import mozilla.components.service.fretboard.ExperimentDescriptor | ||
|
||
const val EXPERIMENTS_JSON_FILENAME = "experiments.json" | ||
const val EXPERIMENTS_BASE_URL = "https://firefox.settings.services.mozilla.com/v1" |
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.
this looks like a production server. Is that intentional for this test?
import mozilla.components.service.fxa.ServerConfig | ||
|
||
object FxaServer { | ||
const val CLIENT_ID = "a2270f727f45f648" |
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.
will this CLIENT_ID also be replaced by a dynamic one? (same as: https://github.com/mozilla-mobile/fenix/pull/5633/files/b6603729b13964d8f52aa06342a74601f2bf6cd3#r329536741)? It's OK to hard code these if necessary, but it would be more brittle. Esp. on the stage server
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.
This implementation is similar, using same CLIENT_ID for the non test part, the regular FxaServer.kt. But I can check if this can be changed
pytest-fxa = "*" | ||
pytest-html = "*" | ||
pytest-metadata = "*" | ||
requests = "*" |
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.
do you not want to pin down these version numbers for stability?
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 have had this for the iOS tests for long time and did not face any stability issues...but if you prefer I change that, I can look into that.
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.
Pipfile.lock is checked in, which should pin down dependency versions already.
fun checkBookmarkFromDesktopTest() { | ||
signInFxSync() | ||
tapReturnToPreviousApp() | ||
sleep(5000) |
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 imagine you're going to refine this later, but I recommend creating a constant for this in the helpers. We currently have a few wait times defined in https://github.com/mozilla-mobile/fenix/blob/master/app/src/androidTest/java/org/mozilla/fenix/helpers/TestAssetHelper.kt which was created for Mock server assets / functions. With my next PR, I'll be adding a more generic https://github.com/mozilla-mobile/fenix/blob/master/app/src/androidTest/java/org/mozilla/fenix/helpers/TestHelper.kt which would be for misc functions and constants. We could eventually migrate our constants there.
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.
Yes, these tests, except for the first one are commented out at the moment and will need a little bit of work once the environment is set up and the first test is constantly passing. I just drafted them to have an idea about how the test suite will look like.
fun checkHistoryFromDeviceTest() { | ||
tapInToolBar() | ||
typeInToolBar() | ||
sleep(3000) |
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.
see above comment
val emailInput = mDevice.findObject(UiSelector() | ||
.instance(0) | ||
.className(EditText::class.java)) | ||
emailInput.waitForExists(1000) |
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.
see above
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 will change that to use the constant in helpers. Sorry I forgot about that.
tapReturnToPreviousApp() | ||
homeScreen { | ||
}.openThreeDotMenu {} | ||
libraryButton() |
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.
this is just a style preference, but I put these methods inside the bracket of openThreeDotMenu
to show that these actions are happening within the three dot menu dialog. For me it's more easier to read.
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.
Oh right, when I created this PR those options were not added to the robot menu yet, so I added functions at the end of the test. I will replace them with the actions from robot!
val signInButton = mDevice.findObject(UiSelector() | ||
.instance(0) | ||
.className(Button::class.java)) | ||
signInButton.waitForExists(10000) |
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.
use constants
|
||
fun tapOnContinueButton() { | ||
val continueButton = mDevice.findObject(By.res("submit-btn")) | ||
continueButton.clickAndWait(Until.newWindow(), 50000) |
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.
use constants
fun tapOnSygIn() { | ||
mDevice.pressEnter() | ||
mDevice.wait(Until.findObjects(By.text("Sign in")), 3000) | ||
val signInButton = mDevice.findObject(UiSelector() |
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.
use constants
fun redirectUrl(context: Context) = if (context.isInExperiment(Experiments.asFeatureWebChannelsDisabled)) { | ||
REDIRECT_URL | ||
} else { | ||
"urn:ietf:wg:oauth:2.0:oob:oauth-redirect-webchannel" |
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.
should we put this as a constant?
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.
other than minor style suggestion, LGTM
Codecov Report
@@ Coverage Diff @@
## master #5633 +/- ##
============================================
+ Coverage 14.36% 14.37% +0.01%
- Complexity 322 326 +4
============================================
Files 257 258 +1
Lines 10539 10543 +4
Branches 1538 1537 -1
============================================
+ Hits 1514 1516 +2
- Misses 8899 8901 +2
Partials 126 126
Continue to review full report at Codecov.
|
55a641d
to
edb879c
Compare
edb879c
to
26350d4
Compare
@csadilek asking for your review since you are familiar with all the changes at least for a first deep look..thanks! |
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.
Looks good! Just some nits (missing license headers, some KDocs) to address before landing. Thanks for moving this forward!
@@ -0,0 +1,21 @@ | |||
package org.mozilla.fenix.components |
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 need a license header here :).
import mozilla.components.service.fxa.ServerConfig | ||
import org.mozilla.fenix.Experiments | ||
import org.mozilla.fenix.isInExperiment | ||
|
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.
Let's add some KDocs here e.g.
/**
* Utility to configure Firefox Account servers.
*/
@@ -0,0 +1,26 @@ | |||
### Sync Integration Tests |
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.
Thanks for writing these docs!
@@ -0,0 +1,17 @@ | |||
package org.mozilla.fenix.components |
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 forgot the license header.
import android.content.Context | ||
import mozilla.components.service.fxa.ServerConfig | ||
|
||
object FxaServer { |
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.
Let's add some KDocs, see my comment below.
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.
This is really neat. How do you ensure that FxA signin verification won't be necessary during a test?
pytest-fxa = "*" | ||
pytest-html = "*" | ||
pytest-metadata = "*" | ||
requests = "*" |
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.
Pipfile.lock is checked in, which should pin down dependency versions already.
|
||
fun Context.isInExperiment(descriptor: ExperimentDescriptor): Boolean = | ||
if (descriptor.name == "asFeatureWebChannelsDisabled") | ||
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.
The only reason webchannel stuff didn't work is because we didn't whitelist stage FxA server in the webchannel extension manifest file. We certainly do want these tests to exercise webchannel flow, since that's the flow we ship by default. This can be an easy follow-up PR though.
passwordInput.setText(passwordValue) | ||
} | ||
|
||
fun tapOnSygIn() { |
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.
nit: typo?
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.
Right! 🙈
@@ -50,10 +50,10 @@ class BackgroundServicesTest { | |||
val context = mockk<Context>(relaxed = true) | |||
|
|||
every { context.isInExperiment(eq(Experiments.asFeatureWebChannelsDisabled)) } returns false | |||
assertEquals("urn:ietf:wg:oauth:2.0:oob:oauth-redirect-webchannel", BackgroundServices.redirectUrl(context)) | |||
// assertEquals("urn:ietf:wg:oauth:2.0:oob:oauth-redirect-webchannel", BackgroundServices.redirectUrl(context)) |
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.
This seems wrong. Why did you need to disable these tests?
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.
Ah this was likely because redirectUrl
is no longer a function on BackgroundServices
. Didn't notice this was commented out. So, we can change that to FxaServer.redirectUrl(context)
now and it should work again.
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.
Oh, sorry about that I commented it so that building on TC did not complain and forgot to fix. Fixing...
The verification happens after the account is created with fxacli tool in
In the logs you can see something as:
When the test finishes, the account is removed. |
5159d43
to
7077d34
Compare
fixing Jenkins path to tests and clean tests commenting future tests and adding doc with info about the tests
improve writing email and password in file
7077d34
to
0e3148f
Compare
Is this ready to land? This PR has been up and approved for a while. Want to make sure I don't merge it before all nits have been addressed though. |
@sblatz yes, it should be ready, but if you want me to double check with one (or more) reviewers, let me know... |
@grigoryk I replied to your question but did not mention you so not sure if you read it and that answers your question...Thanks! |
Hi @sblatz , what's that bors expected? Should I do something before merging? |
bors r=csadilek |
5633: Add fxa/sync integration tests r=csadilek a=isabelrios Pull Request checklist <!-- Before submitting the PR, please address each item --> - [x] **Quality**: This PR builds and passes detekt/ktlint checks (A pre-push hook is recommended) - [x] **Tests**: This PR includes thorough tests or an explanation of why it does not - [-] **Screenshots**: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not - [-] **Accessibility**: The code in this PR follows [accessibility best practices](https://github.com/mozilla-mobile/shared-docs/blob/master/android/accessibility_guide.md) or does not include any user facing features This PR tries to add new tests, sync integration tests, to check the sync process Desktop<->Fenix, first for Bookmarks and in the future for more. Co-authored-by: Isabel Rios <isabelrios@mackbookirios.home> Co-authored-by: isabelrios <isabelrios@gmail.com>
Build succeeded
|
Pull Request checklist
This PR tries to add new tests, sync integration tests, to check the sync process Desktop<->Fenix, first for Bookmarks and in the future for more.