-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle temporary guest users details (WPB-10454) (#3322)
- Loading branch information
1 parent
1808cc8
commit e429419
Showing
16 changed files
with
381 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
app/src/androidTest/kotlin/com/wire/android/ui/common/UserProfileAvatarTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.android.ui.common | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import com.wire.android.model.UserAvatarData | ||
import com.wire.android.ui.WireTestTheme | ||
import com.wire.kalium.logic.data.user.UserAvailabilityStatus | ||
import kotlinx.coroutines.test.runTest | ||
import kotlinx.datetime.Clock | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import kotlin.time.Duration.Companion.hours | ||
|
||
class UserProfileAvatarTest { | ||
@get:Rule | ||
val composeTestRule by lazy { createComposeRule() } | ||
|
||
@Test | ||
fun givenAStandardUser_ShouldNotShowIndicators() = runTest { | ||
composeTestRule.setContent { | ||
WireTestTheme { | ||
UserProfileAvatar( | ||
size = dimensions().avatarDefaultBigSize, | ||
avatarData = UserAvatarData(), | ||
type = UserProfileAvatarType.WithoutIndicators | ||
) | ||
} | ||
} | ||
|
||
composeTestRule.onNodeWithTag(LEGAL_HOLD_INDICATOR_TEST_TAG).assertDoesNotExist() | ||
composeTestRule.onNodeWithTag(TEMP_USER_INDICATOR_TEST_TAG).assertDoesNotExist() | ||
} | ||
|
||
@Test | ||
fun givenAUserUnderLegalHold_ShouldShowLegalHoldIndicators() = runTest { | ||
composeTestRule.setContent { | ||
WireTestTheme { | ||
UserProfileAvatar( | ||
size = dimensions().avatarDefaultBigSize, | ||
avatarData = UserAvatarData(availabilityStatus = UserAvailabilityStatus.AVAILABLE), | ||
type = UserProfileAvatarType.WithIndicators.LegalHold(true) | ||
) | ||
} | ||
} | ||
|
||
composeTestRule.onNodeWithTag(LEGAL_HOLD_INDICATOR_TEST_TAG).assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun givenAUserUnderLegalHoldHidden_ShouldNotShowLegalHoldIndicators() = runTest { | ||
composeTestRule.setContent { | ||
WireTestTheme { | ||
UserProfileAvatar( | ||
size = dimensions().avatarDefaultBigSize, | ||
avatarData = UserAvatarData(), | ||
type = UserProfileAvatarType.WithIndicators.LegalHold(false) | ||
) | ||
} | ||
} | ||
|
||
composeTestRule.onNodeWithTag(LEGAL_HOLD_INDICATOR_TEST_TAG).assertDoesNotExist() | ||
} | ||
|
||
@Test | ||
fun givenATempGuestUser_ShouldShowTempUserIndicators() = runTest { | ||
composeTestRule.setContent { | ||
WireTestTheme { | ||
UserProfileAvatar( | ||
size = dimensions().avatarDefaultBigSize, | ||
avatarData = UserAvatarData(), | ||
type = UserProfileAvatarType.WithIndicators.TemporaryUser(expiresAt = Clock.System.now().plus(24.hours)) | ||
) | ||
} | ||
} | ||
|
||
composeTestRule.onNodeWithTag(TEMP_USER_INDICATOR_TEST_TAG).assertExists() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.