From 4d139d52c40ea2655487d9405bab3334218ad00a Mon Sep 17 00:00:00 2001 From: Aaron Train Date: Mon, 30 Mar 2020 18:01:58 -0400 Subject: [PATCH] Closes #9189: Fixes "static asset not found" error in doNotSaveLoginFromPromptTest, saveLoginFromPromptTest UI tests (#9439) AndroidAssetDispatcher class dispatcher was attempting to open a local asset with a query suffix from the request. If query suffix is found, remove it. Re-enable saveLoginFromPromptTest() and doNotSaveLoginFromPromptTest() --- .../java/org/mozilla/fenix/helpers/MockWebServer.kt | 8 ++++---- .../java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/helpers/MockWebServer.kt b/app/src/androidTest/java/org/mozilla/fenix/helpers/MockWebServer.kt index 592c931af1..5dfc98ec8c 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/helpers/MockWebServer.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/helpers/MockWebServer.kt @@ -62,12 +62,12 @@ const val HTTP_NOT_FOUND = 404 class AndroidAssetDispatcher : Dispatcher() { private val mainThreadHandler = Handler(Looper.getMainLooper()) - override fun dispatch(request: RecordedRequest): MockResponse { + override fun dispatch(request: RecordedRequest?): MockResponse { val assetManager = InstrumentationRegistry.getInstrumentation().context.assets try { - val pathNoLeadingSlash = request.path.drop(1) - assetManager.open(pathNoLeadingSlash).use { inputStream -> - return fileToResponse(pathNoLeadingSlash, inputStream) + val pathWithoutQueryParams = Uri.parse(request?.path?.drop(1)).path + assetManager.open(pathWithoutQueryParams!!).use { inputStream -> + return fileToResponse(pathWithoutQueryParams, inputStream) } } catch (e: IOException) { // e.g. file not found. // We're on a background thread so we need to forward the exception to the main thread. diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt index cb017834e2..8acb984318 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt @@ -140,7 +140,6 @@ class SettingsPrivacyTest { } @Test - @Ignore("Passes locally, fails on CI. Fix in https://github.com/mozilla-mobile/fenix/issues/9189") fun saveLoginFromPromptTest() { val saveLoginTest = TestAssetHelper.getSaveLoginAsset(mockWebServer) @@ -166,7 +165,6 @@ class SettingsPrivacyTest { } @Test - @Ignore("Passes locally, fails on CI. Fix in https://github.com/mozilla-mobile/fenix/issues/9189") fun doNotSaveLoginFromPromptTest() { val saveLoginTest = TestAssetHelper.getSaveLoginAsset(mockWebServer)