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

Fix/e2e create event #216

Merged
merged 44 commits into from
Dec 18, 2024
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ec48d3e
fix: refactored e2e create event to remove network calls and mock the…
misterM125 Dec 11, 2024
c27d933
chore: removed unnecessary logs from e2e
misterM125 Dec 11, 2024
87075f7
fix: added timeouts to waiters in the e2e to avoid the CI running ind…
misterM125 Dec 12, 2024
7c47d0f
test: added a timeout to the overall test to avoid blocking the CI
misterM125 Dec 12, 2024
eeb0d87
ktfmt format
misterM125 Dec 12, 2024
d45ced4
test: added ignore tag to test if the end to end really blocks the CI
misterM125 Dec 12, 2024
8520316
test: removed part of the test to see what the buggy part is
misterM125 Dec 12, 2024
68cf8a6
ktfmt format
misterM125 Dec 12, 2024
561d55d
testing: testing another part of the end to end
misterM125 Dec 12, 2024
a771f23
testing: uncommented even more to test on the CI
misterM125 Dec 12, 2024
111a5e9
testing: removed 'waitForIdle' calls to see if it is what is blocking…
misterM125 Dec 12, 2024
1bd8f9a
testing: check if the problem comes from date parsing
misterM125 Dec 12, 2024
f191af7
fix: uncommented an action that should not have been commented
misterM125 Dec 12, 2024
897f5d4
ktfmt format
misterM125 Dec 12, 2024
183571c
testing: test if the CI properly navigates to the parkOverview screen
misterM125 Dec 12, 2024
6287d3f
testing: testing if end to end can navigate to add event screen
misterM125 Dec 12, 2024
eab602a
testing: testing click to add event screen
misterM125 Dec 12, 2024
1b6bc1e
Merge branch 'main' into fix/e2e-create-event
misterM125 Dec 12, 2024
f5a6046
fix: added a missing import
misterM125 Dec 12, 2024
118b9a4
testing: removed problematic assertIsDisplayed
misterM125 Dec 13, 2024
630638c
fix: remove blocking timeout
misterM125 Dec 13, 2024
3846783
testing: removed navigation to add event screen
misterM125 Dec 13, 2024
c55c06c
testing: use navTestInvokation to help with navigation
misterM125 Dec 13, 2024
658e90b
refactor: divided the end to end test into two parts to avoid the CI …
misterM125 Dec 16, 2024
beaf324
comment: removed unnecessary comment
misterM125 Dec 16, 2024
5434d16
testing: test if the first part of the end to end works
misterM125 Dec 16, 2024
f4031af
testing: test if the second part of the end to end works
misterM125 Dec 16, 2024
06614b7
Merge branch 'main' into fix/e2e-create-event
misterM125 Dec 16, 2024
01a2448
chore: removed useless imports
misterM125 Dec 16, 2024
6039e32
testing: removed ignore tag to test the full end to end
misterM125 Dec 16, 2024
15c70db
testing: test that other tests work well without end to end
misterM125 Dec 16, 2024
e3840fd
testing: added an AssertIsDisplayed
misterM125 Dec 16, 2024
9e618be
testing: commented a waiter in end to end
misterM125 Dec 16, 2024
91779fc
testing: uncommented waiters and removed redundant calls
misterM125 Dec 16, 2024
3810983
testing: add asserts
misterM125 Dec 16, 2024
ffbfeb1
testing: removed additionnal asserts to see if it works
misterM125 Dec 16, 2024
f2d5f27
refactor: removed lines that do not work in end to end test
misterM125 Dec 16, 2024
1217569
refactor: removed additionnal lines
misterM125 Dec 17, 2024
3635c4a
fix: removed unstable asserts from eventOverviewTest
misterM125 Dec 17, 2024
a00968c
chore: removed unneccessary logs
misterM125 Dec 17, 2024
36c91c7
Merge branch 'main' into fix/e2e-create-event
misterM125 Dec 17, 2024
65c4188
ktfmt format
misterM125 Dec 17, 2024
ddf454c
Merge branch 'main' into fix/e2e-create-event
misterM125 Dec 17, 2024
ab6b3ac
chore: added documentation to setPark and removed unused imports
misterM125 Dec 17, 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
Prev Previous commit
Next Next commit
refactor: divided the end to end test into two parts to avoid the CI …
…blocking indefinitely
  • Loading branch information
misterM125 committed Dec 16, 2024
commit 658e90b293778ba4dd7d8948511763ee33ba9d0f
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.android.streetworkapp.end2end

import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.platform.LocalContext
@@ -144,9 +143,6 @@ class End2EndCreateEvent {
occupancy = 5,
events = listOf(event.eid))

// Define a state variable to hold the current screen
private var currentScreen by mutableStateOf(Screen.MAP)

@Before
fun setUp() {
MockitoAnnotations.openMocks(this)
@@ -230,22 +226,16 @@ class End2EndCreateEvent {
}

/**
* This end to end test simulates a user flow where the user creates an event and then displays it
* in the park overview screen. We also verify that the event is properly displayed in the event
* overview screen. Warning: this test fails between 00:00 and 01:00 UTC time because of the date
* comparison
* First part of the end to end test, simulates login and navigating to the park overview screen
* by clicking on a marker on the map
*/
// @Ignore("Test does not seem to pass on CI")
@Test
fun e2eCanCreateEventAndDisplayIt() = runTest {
// This one needs to be initialized here because it evaluateText is a suspend function
`when`(textModerationRepository.evaluateText(any(), any()))
.thenReturn(TextEvaluation.Result(true))

fun e2eLoginAndNavigateToParkOverview() = runTest {
composeTestRule.setContent {
StreetWorkApp(
parkLocationViewModel,
{ navigateTo(currentScreen) },
{ navigateTo(Screen.MAP) },
{ mapISLoaded = true },
userViewModel,
parkViewModel,
@@ -258,8 +248,7 @@ class End2EndCreateEvent {
GoogleAuthService(
"abc",
mock(FirebaseAuth::class.java, RETURNS_DEFAULTS),
context = LocalContext.current),
navTestInvokationOnEachRecompose = true)
context = LocalContext.current))
}

// Wait for the map to be loaded
@@ -302,7 +291,42 @@ class End2EndCreateEvent {
true
}

currentScreen = Screen.PARK_OVERVIEW
composeTestRule.waitUntil(5000) {
composeTestRule.onNodeWithTag("parkOverviewScreen").isDisplayed()
}
}

/**
* Second part of the end to end test that simulates a user flow where the user creates an event
* and then displays it in the park overview screen. We also verify that the event is properly
* displayed in the event overview screen.
*/
@Test
fun e2eCanCreateEventAndDisplayIt() = runTest {
// This one needs to be initialized here because it evaluateText is a suspend function
`when`(textModerationRepository.evaluateText(any(), any()))
.thenReturn(TextEvaluation.Result(true))

parkViewModel.setPark(park)

composeTestRule.setContent {
StreetWorkApp(
parkLocationViewModel,
{ navigateTo(Screen.PARK_OVERVIEW) },
{ mapISLoaded = true },
userViewModel,
parkViewModel,
eventViewModel,
mock(ProgressionViewModel::class.java),
mock(WorkoutViewModel::class.java),
textModerationViewModel,
mock(ImageViewModel::class.java),
mock(PreferencesViewModel::class.java),
GoogleAuthService(
"abc",
mock(FirebaseAuth::class.java, RETURNS_DEFAULTS),
context = LocalContext.current))
}

composeTestRule.waitUntil(5000) {
composeTestRule.onNodeWithTag("parkOverviewScreen").isDisplayed()
@@ -311,8 +335,6 @@ class End2EndCreateEvent {
// create an event
composeTestRule.onNodeWithTag("createEventButton").assertIsDisplayed().performClick()

currentScreen = Screen.ADD_EVENT

composeTestRule.onNodeWithTag("addEventScreen").assertIsDisplayed()

composeTestRule.onNodeWithTag("titleTag").assertIsDisplayed().performTextClearance()
@@ -337,16 +359,12 @@ class End2EndCreateEvent {

verify(parkDocumentRef).update(eq("events"), any())

currentScreen = Screen.PARK_OVERVIEW

composeTestRule.waitUntil(5000) { composeTestRule.onNodeWithTag("eventButton").isDisplayed() }

composeTestRule.onNodeWithText(event.title).assertIsDisplayed()

composeTestRule.onNodeWithTag("eventButton").assertIsDisplayed().performClick()

currentScreen = Screen.EVENT_OVERVIEW

composeTestRule.waitForIdle()

// navigate to the event overview screen and verify that the event is properly displayed
Loading