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

[UI Test] Test for "login not WP" case. #13098

Draft
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Draft
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
@@ -0,0 +1,29 @@
{
"request": {
"method": "GET",
"urlPath": "/rest/v1.1/connect/site-info/",
"queryParameters": {
"url": {
"matches": ".*notawpsite.com.*"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remark, the . in the site address there matches any character, you might want to replace it with \\.

}
}
},
"response": {
"status": 200,
"jsonBody": {
"exists": true,
"isWordPress": false,
"hasJetpack": false,
"isJetpackActive": false,
"isJetpackConnected": false,
"isWordPressDotCom": false,
"urlAfterRedirects": "",
"jetpackVersion": false
},
"headers": {
"Content-Type": "application/json",
"Connection": "keep-alive",
"Cache-Control": "no-cache, must-revalidate, max-age=0"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
{
"request": {
"method": "GET",
"urlPath": "/rest/v1.1/connect/site-info/"
"request": {
"method": "GET",
"urlPath": "/rest/v1.1/connect/site-info/",
"queryParameters": {
"url": {
"matches": ".*automatticwidgets.wpcomstaging.com.*"
}
}
},
"response": {
"status": 200,
"jsonBody": {
"exists": true,
"isWordPress": true,
"hasJetpack": true,
"isJetpackActive": true,
"isJetpackConnected": true,
"isWordPressDotCom": true,
"urlAfterRedirects": "https:\/\/automatticwidgets.wpcomstaging.com",
"jetpackVersion": false
},
"response": {
"status": 200,
"jsonBody": {
"exists": true,
"isWordPress": true,
"hasJetpack": true,
"isJetpackActive": true,
"isJetpackConnected": true,
"isWordPressDotCom": true,
"urlAfterRedirects": "https:\/\/automatticwidgets.wpcomstaging.com",
"jetpackVersion": false
},
"headers": {
"Content-Type": "application/json",
"Connection": "keep-alive",
"Cache-Control": "no-cache, must-revalidate, max-age=0"
}
"headers": {
"Content-Type": "application/json",
"Connection": "keep-alive",
"Cache-Control": "no-cache, must-revalidate, max-age=0"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.woocommerce.android.e2e.screens.login

import androidx.test.espresso.Espresso
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.matcher.ViewMatchers
import com.woocommerce.android.R
import com.woocommerce.android.e2e.helpers.util.Screen

class LoginNotWPScreen : Screen {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remark, technically, the error is shown on the SiteAddressScreen, saying LoginNotWPScreen could be confusing in the future; I suggest putting the logic of this class in the same SiteAddressScreen class, and updating the openLoginNotWpScreen with something like enterNonWPAddress, WDYT?

companion object {
val ERROR_MESSAGE = R.string.login_not_wordpress_site_v2
}
constructor() : super(ERROR_MESSAGE)

fun assertErrorElements(): LoginNotWPScreen {
Espresso.onView(ViewMatchers.withText(R.string.login_try_another_store))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

Espresso.onView(ViewMatchers.withText(R.string.login_try_another_account))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))

return this
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ class SiteAddressScreen : Screen {

return EmailAddressScreen()
}

fun openLoginNotWpScreen(siteAddress: String): LoginNotWPScreen {
clickOn(org.wordpress.android.login.R.id.input)
typeTextInto(org.wordpress.android.login.R.id.input, siteAddress)
clickOn(R.id.bottom_button)
return LoginNotWPScreen()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@file:Suppress("DEPRECATION")

package com.woocommerce.android.e2e.tests.ui

import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.rule.ActivityTestRule
import com.woocommerce.android.e2e.helpers.InitializationRule
import com.woocommerce.android.e2e.helpers.TestBase
import com.woocommerce.android.e2e.rules.RetryTestRule
import com.woocommerce.android.e2e.screens.login.SiteAddressScreen
import com.woocommerce.android.e2e.screens.login.WelcomeScreen
import com.woocommerce.android.ui.login.LoginActivity
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.Before
import org.junit.Rule
import org.junit.Test

@HiltAndroidTest
class LoginUITest: TestBase() {
@get:Rule(order = 0)
val rule = HiltAndroidRule(this)

@get:Rule(order = 1)
val composeTestRule = createComposeRule()

@get:Rule(order = 2)
val initRule = InitializationRule()

@get:Rule(order = 3)
var activityRule = ActivityTestRule(LoginActivity::class.java)

@get:Rule(order = 4)
var retryTestRule = RetryTestRule()

@Before
fun setUp() {
WelcomeScreen
.skipCarouselIfNeeded()
.selectLogin()
}

@Test
fun siteAddressWithWrongURL() {
SiteAddressScreen()
.openLoginNotWpScreen(siteAddress = "notawpsite.com")
.assertErrorElements()
}
}
Loading