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 6 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.*"
}
}
},
"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
@@ -1,16 +1,41 @@
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 SiteAddressScreen : Screen {
constructor() : super(org.wordpress.android.login.R.id.input)

companion object {
val ERROR_MESSAGE = R.string.login_not_wordpress_site_v2
}

fun proceedWith(siteAddress: String): EmailAddressScreen {
clickOn(org.wordpress.android.login.R.id.input)
typeTextInto(org.wordpress.android.login.R.id.input, siteAddress)
clickOn(R.id.bottom_button)

return EmailAddressScreen()
}

fun enterNonWPAddress(siteAddress: String): SiteAddressScreen {
clickOn(org.wordpress.android.login.R.id.input)
typeTextInto(org.wordpress.android.login.R.id.input, siteAddress)
clickOn(R.id.bottom_button)

return this
}

fun assertErrorElements(): SiteAddressScreen {
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
@@ -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()
.enterNonWPAddress(siteAddress = "notawpsite.com")
.assertErrorElements()
}
}
Loading