This issue has been seen as part of the WIP to create sync integration tests Fenix <-> Desktop
https://github.com/mozilla-mobile/fenix/issues/4023#issue-467375928
Set stage as the default browser
Sign in with an stage account created with fxacli tool https://pypi.org/project/fxacli/
Wait until the syncing process finishes to check the bookmark/history
Bookmarks and History items are synchronized correctly
The sing in process seems to be fine but the syncing process does not start. The Connectedscreen below is never closed automatically

And if you close it by going back or tapping on 'x' button, you have to enter email/password to sign in again
Please see https://github.com/mozilla-mobile/fenix/issues/4023#issuecomment-517364646 with more information and logs
Adding people cced in previous bug: cc @vladikoff @jrgm @grigoryk
I was wondering if you @vladikoff @grigoryk had a chance to look at this.
This is still happening and so although we have the tests and the environment for the sync integration tests ready (you can see this doc for more info), they will fail.
Thank you in advance!
@isabelrios do you have a branch or a diff of Fenix that you use to login to stage?
@vladikoff yes, all the work is in this branch in my fork.
@isabelrios this diff works for me off master branch:
diff --git a/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt b/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt
index aacabc5c..df2ed7cc 100644
--- a/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt
+++ b/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt
@@ -55,7 +55,7 @@ class BackgroundServices(
) {
companion object {
const val CLIENT_ID = "a2270f727f45f648"
- const val REDIRECT_URL = "https://accounts.firefox.com/oauth/success/$CLIENT_ID"
+ const val REDIRECT_URL = "https://accounts.stage.mozaws.net/oauth/success/$CLIENT_ID"
}
fun defaultDeviceName(context: Context): String = context.getString(
@@ -65,7 +65,7 @@ class BackgroundServices(
Build.MODEL
)
- private val serverConfig = ServerConfig.release(CLIENT_ID, REDIRECT_URL)
+ private val serverConfig = ServerConfig("https://accounts.stage.mozaws.net", CLIENT_ID, REDIRECT_URL)
private val deviceConfig = DeviceConfig(
name = defaultDeviceName(context),
type = DeviceType.MOBILE,
I can login and sync
Hey @vladikoff thanks for checking this issue! yes, you are right, if you do that change on master everything works. But, we can't do this that way...we need a way to change the server only for running the tests otherwise the app will always use stage. We (thanks to @csadilek ) have explored different solutions:
1- Use a pref for the tests to use stage (see commit). This worked temporarly but after some changes in the app it was too late to set the pref because the accountManager is now always created in Application.onCreate so the server was not changed.
2- Introduce a FxaConfig object which is different for UI tests. You can see the changes in this commit. This is working expect for the final sync reported here.
So, we are using the second approach. Unfortunately something may be missing or incorrectly set since we are seeing this issue with that implementation.
If you think there is a better approach to use stage/production server depending on how the app is used (regular use or for the tests) please let me know! Thanks!
For all the info related to these tests you can check this doc
cc @npark-mozilla (FYi)
Let me share here the new findings about this issue.
The configuration in androidTest/java/org/mozilla/fenix/components/FxaServer.kt does not seem to be working perfectly fine to set stage server for the tests. The test starts correctly and the server used is stage but the sync process never finishes successfully, hanging in the screen reported.
If in main/java/org/mozilla/fenix/components/FxaServer.kt which currently sets the prod server, we modify the REDIRECT_URL as "https://accounts.stage.mozaws.net/oauth/success/$CLIENT_ID" to use stage, then the test works perfectly. The sync process finishes and the history items are synced and shown fine.
Looks like the configuration for the tests does not work perfectly fine, although the server is set something fails at the end of the process...not sure if that makes any sense...there may be something that I'm missing...
@csadilek please let me ask you in case you would have any idea about the issue since you have more knowledge about the way the config stage/prod works for the tests/app.
Thanks!
@isabelrios ok, I'll take a look tomorrow!
@vladikoff the problem @isabelrios describes (stuck on the connected screen) is in fact reproducible on master. You just have to make sure not to use the web channel. Here's a changeset on top of latest master to reproduce against staging: https://github.com/csadilek/fenix/commit/72e3beedc7b8a5a970e97a929e0c9e45450da2ab
@isabelrios I've rebased your branch on all the latest changes on master (quite a few FxA changes) and pushed them here: https://github.com/csadilek/fenix/commits/sync-integration-environment-test-history.
I will work with @vladikoff to figure out why the default (non web channel) login flow isn't completed.
@isabelrios OK, checkHistoryFromDesktopTest is passing now!
I've pushed an update to my branch here: https://github.com/csadilek/fenix/tree/sync-integration-environment-test-history
We had to override the experiment config (see Experiments.kt) for the tests as well, as in the meantime, the FxA web channel was introduced, which is behind an experiment flag. The tests makes sure that the web channel isn't used (it's not available for staging).
@csadilek thank you so much for your help here! yay!! I see the test passing too!
Hopefully there are not too many changes around this again and this solution is the final one 🤞 :) to finally have all this in the repo soon.
Thanks!
If you agree, let's close this issue and if something related fails in the future we will create a new one or reopen this one.
Thanks again for your help!
Most helpful comment
@isabelrios OK,
checkHistoryFromDesktopTestis passing now!I've pushed an update to my branch here: https://github.com/csadilek/fenix/tree/sync-integration-environment-test-history
We had to override the experiment config (see Experiments.kt) for the tests as well, as in the meantime, the FxA web channel was introduced, which is behind an experiment flag. The tests makes sure that the web channel isn't used (it's not available for staging).