Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: E2E - Get running and passing on github runners #105

Merged
merged 20 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
dcc3e79
Fix BrowseChannelsE2eTest
FelberMartin Nov 9, 2024
8640976
Adjusted CreateChannelScreen to use testTags; tests still failing
FelberMartin Nov 9, 2024
15b2491
Fixed CreateChannelE2eTest
FelberMartin Nov 9, 2024
392de62
Merge branch 'develop' into chore/fix_e2e_tests_4
FelberMartin Nov 14, 2024
cedff81
Removing invalid env variable
FelberMartin Nov 14, 2024
7adfc47
Revert "Removing invalid env variable"
FelberMartin Nov 14, 2024
9e4da93
Removing invalid env variables
FelberMartin Nov 14, 2024
e3edbb1
Sanity cleanup: kill everything still running on port 3306 (currently…
FelberMartin Nov 14, 2024
5cbedfc
Removing sanity cleanup again to test whether this was just a tempora…
FelberMartin Nov 14, 2024
99caeb3
Adding back sanity cleanup for port 3306 (see second to last commit)
FelberMartin Nov 14, 2024
b397676
Continue on error for test reporting
FelberMartin Nov 14, 2024
b4ef3ca
Revert "Continue on error for test reporting"
FelberMartin Nov 14, 2024
fd8cc7d
Marked test as UnitTest
FelberMartin Nov 15, 2024
fabb108
Fixed ConversationOverviewE2eTest
FelberMartin Nov 15, 2024
560043a
Using more tolerant timeout
FelberMartin Nov 15, 2024
68a3664
Merge branch 'chore/fix_e2e_tests_4' into chore/fix_e2e_tests_config
FelberMartin Nov 15, 2024
d77f160
Disabling quiz tests
FelberMartin Nov 15, 2024
a1a823a
Re-added env variables
FelberMartin Nov 15, 2024
45fad40
Changed workflow names
FelberMartin Nov 15, 2024
4fef3bb
Merge branch 'develop' into chore/fix_e2e_tests_config
FelberMartin Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: End To End Tests
name: E2E Tests

on:
push:
Expand All @@ -9,7 +9,7 @@ on:

jobs:
end-to-end-tests:
name: End To End Tests
name: E2E Tests
runs-on: [self-hosted, ase-large-android-sdk-35]
timeout-minutes: 60

Expand All @@ -35,6 +35,15 @@ jobs:
if: success() || failure()
continue-on-error: true

# Sanity cleanup 2
- name: Print what is running on port 3306
run: sudo lsof -i:3306 || true
continue-on-error: true

- name: Stop anything still running on port 3306
run: sudo kill -9 $(sudo lsof -t -i:3306) || true
continue-on-error: true

- name: Launch docker containers
run: docker compose -f docker/e2e-tests.yml up -d artemis-app-setup
if: success() || failure()
Expand All @@ -53,7 +62,7 @@ jobs:
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Android End To End Test Results
name: E2E Test Results
path: test-outputs/**/*.xml
reporter: java-junit
fail-on-empty: 'false'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Android Unit Tests
name: JUnit Test Results
path: test-outputs/**/*.xml
reporter: java-junit
fail-on-empty: 'false'
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import io.ktor.serialization.kotlinx.json.json
import java.security.cert.X509Certificate
import javax.net.ssl.X509TrustManager

class TrustAllCertsKtorProvider(jsonProvider: JsonProvider, timeoutMillis: Long = 3000) : KtorProvider {
class TrustAllCertsKtorProvider(jsonProvider: JsonProvider, timeoutMillis: Long = 10000) : KtorProvider {

private val trustAll = @SuppressLint("CustomX509TrustManager")
object : X509TrustManager {
Expand Down
6 changes: 4 additions & 2 deletions docker/artemis_e2e_config.env
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ INFO_STUDENTEXAMSTORESESSIONDATA="true"
LOGGING_FILE_NAME="/opt/artemis/data/artemis.log"

MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED="true"
artemis.user-management.registration.enabled=true
artemis.user-management.registration.allowed-email-pattern=.*

# Artemis registration configuration
ARTEMIS_USER_MANAGEMENT_REGISTRATION_ENABLED=true
ARTEMIS_USER_MANAGEMENT_REGISTRATION_ALLOWED_EMAIL_PATTERN=.*
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import androidx.compose.ui.test.performScrollTo
import androidx.compose.ui.test.performTextInput
import androidx.lifecycle.SavedStateHandle
import androidx.test.platform.app.InstrumentationRegistry
import de.tum.informatics.www1.artemis.native_app.core.common.test.DefaultTestTimeoutMillis
import de.tum.informatics.www1.artemis.native_app.core.common.test.EndToEndTest
import de.tum.informatics.www1.artemis.native_app.core.common.test.testServerUrl
import de.tum.informatics.www1.artemis.native_app.core.data.cookieAuth
import de.tum.informatics.www1.artemis.native_app.core.model.account.User
import de.tum.informatics.www1.artemis.native_app.core.test.BaseComposeTest
import de.tum.informatics.www1.artemis.native_app.core.test.coreTestModules
import de.tum.informatics.www1.artemis.native_app.core.common.test.DefaultTestTimeoutMillis
import de.tum.informatics.www1.artemis.native_app.core.test.test_setup.course_creation.ktorProvider
import de.tum.informatics.www1.artemis.native_app.core.test.test_setup.generateId
import de.tum.informatics.www1.artemis.native_app.core.common.test.testServerUrl
import de.tum.informatics.www1.artemis.native_app.feature.login.register.RegisterUi
import de.tum.informatics.www1.artemis.native_app.feature.login.register.RegisterViewModel
import de.tum.informatics.www1.artemis.native_app.feature.login.register.TEST_TAG_TEXT_FIELD_CONFIRM_PASSWORD
Expand All @@ -45,9 +45,10 @@ import org.koin.android.ext.koin.androidContext
import org.koin.test.KoinTestRule
import org.koin.test.get
import org.robolectric.RobolectricTestRunner
import org.robolectric.util.Logger
import kotlin.test.assertEquals
import kotlin.test.assertTrue


@RunWith(RobolectricTestRunner::class)
@Category(EndToEndTest::class)
class RegisterEndToEndTest : BaseComposeTest() {
Expand Down Expand Up @@ -106,10 +107,13 @@ class RegisterEndToEndTest : BaseComposeTest() {
performTextInput(TEST_TAG_TEXT_FIELD_CONFIRM_PASSWORD, password)

runBlockingWithTestTimeout {
viewModel.register().await()
val result = viewModel.register().await()
assertEquals(result, RegisterViewModel.RegistrationResponse.SUCCESS,
"Registration failed: $result"
)

val users: List<User> = getUsers(loginName)
Logger.debug("Loaded users are $users")
println("Loaded users are $users")

assertTrue(users.any { it.username == loginName }, "Could not find registered user")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.ui.test.performTextClearance
import androidx.compose.ui.test.performTextInput
import androidx.compose.ui.text.input.TextFieldValue
import androidx.test.ext.junit.runners.AndroidJUnit4
import de.tum.informatics.www1.artemis.native_app.core.common.test.UnitTest
import de.tum.informatics.www1.artemis.native_app.core.data.DataState
import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.R
import kotlinx.coroutines.CompletableDeferred
Expand All @@ -24,8 +25,10 @@ import kotlinx.coroutines.flow.flowOf
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.experimental.categories.Category
import org.junit.runner.RunWith

@Category(UnitTest::class)
@RunWith(AndroidJUnit4::class)
class ReplyTextFieldUiTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ internal fun BrowseChannelsScreen(
@Composable
private fun ChannelChatItem(channelChat: ChannelChat, onClick: () -> Unit) {
ListItem(
modifier = Modifier
.fillMaxWidth()
.testTag(testTagForBrowsedChannelItem(channelChat.id)),
modifier = Modifier.fillMaxWidth(),
leadingContent = {
ChannelIcons(channelChat)
},
Expand Down Expand Up @@ -189,21 +187,21 @@ private fun ChannelChatItem(channelChat: ChannelChat, onClick: () -> Unit) {
trailingContent = {
if (!channelChat.isMember) {
Button(
modifier = Modifier
.wrapContentSize()
.testTag(testTagForBrowsedChannelItem(channelChat.id)),
onClick = onClick,
colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.primary,
contentColor = MaterialTheme.colorScheme.onPrimary
),
shape = RoundedCornerShape(4.dp),
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 4.dp),
modifier = Modifier
.wrapContentSize()

) {
Text(text = stringResource(id = R.string.join_button_title))
}
}
}
)
}


Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.tum.informatics.www1.artemis.native_app.feature.metis.manageconversations.ui.conversation.create_channel

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
Expand All @@ -25,25 +24,21 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewModelScope
import de.tum.informatics.www1.artemis.native_app.core.ui.Spacings
import de.tum.informatics.www1.artemis.native_app.core.ui.alert.TextAlertDialog
import de.tum.informatics.www1.artemis.native_app.core.ui.compose.NavigationBackButton
import de.tum.informatics.www1.artemis.native_app.feature.metis.manageconversations.R
import de.tum.informatics.www1.artemis.native_app.feature.metis.manageconversations.ui.conversation.PotentiallyIllegalTextField
import kotlinx.coroutines.launch
import org.koin.androidx.compose.koinViewModel
import org.koin.core.parameter.parametersOf

internal const val TEST_TAG_CREATE_CHANNEL_BUTTON = "create channel button"

internal const val TEST_TAG_SET_PUBLIC_BUTTON = "TEST_TAG_SET_PUBLIC_BUTTON"
internal const val TEST_TAG_SET_PRIVATE_BUTTON = "TEST_TAG_SET_PRIVATE_BUTTON"

internal const val TEST_TAG_SET_ANNOUNCEMENT_BUTTON = "TEST_TAG_SET_ANNOUNCEMENT_BUTTON"
internal const val TEST_TAG_SET_UNRESTRICTED_BUTTON = "TEST_TAG_SET_UNRESTRICTED_BUTTON"
internal const val TEST_TAG_SET_PRIVATE_PUBLIC_SWITCH = "TEST_TAG_SET_PRIVATE_PUBLIC_SWITCH"
internal const val TEST_TAG_SET_ANNOUNCEMENT_UNRESTRICTED_SWITCH = "TEST_TAG_SET_ANNOUNCEMENT_UNRESTRICTED_SWITCH"

@Composable
fun CreateChannelScreen(
Expand Down Expand Up @@ -141,35 +136,36 @@ internal fun CreateChannelScreen(
title = stringResource(id = R.string.create_channel_channel_accessibility_type),
description = stringResource(id = R.string.create_channel_channel_accessibility_type_hint),
isChecked = isPrivate,
onCheckedChange = { viewModel.updatePublic(it) }
onCheckedChange = { viewModel.updatePublic(it) },
switchTestTag = TEST_TAG_SET_PRIVATE_PUBLIC_SWITCH,
)

BinarySelection(
modifier = Modifier.fillMaxWidth(),
title = stringResource(id = R.string.create_channel_channel_announcement_type),
description = stringResource(id = R.string.create_channel_channel_announcement_type_hint),
isChecked = isAnnouncement,
onCheckedChange = { viewModel.updateAnnouncement(it) }
onCheckedChange = { viewModel.updateAnnouncement(it) },
switchTestTag = TEST_TAG_SET_ANNOUNCEMENT_UNRESTRICTED_SWITCH,
)

Button(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp)
.testTag(TEST_TAG_CREATE_CHANNEL_BUTTON),
enabled = canCreate,
onClick = {
viewModel.viewModelScope.launch {
val channel = viewModel.createChannel().await()
viewModel.createChannel { channel ->
if (channel != null) {
onConversationCreated(channel.id)
} else {
isDisplayingErrorDialog = true
}
}
},
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp),
enabled = viewModel.canCreate.collectAsState().value,

) {
Text(text = "Create Channel")
Text(text = stringResource(R.string.create_channel_button))
}

Spacer(modifier = Modifier.height(16.dp))
Expand All @@ -195,7 +191,8 @@ private fun BinarySelection(
title: String,
description: String,
isChecked: Boolean,
onCheckedChange: (Boolean) -> Unit
onCheckedChange: (Boolean) -> Unit,
switchTestTag: String = ""
) {
Column(
modifier = modifier,
Expand All @@ -211,6 +208,7 @@ private fun BinarySelection(
style = MaterialTheme.typography.titleMedium
)
Switch(
modifier = Modifier.testTag(switchTestTag),
checked = isChecked,
onCheckedChange = onCheckedChange
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import de.tum.informatics.www1.artemis.native_app.core.datastore.ServerConfigura
import de.tum.informatics.www1.artemis.native_app.core.datastore.authToken
import de.tum.informatics.www1.artemis.native_app.feature.metis.manageconversations.ui.common.mapIsChannelNameIllegal
import de.tum.informatics.www1.artemis.native_app.feature.metis.manageconversations.ui.common.mapIsDescriptionOrTopicIllegal
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.async
import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.content.dto.conversation.ChannelChat
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import kotlinx.coroutines.plus
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
Expand Down Expand Up @@ -56,12 +56,12 @@ internal class CreateChannelViewModel(
}
.stateIn(viewModelScope + coroutineContext, SharingStarted.Eagerly, false)

fun createChannel(): Deferred<de.tum.informatics.www1.artemis.native_app.feature.metis.shared.content.dto.conversation.ChannelChat?> {
return viewModelScope.async(coroutineContext) {
fun createChannel(onChannelCreated: (ChannelChat?) -> Unit) {
viewModelScope.launch(coroutineContext) {
val authToken = accountService.authToken.first()
val serverUrl = serverConfigurationService.serverUrl.first()

conversationService.createChannel(
val channel = conversationService.createChannel(
courseId = courseId,
name = name.value,
description = description.value,
Expand All @@ -70,6 +70,8 @@ internal class CreateChannelViewModel(
authToken = authToken,
serverUrl = serverUrl
).orNull()

onChannelCreated(channel)
}
}

Expand Down
Loading
Loading