Skip to content

Commit e3de573

Browse files
committed
test: e2e ids for profile and contacts
Made-with: Cursor
1 parent 0b23ded commit e3de573

14 files changed

Lines changed: 179 additions & 55 deletions

app/src/main/java/to/bitkit/ui/components/AddLinkSheet.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import androidx.compose.runtime.setValue
2020
import androidx.compose.ui.Modifier
2121
import androidx.compose.ui.platform.LocalFocusManager
2222
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
23+
import androidx.compose.ui.platform.testTag
2324
import androidx.compose.ui.res.painterResource
2425
import androidx.compose.ui.res.stringResource
2526
import androidx.compose.ui.tooling.preview.Preview
@@ -119,7 +120,9 @@ private fun LinkFormContent(
119120
placeholder = stringResource(R.string.profile__add_link_label_placeholder),
120121
trailingIcon = { SuggestionsButton(onClick = onShowSuggestions) },
121122
singleLine = true,
122-
modifier = Modifier.fillMaxWidth()
123+
modifier = Modifier
124+
.fillMaxWidth()
125+
.testTag("AddLinkLabel"),
123126
)
124127
VerticalSpacer(16.dp)
125128
Text13Up(text = stringResource(R.string.profile__add_link_url))
@@ -129,7 +132,9 @@ private fun LinkFormContent(
129132
onValueChange = onUrlChange,
130133
placeholder = stringResource(R.string.profile__add_link_url_placeholder),
131134
singleLine = true,
132-
modifier = Modifier.fillMaxWidth()
135+
modifier = Modifier
136+
.fillMaxWidth()
137+
.testTag("AddLinkUrl"),
133138
)
134139
VerticalSpacer(8.dp)
135140
BodyS(
@@ -141,6 +146,7 @@ private fun LinkFormContent(
141146
text = stringResource(R.string.common__save),
142147
onClick = onSave,
143148
enabled = isSaveEnabled,
149+
modifier = Modifier.testTag("AddLinkSave"),
144150
)
145151
VerticalSpacer(16.dp)
146152
}
@@ -178,7 +184,10 @@ internal fun SuggestionsContent(
178184

179185
@Composable
180186
private fun SuggestionsButton(onClick: () -> Unit) {
181-
TextButton(onClick = onClick) {
187+
TextButton(
188+
onClick = onClick,
189+
modifier = Modifier.testTag("AddLinkSuggestions"),
190+
) {
182191
Icon(
183192
painter = painterResource(R.drawable.ic_lightbulb),
184193
contentDescription = null,

app/src/main/java/to/bitkit/ui/components/AddTagSheet.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import androidx.compose.runtime.setValue
1717
import androidx.compose.ui.Modifier
1818
import androidx.compose.ui.platform.LocalFocusManager
1919
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
20+
import androidx.compose.ui.platform.testTag
2021
import androidx.compose.ui.res.painterResource
2122
import androidx.compose.ui.res.stringResource
2223
import androidx.compose.ui.tooling.preview.Preview
@@ -109,21 +110,27 @@ private fun TagFormContent(
109110
placeholder = stringResource(R.string.profile__add_tag_placeholder),
110111
trailingIcon = { SuggestionsButton(onClick = onShowSuggestions) },
111112
singleLine = true,
112-
modifier = Modifier.fillMaxWidth()
113+
modifier = Modifier
114+
.fillMaxWidth()
115+
.testTag("AddTagInput"),
113116
)
114117
VerticalSpacer(24.dp)
115118
PrimaryButton(
116119
text = stringResource(R.string.common__save),
117120
onClick = onSave,
118121
enabled = isSaveEnabled,
122+
modifier = Modifier.testTag("AddTagSave"),
119123
)
120124
VerticalSpacer(16.dp)
121125
}
122126
}
123127

124128
@Composable
125129
private fun SuggestionsButton(onClick: () -> Unit) {
126-
TextButton(onClick = onClick) {
130+
TextButton(
131+
onClick = onClick,
132+
modifier = Modifier.testTag("AddTagSuggestions"),
133+
) {
127134
Icon(
128135
painter = painterResource(R.drawable.ic_lightbulb),
129136
contentDescription = null,

app/src/main/java/to/bitkit/ui/components/CenteredProfileHeader.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import androidx.compose.runtime.Composable
1010
import androidx.compose.ui.Alignment
1111
import androidx.compose.ui.Modifier
1212
import androidx.compose.ui.draw.clip
13+
import androidx.compose.ui.platform.testTag
1314
import androidx.compose.ui.res.painterResource
1415
import androidx.compose.ui.text.style.TextAlign
1516
import androidx.compose.ui.tooling.preview.Preview
@@ -28,6 +29,8 @@ fun CenteredProfileHeader(
2829
bio: String,
2930
imageUrl: String?,
3031
modifier: Modifier = Modifier,
32+
nameTestTag: String? = null,
33+
notesTestTag: String? = null,
3134
) {
3235
Column(
3336
horizontalAlignment = Alignment.CenterHorizontally,
@@ -62,14 +65,18 @@ fun CenteredProfileHeader(
6265

6366
VerticalSpacer(16.dp)
6467

65-
Display(text = name)
68+
Display(
69+
text = name,
70+
modifier = if (nameTestTag != null) Modifier.testTag(nameTestTag) else Modifier,
71+
)
6672

6773
if (bio.isNotEmpty()) {
6874
VerticalSpacer(8.dp)
6975
BodyM(
7076
text = bio,
7177
color = Colors.White64,
7278
textAlign = TextAlign.Center,
79+
modifier = if (notesTestTag != null) Modifier.testTag(notesTestTag) else Modifier,
7380
)
7481
}
7582
}

app/src/main/java/to/bitkit/ui/components/LinkRow.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,29 @@ import androidx.compose.foundation.layout.fillMaxWidth
55
import androidx.compose.material3.HorizontalDivider
66
import androidx.compose.runtime.Composable
77
import androidx.compose.ui.Modifier
8+
import androidx.compose.ui.platform.testTag
89
import androidx.compose.ui.unit.dp
910
import to.bitkit.ui.theme.Colors
1011

1112
@Composable
1213
fun LinkRow(
1314
label: String,
1415
value: String,
16+
linkIndex: Int,
1517
modifier: Modifier = Modifier,
1618
) {
1719
Column(modifier = modifier.fillMaxWidth()) {
1820
VerticalSpacer(16.dp)
19-
Text13Up(text = label, color = Colors.White64)
21+
Text13Up(
22+
text = label,
23+
color = Colors.White64,
24+
modifier = Modifier.testTag("ProfileLinkLabel_$linkIndex"),
25+
)
2026
VerticalSpacer(8.dp)
21-
BodySSB(text = value)
27+
BodySSB(
28+
text = value,
29+
modifier = Modifier.testTag("ProfileLinkValue_$linkIndex"),
30+
)
2231
VerticalSpacer(16.dp)
2332
HorizontalDivider()
2433
}

app/src/main/java/to/bitkit/ui/components/ProfileEditForm.kt

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import androidx.compose.runtime.remember
2222
import androidx.compose.runtime.setValue
2323
import androidx.compose.ui.Alignment
2424
import androidx.compose.ui.Modifier
25+
import androidx.compose.ui.platform.testTag
2526
import androidx.compose.ui.res.painterResource
2627
import androidx.compose.ui.res.stringResource
2728
import androidx.compose.ui.text.style.TextAlign
@@ -85,7 +86,9 @@ fun ProfileEditForm(
8586
singleLine = true,
8687
textStyle = AppTextStyles.Display.copy(textAlign = TextAlign.Center),
8788
colors = AppTextFieldDefaults.transparent,
88-
modifier = Modifier.fillMaxWidth()
89+
modifier = Modifier
90+
.fillMaxWidth()
91+
.testTag("ProfileEditName"),
8992
)
9093
HorizontalDivider()
9194
VerticalSpacer(12.dp)
@@ -115,7 +118,9 @@ fun ProfileEditForm(
115118
placeholder = stringResource(R.string.profile__edit_bio_placeholder),
116119
minLines = 2,
117120
maxLines = 4,
118-
modifier = Modifier.fillMaxWidth()
121+
modifier = Modifier
122+
.fillMaxWidth()
123+
.testTag("ProfileEditBio"),
119124
)
120125

121126
VerticalSpacer(16.dp)
@@ -143,7 +148,9 @@ fun ProfileEditForm(
143148
)
144149
}
145150
},
146-
modifier = Modifier.fillMaxWidth()
151+
modifier = Modifier
152+
.fillMaxWidth()
153+
.testTag("ProfileEditLink_$index"),
147154
)
148155
VerticalSpacer(8.dp)
149156
}
@@ -160,6 +167,7 @@ fun ProfileEditForm(
160167
modifier = Modifier.size(16.dp)
161168
)
162169
},
170+
modifier = Modifier.testTag("ProfileEditAddLink"),
163171
)
164172
}
165173

@@ -197,6 +205,7 @@ fun ProfileEditForm(
197205
modifier = Modifier.size(16.dp)
198206
)
199207
},
208+
modifier = Modifier.testTag("ProfileEditAddTag"),
200209
)
201210
}
202211

@@ -209,30 +218,32 @@ fun ProfileEditForm(
209218
}
210219

211220
if (onDelete != null) {
212-
VerticalSpacer(16.dp)
213-
HorizontalDivider()
214-
VerticalSpacer(16.dp)
215-
Text13Up(
216-
text = stringResource(R.string.profile__edit_delete_section),
217-
color = Colors.White64,
218-
modifier = Modifier.fillMaxWidth()
219-
)
220-
VerticalSpacer(8.dp)
221-
Row(modifier = Modifier.fillMaxWidth()) {
222-
PrimaryButton(
223-
text = deleteLabel,
224-
onClick = onDelete,
225-
size = ButtonSize.Small,
226-
fullWidth = false,
227-
icon = {
228-
Icon(
229-
painter = painterResource(R.drawable.ic_trash),
230-
contentDescription = null,
231-
tint = Colors.Red,
232-
modifier = Modifier.size(16.dp)
233-
)
234-
},
221+
Column(modifier = Modifier.testTag("ProfileEditDelete")) {
222+
VerticalSpacer(16.dp)
223+
HorizontalDivider()
224+
VerticalSpacer(16.dp)
225+
Text13Up(
226+
text = stringResource(R.string.profile__edit_delete_section),
227+
color = Colors.White64,
228+
modifier = Modifier.fillMaxWidth()
235229
)
230+
VerticalSpacer(8.dp)
231+
Row(modifier = Modifier.fillMaxWidth()) {
232+
PrimaryButton(
233+
text = deleteLabel,
234+
onClick = onDelete,
235+
size = ButtonSize.Small,
236+
fullWidth = false,
237+
icon = {
238+
Icon(
239+
painter = painterResource(R.drawable.ic_trash),
240+
contentDescription = null,
241+
tint = Colors.Red,
242+
modifier = Modifier.size(16.dp)
243+
)
244+
},
245+
)
246+
}
236247
}
237248
}
238249

@@ -245,13 +256,17 @@ fun ProfileEditForm(
245256
SecondaryButton(
246257
text = stringResource(R.string.common__cancel),
247258
onClick = onCancel,
248-
modifier = Modifier.weight(1f)
259+
modifier = Modifier
260+
.weight(1f)
261+
.testTag("ProfileEditCancel"),
249262
)
250263
PrimaryButton(
251264
text = stringResource(R.string.common__save),
252265
onClick = onSave,
253266
enabled = isSaveEnabled,
254-
modifier = Modifier.weight(1f)
267+
modifier = Modifier
268+
.weight(1f)
269+
.testTag("ProfileEditSave"),
255270
)
256271
}
257272
VerticalSpacer(16.dp)

app/src/main/java/to/bitkit/ui/screens/contacts/ContactDetailScreen.kt

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import androidx.compose.runtime.getValue
1818
import androidx.compose.ui.Alignment
1919
import androidx.compose.ui.Modifier
2020
import androidx.compose.ui.platform.LocalContext
21+
import androidx.compose.ui.platform.testTag
2122
import androidx.compose.ui.res.painterResource
2223
import androidx.compose.ui.res.stringResource
2324
import androidx.compose.ui.tooling.preview.Preview
@@ -165,6 +166,8 @@ private fun ContactBody(
165166
name = profile.name,
166167
bio = profile.bio,
167168
imageUrl = profile.imageUrl,
169+
nameTestTag = "ContactViewName",
170+
notesTestTag = "ContactViewNotes",
168171
)
169172

170173
VerticalSpacer(24.dp)
@@ -173,21 +176,41 @@ private fun ContactBody(
173176
horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.CenterHorizontally),
174177
modifier = Modifier.fillMaxWidth(),
175178
) {
176-
ActionButton(onClick = onClickCopy, iconRes = R.drawable.ic_copy)
177-
ActionButton(onClick = onClickShare, iconRes = R.drawable.ic_share)
178-
ActionButton(onClick = onClickEdit, iconRes = R.drawable.ic_edit)
179-
ActionButton(onClick = onClickDelete, iconRes = R.drawable.ic_trash)
179+
ActionButton(
180+
onClick = onClickCopy,
181+
iconRes = R.drawable.ic_copy,
182+
modifier = Modifier.testTag("ContactCopy"),
183+
)
184+
ActionButton(
185+
onClick = onClickShare,
186+
iconRes = R.drawable.ic_share,
187+
modifier = Modifier.testTag("ContactShare"),
188+
)
189+
ActionButton(
190+
onClick = onClickEdit,
191+
iconRes = R.drawable.ic_edit,
192+
modifier = Modifier.testTag("ContactEdit"),
193+
)
194+
ActionButton(
195+
onClick = onClickDelete,
196+
iconRes = R.drawable.ic_trash,
197+
modifier = Modifier.testTag("ContactDelete"),
198+
)
180199
}
181200

182201
VerticalSpacer(32.dp)
183202

184-
profile.links.forEach { LinkRow(label = it.label, value = it.url) }
203+
profile.links.forEachIndexed { index, link ->
204+
LinkRow(label = link.label, value = link.url, linkIndex = index)
205+
}
185206

186207
VerticalSpacer(16.dp)
187208
Text13Up(
188209
text = stringResource(R.string.profile__edit_tags),
189210
color = Colors.White64,
190-
modifier = Modifier.fillMaxWidth()
211+
modifier = Modifier
212+
.fillMaxWidth()
213+
.testTag("ContactViewTagsHeader"),
191214
)
192215
VerticalSpacer(8.dp)
193216
FlowRow(
@@ -210,6 +233,7 @@ private fun ContactBody(
210233
onClick = onAddTag,
211234
icon = painterResource(R.drawable.ic_tag),
212235
displayIconClose = true,
236+
modifier = Modifier.testTag("ContactAddTag"),
213237
)
214238
}
215239
}
@@ -239,6 +263,7 @@ private fun EmptyState(onClickRetry: () -> Unit) {
239263
SecondaryButton(
240264
text = stringResource(R.string.profile__retry_load),
241265
onClick = onClickRetry,
266+
modifier = Modifier.testTag("ContactRetry"),
242267
)
243268
}
244269
}

app/src/main/java/to/bitkit/ui/screens/contacts/ContactsIntroScreen.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
66
import androidx.compose.foundation.layout.padding
77
import androidx.compose.runtime.Composable
88
import androidx.compose.ui.Modifier
9+
import androidx.compose.ui.platform.testTag
910
import androidx.compose.ui.res.painterResource
1011
import androidx.compose.ui.res.stringResource
1112
import androidx.compose.ui.tooling.preview.Preview
@@ -38,7 +39,7 @@ private fun Content(
3839
onContinue: () -> Unit,
3940
onBackClick: () -> Unit,
4041
) {
41-
ScreenColumn {
42+
ScreenColumn(modifier = Modifier.testTag("ContactsIntro")) {
4243
AppTopBar(
4344
titleText = stringResource(R.string.contacts__nav_title),
4445
onBackClick = onBackClick,
@@ -67,6 +68,7 @@ private fun Content(
6768
PrimaryButton(
6869
text = stringResource(R.string.contacts__intro_add_contact),
6970
onClick = onContinue,
71+
modifier = Modifier.testTag("ContactsIntro-button")
7072
)
7173
VerticalSpacer(16.dp)
7274
}

0 commit comments

Comments
 (0)