-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Expand file tree
/
Copy pathAppTest.kt
More file actions
63 lines (53 loc) · 2.28 KB
/
AppTest.kt
File metadata and controls
63 lines (53 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* Copyright 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.jetsnack
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.v2.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import com.example.jetsnack.ui.MainActivity
import org.junit.Rule
import org.junit.Test
class AppTest {
@get:Rule
val composeTestRule = createAndroidComposeRule<MainActivity>()
@Test
fun app_launches() {
// Check app launches at the correct destination
composeTestRule.onNodeWithText("HOME").assertIsDisplayed()
composeTestRule.onNodeWithText("Android's picks").assertIsDisplayed()
}
@Test
fun app_canNavigateToAllScreens() {
// Check app launches at HOME
composeTestRule.onNodeWithText("HOME").assertIsDisplayed()
composeTestRule.onNodeWithText("Android's picks").assertIsDisplayed()
// Navigate to Search
composeTestRule.onNodeWithText("SEARCH").performClick().assertIsDisplayed()
composeTestRule.onNodeWithText("Categories").assertIsDisplayed()
// Navigate to Cart
composeTestRule.onNodeWithText("MY CART").performClick().assertIsDisplayed()
composeTestRule.onNodeWithText("Order (3 items)").assertIsDisplayed()
// Navigate to Profile
composeTestRule.onNodeWithText("PROFILE").performClick().assertIsDisplayed()
composeTestRule.onNodeWithText("This is currently work in progress").assertIsDisplayed()
}
@Test
fun app_canNavigateToDetailPage() {
composeTestRule.onNodeWithText("Chips").performClick()
composeTestRule.onNodeWithText("Lorem ipsum", substring = true).assertIsDisplayed()
}
}