Skip to content

Commit 5f3574e

Browse files
committed
Merge branch 'release/5.91.0' into main
2 parents fc341cf + e6d1283 commit 5f3574e

File tree

95 files changed

+3653
-416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+3653
-416
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ GEM
22
remote: https://rubygems.org/
33
specs:
44
CFPropertyList (3.0.3)
5-
addressable (2.7.0)
5+
addressable (2.8.0)
66
public_suffix (>= 2.0.2, < 5.0)
77
artifactory (3.0.15)
88
atomos (0.1.3)

app/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ android {
7575
}
7676
flavorDimensions "store"
7777
productFlavors {
78+
internal{
79+
dimension "store"
80+
}
7881
fdroid{
7982
dimension "store"
8083
}
@@ -85,7 +88,7 @@ android {
8588
variantFilter { variant ->
8689
def names = variant.flavors*.name
8790
if (names.contains("fdroid") && variant.buildType.name == "debug") {
88-
// We only need the F-Droid release version
91+
// We don't need fdroidDebug build type
8992
setIgnore(true)
9093
}
9194
}

app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3239,7 +3239,7 @@ class BrowserTabViewModelTest {
32393239
whenever(mockOmnibarConverter.convertQueryToUrl("foo", null)).thenReturn("foo.com")
32403240
whenever(mockSpecialUrlDetector.determineType(anyString())).thenReturn(SpecialUrlDetector.UrlType.AppLink(uriString = "http://foo.com"))
32413241
testee.onUserSubmittedQuery("foo")
3242-
verify(mockAppLinksHandler).enterBrowserState()
3242+
verify(mockAppLinksHandler).userEnteredBrowserState()
32433243
assertCommandIssued<Navigate>()
32443244
}
32453245

app/src/androidTest/java/com/duckduckgo/app/browser/applinks/DuckDuckGoAppLinksHandlerTest.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,18 @@ class DuckDuckGoAppLinksHandlerTest {
143143
}
144144

145145
@Test
146-
fun whenResetCalledThenSetAppLinkOpenedInBrowserToFalse() {
146+
fun whenUserEntersBrowserStateThenSetUserEnteredLinkToTrue() {
147+
assertFalse(testee.userEnteredLink)
148+
testee.userEnteredBrowserState()
149+
assertTrue(testee.userEnteredLink)
150+
}
151+
152+
@Test
153+
fun whenResetCalledThenResetAppLinkState() {
147154
testee.appLinkOpenedInBrowser = true
155+
testee.userEnteredLink = true
148156
testee.reset()
149157
assertFalse(testee.appLinkOpenedInBrowser)
158+
assertFalse(testee.userEnteredLink)
150159
}
151160
}

app/src/androidTest/java/com/duckduckgo/app/email/AppEmailManagerTest.kt

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ package com.duckduckgo.app.email
1818

1919
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
2020
import com.duckduckgo.app.CoroutineTestRule
21+
import com.duckduckgo.app.email.AppEmailManager.WaitlistState.*
2122
import com.duckduckgo.app.email.AppEmailManager.Companion.DUCK_EMAIL_DOMAIN
2223
import com.duckduckgo.app.email.api.EmailAlias
24+
import com.duckduckgo.app.email.api.EmailInviteCodeResponse
2325
import com.duckduckgo.app.email.api.EmailService
26+
import com.duckduckgo.app.email.api.WaitlistResponse
27+
import com.duckduckgo.app.email.api.WaitlistStatusResponse
2428
import com.duckduckgo.app.email.db.EmailDataStore
2529
import com.duckduckgo.app.runBlocking
2630
import com.nhaarman.mockitokotlin2.*
@@ -184,7 +188,172 @@ class AppEmailManagerTest {
184188
assertEquals("username$DUCK_EMAIL_DOMAIN", testee.getEmailAddress())
185189
}
186190

191+
@Test
192+
fun whenWaitlistStateIfTimestampExistsCodeDoesNotExistAndSendNotificationIsTrueThenReturnJoinedQueueWithTrue() {
193+
whenever(mockEmailDataStore.waitlistTimestamp).thenReturn(1234)
194+
whenever(mockEmailDataStore.sendNotification).thenReturn(true)
195+
196+
assertEquals(JoinedQueue(true), testee.waitlistState())
197+
}
198+
199+
@Test
200+
fun whenWaitlistStateIfTimestampExistsCodeDoesNotExistAndSendNotificationIsFalseThenReturnJoinedQueueWithFalse() {
201+
whenever(mockEmailDataStore.waitlistTimestamp).thenReturn(1234)
202+
whenever(mockEmailDataStore.sendNotification).thenReturn(false)
203+
204+
assertEquals(JoinedQueue(false), testee.waitlistState())
205+
}
206+
207+
@Test
208+
fun whenWaitlistStateIfTimestampExistsAndCodeExistsThenReturnInBeta() {
209+
whenever(mockEmailDataStore.waitlistTimestamp).thenReturn(1234)
210+
whenever(mockEmailDataStore.inviteCode).thenReturn("abcde")
211+
212+
assertEquals(InBeta, testee.waitlistState())
213+
}
214+
215+
@Test
216+
fun whenWaitlistStateIfTimestampAndCodeDoesNotExistThenReturnNotJoinedQueue() {
217+
whenever(mockEmailDataStore.waitlistTimestamp).thenReturn(-1)
218+
whenever(mockEmailDataStore.inviteCode).thenReturn(null)
219+
220+
assertEquals(NotJoinedQueue, testee.waitlistState())
221+
}
222+
223+
@Test
224+
fun whenJoinWaitlistIfTimestampAndTokenDidNotExistThenStoreTimestampAndToken() {
225+
whenever(mockEmailDataStore.waitlistTimestamp).thenReturn(-1)
226+
whenever(mockEmailDataStore.waitlistToken).thenReturn(null)
227+
228+
testee.joinWaitlist(1234, "abcde")
229+
230+
verify(mockEmailDataStore).waitlistTimestamp = 1234
231+
verify(mockEmailDataStore).waitlistToken = "abcde"
232+
}
233+
@Test
234+
fun whenJoinWaitlistIfTimestampAndTokenDidExistThenStoreTimestampAndTokenAreNotStored() {
235+
whenever(mockEmailDataStore.waitlistTimestamp).thenReturn(1234)
236+
whenever(mockEmailDataStore.waitlistToken).thenReturn("abcde")
237+
238+
testee.joinWaitlist(4321, "edcba")
239+
240+
verify(mockEmailDataStore, never()).waitlistTimestamp = 4321
241+
verify(mockEmailDataStore, never()).waitlistToken = "edcba"
242+
}
243+
244+
@Test
245+
fun whenGetInviteCodeIfCodeExistsThenReturnCode() {
246+
whenever(mockEmailDataStore.inviteCode).thenReturn("abcde")
247+
assertEquals("abcde", testee.getInviteCode())
248+
}
249+
250+
@Test
251+
fun whenGetInviteCodeIfCodeDoesNotExistThenReturnEmpty() {
252+
whenever(mockEmailDataStore.inviteCode).thenReturn(null)
253+
assertEquals("", testee.getInviteCode())
254+
}
255+
256+
@Test
257+
fun whenDoesCodeAlreadyExistIfCodeExistsThenReturnTrue() {
258+
whenever(mockEmailDataStore.inviteCode).thenReturn("inviteCode")
259+
260+
assertTrue(testee.doesCodeAlreadyExist())
261+
}
262+
263+
@Test
264+
fun whenDoesCodeAlreadyExistIfCodeIsNullThenReturnFalse() {
265+
whenever(mockEmailDataStore.inviteCode).thenReturn(null)
266+
267+
assertFalse(testee.doesCodeAlreadyExist())
268+
}
269+
270+
@Test
271+
fun whenFetchInviteCodeIfCodeAlreadyExistsThenReturnCodeExisted() = coroutineRule.runBlocking {
272+
whenever(mockEmailDataStore.inviteCode).thenReturn("inviteCode")
273+
274+
assertEquals(AppEmailManager.FetchCodeResult.CodeExisted, testee.fetchInviteCode())
275+
}
276+
277+
@Test
278+
fun whenFetchInviteCodeIfTimestampIsSmallerThanQueueTimestampThenCallGetCode() = coroutineRule.runBlocking {
279+
givenUserIsInWaitlist()
280+
whenever(mockEmailService.waitlistStatus()).thenReturn(WaitlistStatusResponse(12345))
281+
282+
testee.fetchInviteCode()
283+
284+
verify(mockEmailService).getCode("token")
285+
}
286+
287+
@Test
288+
fun whenFetchInviteCodeIfTimestampIsEqualsThanQueueTimestampThenCallGetCode() = coroutineRule.runBlocking {
289+
givenUserIsInWaitlist()
290+
whenever(mockEmailService.waitlistStatus()).thenReturn(WaitlistStatusResponse(1234))
291+
292+
testee.fetchInviteCode()
293+
294+
verify(mockEmailService).getCode("token")
295+
}
296+
297+
@Test
298+
fun whenFetchInviteCodeIfUserIsTopOfQueueAndCodeAvailableThenReturnCode() = coroutineRule.runBlocking {
299+
givenUserIsTopOfTheQueue()
300+
whenever(mockEmailService.getCode(any())).thenReturn(EmailInviteCodeResponse("code"))
301+
302+
assertEquals(AppEmailManager.FetchCodeResult.Code, testee.fetchInviteCode())
303+
}
304+
305+
@Test
306+
fun whenFetchInviteCodeIfUserIsTopOfQueueAndCodeNotAvailableThenReturnNoCode() = coroutineRule.runBlocking {
307+
givenUserIsTopOfTheQueue()
308+
whenever(mockEmailService.getCode(any())).thenReturn(EmailInviteCodeResponse(""))
309+
310+
assertEquals(AppEmailManager.FetchCodeResult.NoCode, testee.fetchInviteCode())
311+
}
312+
313+
@Test
314+
fun whenFetchInviteCodeIfUserIsTopOfQueueAndCodeServiceNotAvailableThenReturnNoCode() = coroutineRule.runBlocking {
315+
testee = AppEmailManager(TestEmailService(), mockEmailDataStore, coroutineRule.testDispatcherProvider, TestCoroutineScope())
316+
givenUserIsTopOfTheQueue()
317+
318+
assertEquals(AppEmailManager.FetchCodeResult.NoCode, testee.fetchInviteCode())
319+
}
320+
321+
@Test
322+
fun whenFetchInviteCodeIfUserInTheQueueAndStatusServiceNotAvailableThenReturnNoCode() = coroutineRule.runBlocking {
323+
testee = AppEmailManager(TestEmailService(), mockEmailDataStore, coroutineRule.testDispatcherProvider, TestCoroutineScope())
324+
givenUserIsInWaitlist()
325+
326+
assertEquals(AppEmailManager.FetchCodeResult.NoCode, testee.fetchInviteCode())
327+
}
328+
329+
@Test
330+
fun whenNotifyOnJoinedWaitlistThenSendNotificationSetToTrue() {
331+
testee.notifyOnJoinedWaitlist()
332+
verify(mockEmailDataStore).sendNotification = true
333+
}
334+
335+
private fun givenUserIsInWaitlist() {
336+
whenever(mockEmailDataStore.waitlistTimestamp).thenReturn(1234)
337+
whenever(mockEmailDataStore.waitlistToken).thenReturn("token")
338+
}
339+
340+
private fun givenUserIsTopOfTheQueue() = coroutineRule.runBlocking {
341+
givenUserIsInWaitlist()
342+
whenever(mockEmailService.waitlistStatus()).thenReturn(WaitlistStatusResponse(1234))
343+
}
344+
187345
private suspend fun givenNextAliasExists() {
188346
aliasSharedFlow.emit("alias")
189347
}
348+
349+
class TestEmailService : EmailService {
350+
override suspend fun newAlias(authorization: String): EmailAlias = EmailAlias("alias")
351+
override suspend fun joinWaitlist(): WaitlistResponse = WaitlistResponse("token", 12345)
352+
override suspend fun waitlistStatus(): WaitlistStatusResponse {
353+
throw Exception()
354+
}
355+
override suspend fun getCode(token: String): EmailInviteCodeResponse {
356+
throw Exception()
357+
}
358+
}
190359
}

0 commit comments

Comments
 (0)