Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
*/
package com.instructure.parentapp.ui.e2e.compose

import android.app.Instrumentation
import android.util.Log
import androidx.test.espresso.Espresso
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.matcher.IntentMatchers
import com.instructure.canvas.espresso.FeatureCategory
import com.instructure.canvas.espresso.Priority
import com.instructure.canvas.espresso.SecondaryFeatureCategory
Expand Down Expand Up @@ -449,4 +452,34 @@ class LoginE2ETest : ParentComposeTest() {
loginSignInPage.assertPageObjects()
}

@E2E
@Test
@TestMetaData(Priority.NICE_TO_HAVE, FeatureCategory.LOGIN, TestCategory.E2E)
fun testLoginHowDoIFindMySchoolE2E() {

Log.d(STEP_TAG, "Click 'Find My School' button.")
loginLandingPage.clickFindMySchoolButton()

Log.d(STEP_TAG, "Enter and invalid domain to trigger the 'Tap here for login help.' link to be displayed.")
loginFindSchoolPage.enterDomain("invalid-domain")

Log.d(ASSERTION_TAG, "Assert that the 'Tap here for login help.' link is displayed.")
loginFindSchoolPage.assertHowDoIFindMySchoolLinkDisplayed()

val expectedUrl = "https://community.instructure.com/en/kb/articles/662717-where-do-i-find-my-institutions-url-to-access-canvas"
val expectedIntent = IntentMatchers.hasData(expectedUrl)
Intents.init()
try {
Intents.intending(expectedIntent).respondWith(Instrumentation.ActivityResult(0, null))

Log.d(STEP_TAG, "Click on the 'Tap here for login help.' link.")
loginFindSchoolPage.clickOnHowDoIFindMySchoolLink()

Log.d(ASSERTION_TAG, "Assert that an intent with the correct URL was fired.")
Intents.intended(expectedIntent)
} finally {
Intents.release()
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
*/
package com.instructure.student.ui.e2e.classic

import android.app.Instrumentation
import android.util.Log
import androidx.test.espresso.Espresso
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.matcher.IntentMatchers
import com.instructure.canvas.espresso.FeatureCategory
import com.instructure.canvas.espresso.Priority
import com.instructure.canvas.espresso.SecondaryFeatureCategory
Expand All @@ -37,6 +40,7 @@ import com.instructure.dataseeding.model.EnrollmentTypes.STUDENT_ENROLLMENT
import com.instructure.dataseeding.model.EnrollmentTypes.TEACHER_ENROLLMENT
import com.instructure.dataseeding.util.CanvasNetworkAdapter
import com.instructure.espresso.withIdlingResourceDisabled
import com.instructure.student.R
import com.instructure.student.ui.utils.StudentTest
import com.instructure.student.ui.utils.extensions.enterDomain
import com.instructure.student.ui.utils.extensions.seedData
Expand Down Expand Up @@ -416,6 +420,58 @@ class LoginE2ETest : StudentTest() {
loginSignInPage.assertPageObjects()
}

@E2E
@Test
@TestMetaData(Priority.NICE_TO_HAVE, FeatureCategory.LOGIN, TestCategory.E2E)
fun testLoginHowDoIFindMySchoolE2E() {

Log.d(STEP_TAG, "Click 'Find My School' button.")
loginLandingPage.clickFindMySchoolButton()

Log.d(STEP_TAG, "Enter and invalid domain to trigger the 'Tap here for login help.' link to be displayed.")
loginFindSchoolPage.enterDomain("invalid-domain")

Log.d(ASSERTION_TAG, "Assert that the 'Tap here for login help.' link is displayed.")
loginFindSchoolPage.assertHowDoIFindMySchoolLinkDisplayed()

val expectedUrl = "https://community.instructure.com/en/kb/articles/662717-where-do-i-find-my-institutions-url-to-access-canvas"
val expectedIntent = IntentMatchers.hasData(expectedUrl)
Intents.init()
try {
Intents.intending(expectedIntent).respondWith(Instrumentation.ActivityResult(0, null))

Log.d(STEP_TAG, "Click on the 'Tap here for login help.' link.")
loginFindSchoolPage.clickOnHowDoIFindMySchoolLink()

Log.d(ASSERTION_TAG, "Assert that an intent with the correct URL was fired.")
Intents.intended(expectedIntent)
} finally {
Intents.release()
}
}

@E2E
@Test
@TestMetaData(Priority.MANDATORY, FeatureCategory.LOGIN, TestCategory.E2E)
fun testLoginCanFindSchoolE2E() {

Log.d(STEP_TAG, "Click 'Find My School' button.")
loginLandingPage.clickFindMySchoolButton()

Log.d(ASSERTION_TAG, "Assert that the Find School Page has been displayed properly.")
loginFindSchoolPage.assertPageObjects()

Log.d(ASSERTION_TAG, "Assert that the hint text is correct based on the device type.")
if(isTabletDevice()) loginFindSchoolPage.assertHintText(R.string.schoolInstructureCom)
else loginFindSchoolPage.assertHintText(R.string.loginHint)

Log.d(STEP_TAG, "Enter domain: 'harvest'.")
loginFindSchoolPage.enterDomain("harvest")

Log.d(ASSERTION_TAG, "Assert that the 'City Harvest Church (Singapore)' school is displayed among the search results.")
loginFindSchoolPage.assertSchoolSearchResults("City Harvest Church (Singapore)")
}

private fun loginWithUser(user: CanvasUserApiModel, lastSchoolSaved: Boolean = false) {

Thread.sleep(5100) //Need to wait > 5 seconds before each login attempt because of new 'too many attempts' login policy on web.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import com.instructure.canvas.espresso.FeatureCategory
import com.instructure.canvas.espresso.Priority
import com.instructure.canvas.espresso.TestCategory
import com.instructure.canvas.espresso.TestMetaData
import com.instructure.student.R
import com.instructure.student.ui.utils.StudentTest
import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.Test
Expand All @@ -29,19 +28,6 @@ class LoginInteractionTest : StudentTest() {

override fun displaysPageObjects() = Unit // Not used for interaction tests

@Test
@TestMetaData(Priority.MANDATORY, FeatureCategory.LOGIN, TestCategory.INTERACTION)
fun testLogin_canFindSchool() {
loginLandingPage.clickFindMySchoolButton()
loginFindSchoolPage.assertPageObjects()

if(isTabletDevice()) loginFindSchoolPage.assertHintText(R.string.schoolInstructureCom)
else loginFindSchoolPage.assertHintText(R.string.loginHint)

loginFindSchoolPage.enterDomain("harvest")
loginFindSchoolPage.assertSchoolSearchResults("City Harvest Church (Singapore)")
}

@Test
@TestMetaData(Priority.MANDATORY, FeatureCategory.LOGIN, TestCategory.INTERACTION)
fun testLogin_qrTutorialPageLoads() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
*/
package com.instructure.teacher.ui.e2e.classic

import android.app.Instrumentation
import android.util.Log
import androidx.test.espresso.Espresso
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.matcher.IntentMatchers
import com.instructure.canvas.espresso.FeatureCategory
import com.instructure.canvas.espresso.Priority
import com.instructure.canvas.espresso.SecondaryFeatureCategory
Expand Down Expand Up @@ -299,6 +302,36 @@ class LoginE2ETest : TeacherTest() {
loginSignInPage.assertPageObjects()
}

@E2E
@Test
@TestMetaData(Priority.NICE_TO_HAVE, FeatureCategory.LOGIN, TestCategory.E2E)
fun testLoginHowDoIFindMySchoolE2E() {

Log.d(STEP_TAG, "Click 'Find My School' button.")
loginLandingPage.clickFindMySchoolButton()

Log.d(STEP_TAG, "Enter and invalid domain to trigger the 'Tap here for login help.' link to be displayed.")
loginFindSchoolPage.enterDomain("invalid-domain")

Log.d(ASSERTION_TAG, "Assert that the 'Tap here for login help.' link is displayed.")
loginFindSchoolPage.assertHowDoIFindMySchoolLinkDisplayed()

val expectedUrl = "https://community.instructure.com/en/kb/articles/662717-where-do-i-find-my-institutions-url-to-access-canvas"
val expectedIntent = IntentMatchers.hasData(expectedUrl)
Intents.init()
try {
Intents.intending(expectedIntent).respondWith(Instrumentation.ActivityResult(0, null))

Log.d(STEP_TAG, "Click on the 'Tap here for login help.' link.")
loginFindSchoolPage.clickOnHowDoIFindMySchoolLink()

Log.d(ASSERTION_TAG, "Assert that an intent with the correct URL was fired.")
Intents.intended(expectedIntent)
} finally {
Intents.release()
}
}

private fun loginWithUser(user: CanvasUserApiModel, lastSchoolSaved: Boolean = false) {

if(lastSchoolSaved) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.instructure.espresso.page.BasePage
import com.instructure.espresso.page.getStringFromResource
import com.instructure.espresso.page.plus
import com.instructure.espresso.page.waitForView
import com.instructure.espresso.page.withAncestor
import com.instructure.espresso.page.withId
import com.instructure.espresso.page.withText
import com.instructure.espresso.replaceText
Expand Down Expand Up @@ -81,5 +82,19 @@ class LoginFindSchoolPage: BasePage() {
val hintText = getHintText(withId(R.id.domainInput))
assertEquals(hintText, getStringFromResource(schoolText))
}

/**
* Assert that the "Tap here for login help." link is displayed.
*/
fun assertHowDoIFindMySchoolLinkDisplayed() {
waitForView(withId(R.id.helpLink) + withText(R.string.accountDomainFooterLoginHelp) + withAncestor(withId(R.id.findSchoolRecyclerView))).assertDisplayed()
}

/**
* Clicks the "Tap here for login help." link.
*/
fun clickOnHowDoIFindMySchoolLink() {
waitForView(withId(R.id.helpLink) + withText(R.string.accountDomainFooterLoginHelp) + withAncestor(withId(R.id.findSchoolRecyclerView))).click()
}
}

Loading