From c108d87909e6052c0d2019f38cc7e5a5e17a1cc8 Mon Sep 17 00:00:00 2001 From: charlie mangano Date: Tue, 19 Nov 2024 11:09:16 +0100 Subject: [PATCH] test: remove end-to-end tests These tests should now be only present in the `test/end-to-end` branch --- .../android/periodpals/endtoend/EndToEndM1.kt | 236 ------------------ .../android/periodpals/endtoend/EndToEndM2.kt | 104 -------- 2 files changed, 340 deletions(-) delete mode 100644 app/src/androidTest/java/com/android/periodpals/endtoend/EndToEndM1.kt delete mode 100644 app/src/androidTest/java/com/android/periodpals/endtoend/EndToEndM2.kt diff --git a/app/src/androidTest/java/com/android/periodpals/endtoend/EndToEndM1.kt b/app/src/androidTest/java/com/android/periodpals/endtoend/EndToEndM1.kt deleted file mode 100644 index ab56504d6..000000000 --- a/app/src/androidTest/java/com/android/periodpals/endtoend/EndToEndM1.kt +++ /dev/null @@ -1,236 +0,0 @@ -package com.android.periodpals.endtoend - -import android.util.Log -import androidx.compose.ui.test.assertIsDisplayed -import androidx.compose.ui.test.assertTextEquals -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.compose.ui.test.onAllNodesWithTag -import androidx.compose.ui.test.onNodeWithTag -import androidx.compose.ui.test.performClick -import androidx.compose.ui.test.performScrollTo -import androidx.compose.ui.test.performTextInput -import androidx.test.espresso.Espresso -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.rule.ActivityTestRule -import com.android.periodpals.MainActivity -import com.android.periodpals.resources.C.Tag.AuthenticationScreens -import com.android.periodpals.resources.C.Tag.AuthenticationScreens.SignInScreen -import com.android.periodpals.resources.C.Tag.AuthenticationScreens.SignUpScreen -import com.android.periodpals.resources.C.Tag.ProfileScreens -import com.android.periodpals.resources.C.Tag.ProfileScreens.CreateProfileScreen -import com.android.periodpals.resources.C.Tag.ProfileScreens.ProfileScreen -import com.kaspersky.kaspresso.testcases.api.testcase.TestCase -import org.junit.After -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -private const val TAG = "EndToEndM1" -private const val TIMEOUT = 10000L // 10 seconds, adjust for slower devices, networks and CI - -@RunWith(AndroidJUnit4::class) -class EndToEnd1 : TestCase() { - @get:Rule val composeTestRule = createComposeRule() - @get:Rule val activityRule = ActivityTestRule(MainActivity::class.java) - - companion object SignUpData { - private val signUpName = ('a'..'z').map { it }.shuffled().subList(0, 8).joinToString("") - private const val dob = "01/01/2001" - private val signUpDescription = "Short bio containing my name to identify me: $signUpName" - private val signUpEmail = "$signUpName@example.com" - private const val psswd = "iLoveSwent1234!" - private const val signInName = "testUser" - private const val signInEmail = "$signInName@example.com" - private const val signInDescription = "Short bio containing my name to identify me: $signInName" - } - - @Before fun setUp() {} - - @After - fun tearDown() { - // delete user from database - } - - /** - * End-to-end test for the - * [sign-up flow](https://www.figma.com/design/r6jgyWnwTQ6e5X1eLpeHwN/PeriodsPals?node-id=579-5989&node-type=canvas&m=dev) - * - * The "user" lands on the SignIn screen then navigates to the SignUp screen. They (correctly) - * fill in the fields and click on the "Sign Up" button and get redirected to the CreateProfile - * screen. They (correctly) fill in the fields and get redirected to the Profile screen that - * displays the info they just entered. - */ - @Test - fun signUpEndToEnd() { - - composeTestRule.setContent { MainActivity() } - - // SignIn Screen - // User navigates to SignUp Screen - composeTestRule.waitForIdle() - Log.d(TAG, "User arrives on SignIn Screen") - composeTestRule.onNodeWithTag(SignInScreen.SCREEN).assertExists() - composeTestRule - .onNodeWithTag(SignInScreen.NOT_REGISTERED_BUTTON) - .performScrollTo() - .assertIsDisplayed() - .performClick() - - // SignUp Screen - // User fills out the form and submits - composeTestRule.waitForIdle() - Log.d(TAG, "User arrives on SignUp Screen") - composeTestRule - .onNodeWithTag(AuthenticationScreens.EMAIL_FIELD) - .performScrollTo() - .assertIsDisplayed() - .performTextInput(signUpEmail) - composeTestRule - .onNodeWithTag(AuthenticationScreens.PASSWORD_FIELD) - .performScrollTo() - .assertIsDisplayed() - .performTextInput(psswd) - composeTestRule - .onNodeWithTag(SignUpScreen.CONFIRM_PASSWORD_FIELD) - .performScrollTo() - .assertIsDisplayed() - .performTextInput(psswd) - Espresso.closeSoftKeyboard() - composeTestRule - .onNodeWithTag(SignUpScreen.SIGN_UP_BUTTON) - .performScrollTo() - .assertIsDisplayed() - .performClick() - composeTestRule.waitUntil(TIMEOUT) { - composeTestRule.onAllNodesWithTag(CreateProfileScreen.SCREEN).fetchSemanticsNodes().size == 1 - } - - // Create Profile Screen - // User fills out the form and submits - composeTestRule.waitForIdle() - Log.d(TAG, "User arrives on Create Profile Screen") - composeTestRule - .onNodeWithTag(ProfileScreens.NAME_INPUT_FIELD) - .performScrollTo() - .assertIsDisplayed() - .performTextInput(signUpName) - composeTestRule - .onNodeWithTag(ProfileScreens.DOB_INPUT_FIELD) - .performScrollTo() - .assertIsDisplayed() - .performTextInput(dob) - composeTestRule - .onNodeWithTag(ProfileScreens.DESCRIPTION_INPUT_FIELD) - .performScrollTo() - .assertIsDisplayed() - .performTextInput(signUpDescription) - Espresso.closeSoftKeyboard() - composeTestRule - .onNodeWithTag(ProfileScreens.SAVE_BUTTON) - .performScrollTo() - .assertIsDisplayed() - .performClick() - composeTestRule.waitUntil(TIMEOUT) { - composeTestRule.onAllNodesWithTag(ProfileScreen.SCREEN).fetchSemanticsNodes().size == 1 - } - - // Profile Screen - // User arrives on Profile Screen and see their data displayed - composeTestRule.waitForIdle() - Log.d(TAG, "User arrives on Profile Screen") - composeTestRule - .onNodeWithTag(ProfileScreen.NAME_FIELD) - .performScrollTo() - .assertIsDisplayed() - .assertTextEquals(signUpName) - composeTestRule - .onNodeWithTag(ProfileScreen.DESCRIPTION_FIELD) - .performScrollTo() - .assertIsDisplayed() - .assertTextEquals(signUpDescription) - composeTestRule - .onNodeWithTag(ProfileScreen.NO_REVIEWS_CARD) - .performScrollTo() - .assertIsDisplayed() - composeTestRule - .onNodeWithTag(ProfileScreen.CONTRIBUTION_FIELD) - .performScrollTo() - .assertIsDisplayed() - .assertTextEquals("New user") - } - - /** - * End-to-end test for the - * [sign-in flow](https://www.figma.com/design/r6jgyWnwTQ6e5X1eLpeHwN/PeriodsPals?node-id=579-5989&node-type=canvas&m=dev). - * - * The "user" lands on the SignIn screen and (correctly) fill in their info. They click on the - * "Sign In" button and get redirected to the Profile screen that displays their information. - */ - @Test - fun signInEndToEnd() { - - composeTestRule.setContent { MainActivity() } - - // SignIn Screen - // User fills out the form and submits - composeTestRule.waitForIdle() - Log.d(TAG, "User arrives on SignIn Screen") - composeTestRule - .onNodeWithTag(AuthenticationScreens.EMAIL_FIELD) - .performScrollTo() - .assertIsDisplayed() - .performTextInput(signInEmail) - composeTestRule - .onNodeWithTag(AuthenticationScreens.PASSWORD_FIELD) - .performScrollTo() - .assertIsDisplayed() - .performTextInput(psswd) - Espresso.closeSoftKeyboard() - composeTestRule - .onNodeWithTag(SignInScreen.SIGN_IN_BUTTON) - .performScrollTo() - .assertIsDisplayed() - .performClick() - composeTestRule.waitUntil(TIMEOUT) { - composeTestRule.onAllNodesWithTag(ProfileScreen.SCREEN).fetchSemanticsNodes().size == 1 - } - - // Profile Screen - // User arrives on Profile Screen and see their data displayed - composeTestRule.waitForIdle() - composeTestRule.waitUntil( - TIMEOUT) { // need to wait because very first recomposition has not fetched data yet - try { // trick waitUntil into thinking this counts as a SemanticNodeInteraction - composeTestRule - .onNodeWithTag(ProfileScreen.NAME_FIELD) - .performScrollTo() - .assertIsDisplayed() - .assertTextEquals(signInName) - true - } catch (e: AssertionError) { - false - } - } - Log.d(TAG, "User arrives on Profile Screen") - composeTestRule - .onNodeWithTag(ProfileScreen.NAME_FIELD) - .performScrollTo() - .assertIsDisplayed() - .assertTextEquals(signInName) - composeTestRule - .onNodeWithTag(ProfileScreen.DESCRIPTION_FIELD) - .performScrollTo() - .assertIsDisplayed() - .assertTextEquals(signInDescription) - composeTestRule - .onNodeWithTag(ProfileScreen.NO_REVIEWS_CARD) - .performScrollTo() - .assertIsDisplayed() // TODO: change once implemented the reviews - composeTestRule - .onNodeWithTag(ProfileScreen.CONTRIBUTION_FIELD) - .performScrollTo() - .assertIsDisplayed() - .assertTextEquals("New user") // TODO: change once implemented the statuses - } -} diff --git a/app/src/androidTest/java/com/android/periodpals/endtoend/EndToEndM2.kt b/app/src/androidTest/java/com/android/periodpals/endtoend/EndToEndM2.kt deleted file mode 100644 index 2d968e0f1..000000000 --- a/app/src/androidTest/java/com/android/periodpals/endtoend/EndToEndM2.kt +++ /dev/null @@ -1,104 +0,0 @@ -package com.android.periodpals.endtoend - -import android.util.Log -import androidx.compose.ui.test.assertIsDisplayed -import androidx.compose.ui.test.assertTextEquals -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.compose.ui.test.onAllNodesWithTag -import androidx.compose.ui.test.onNodeWithTag -import androidx.compose.ui.test.performClick -import androidx.compose.ui.test.performTextInput -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.rule.ActivityTestRule -import com.android.periodpals.MainActivity -import com.android.periodpals.resources.C.Tag.AuthenticationScreens -import com.android.periodpals.resources.C.Tag.AuthenticationScreens.SignInScreen -import com.android.periodpals.resources.C.Tag.ProfileScreens -import com.android.periodpals.resources.C.Tag.ProfileScreens.EditProfileScreen -import com.android.periodpals.resources.C.Tag.ProfileScreens.ProfileScreen -import com.android.periodpals.resources.C.Tag.TopAppBar -import com.kaspersky.kaspresso.testcases.api.testcase.TestCase -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -private const val TAG = "EndToEnd2" -private const val TIMEOUT = 10000L // 10 seconds, adjust for slower devices, networks and CI - -@RunWith(AndroidJUnit4::class) -class EndToEndM2 : TestCase() { - @get:Rule val composeTestRule = createComposeRule() - @get:Rule val activityRule = ActivityTestRule(MainActivity::class.java) - - companion object { - private val randomNumber = (1..9).random() - private const val EMAIL = "end2end@test" - private const val PASSWORD = "Secure!password123" - private val name = "Mocknica$randomNumber" - private val dob = "0$randomNumber/01/2000" - private val description = "I'm a mathematician, my favourite number is $randomNumber!" - } - - @Before - fun setUp() { - composeTestRule.setContent { MainActivity() } - } - - @Test - fun signInAndEditProfile() { - // Sign in using existing account - composeTestRule.waitForIdle() - Log.d(TAG, "User arrives on SignIn Screen") - composeTestRule.onNodeWithTag(SignInScreen.SCREEN).assertExists() // or is displayed? - composeTestRule - .onNodeWithTag(AuthenticationScreens.EMAIL_FIELD) - .assertIsDisplayed() - .performTextInput(EMAIL) - composeTestRule - .onNodeWithTag(AuthenticationScreens.PASSWORD_FIELD) - .assertIsDisplayed() - .performTextInput(PASSWORD) - composeTestRule.onNodeWithTag(SignInScreen.SIGN_IN_BUTTON).assertIsDisplayed().performClick() - composeTestRule.waitUntil(TIMEOUT) { - composeTestRule.onAllNodesWithTag(ProfileScreen.SCREEN).fetchSemanticsNodes().size == 1 - } - - // Profile Screen is displayed - composeTestRule.waitForIdle() - Log.d(TAG, "User arrives on Profile Screen") - composeTestRule.onNodeWithTag(TopAppBar.EDIT_BUTTON).assertIsDisplayed().performClick() - composeTestRule.waitUntil(TIMEOUT) { - composeTestRule.onAllNodesWithTag(EditProfileScreen.SCREEN).fetchSemanticsNodes().size == 1 - } - - // Edit Profile Screen is displayed, edit name, dob and description - composeTestRule.waitForIdle() - Log.d(TAG, "User arrives on Edit Profile Screen") - composeTestRule - .onNodeWithTag(ProfileScreens.NAME_INPUT_FIELD) - .assertIsDisplayed() - .performTextInput(name) - composeTestRule - .onNodeWithTag(ProfileScreens.DOB_INPUT_FIELD) - .assertIsDisplayed() - .performTextInput(dob) - composeTestRule - .onNodeWithTag(ProfileScreens.DESCRIPTION_INPUT_FIELD) - .assertIsDisplayed() - .performTextInput(description) - composeTestRule.onNodeWithTag(ProfileScreens.SAVE_BUTTON).assertIsDisplayed().performClick() - composeTestRule.waitUntil(TIMEOUT) { - composeTestRule.onAllNodesWithTag(ProfileScreen.SCREEN).fetchSemanticsNodes().size == 1 - } - - // Profile Screen, check if the changes are saved - composeTestRule.waitForIdle() - Log.d(TAG, "User arrives on Profile Screen") - composeTestRule.onNodeWithTag(ProfileScreen.NAME_FIELD).assertExists().assertTextEquals(name) - composeTestRule - .onNodeWithTag(ProfileScreen.DESCRIPTION_FIELD) - .assertExists() - .assertTextEquals(description) - } -}