Skip to content

Commit e31d96c

Browse files
refactor: Add IDs to elements of landing, login, register, and what's new screens (#189)
refactor: add unique ID for all input fields and their titles in login screen - Title: (Sign In) - Text: (Welcome back! Please authorize to continue.) - Email and Password (Labels and TextFields) - Button: (Forgot password?) - Button (Sign In) - Text: (Or sign in with:) - Buttons: (Sign in with Google, Facebook, Microsoft and Apple) - On Forgot password page (Title, Text, Email label, Email field and Reset password button) refactor: add unique ID for all input fields and their titles in Register screen - Title: (Sign up) - Text: (Create new account.) - All Input Fields with Labels and notes under the Fields (Full name, public name, email, password) - Add ID and text: (Country or Region of Residence dropdown and its label) - ID to all buttons (Create account, Register with facebook, Microsoft and Apple) - Dropdowns: (Highest education and Gender) - Dropdown values (Country, education and Gender) refactor: add a Unique ID for Landing Screen - The title under the App logo (Courses and programs from the world's best universities in your pocket) - Text: (What do you want to learn?) - Textfield (Search our 3000+ courses) - Button: (Explore all courses) - Button: Register - Button: Sign in refactor: add a Unique ID for What's new Screen - Title and Close Button - Next, Previous & Done Buttons - fix crash on whats new screen fixes: LEARNER-9726
1 parent afcda48 commit e31d96c

File tree

10 files changed

+149
-41
lines changed

10 files changed

+149
-41
lines changed

app/src/main/java/org/openedx/app/di/ScreenModule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ val screenModule = module {
256256
)
257257
}
258258

259-
viewModel { (courseId: String) -> WhatsNewViewModel(courseId, get()) }
259+
viewModel { (courseId: String?) -> WhatsNewViewModel(courseId, get()) }
260260
viewModel {
261261
HtmlUnitViewModel(
262262
get(),

auth/src/main/java/org/openedx/auth/presentation/logistration/LogistrationFragment.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ import androidx.compose.runtime.getValue
2525
import androidx.compose.runtime.mutableStateOf
2626
import androidx.compose.runtime.saveable.rememberSaveable
2727
import androidx.compose.runtime.setValue
28+
import androidx.compose.ui.ExperimentalComposeUiApi
2829
import androidx.compose.ui.Modifier
2930
import androidx.compose.ui.graphics.ColorFilter
3031
import androidx.compose.ui.platform.ComposeView
3132
import androidx.compose.ui.platform.LocalFocusManager
3233
import androidx.compose.ui.platform.ViewCompositionStrategy
34+
import androidx.compose.ui.platform.testTag
3335
import androidx.compose.ui.res.painterResource
3436
import androidx.compose.ui.res.stringResource
37+
import androidx.compose.ui.semantics.semantics
38+
import androidx.compose.ui.semantics.testTagsAsResourceId
3539
import androidx.compose.ui.text.input.TextFieldValue
3640
import androidx.compose.ui.tooling.preview.Devices
3741
import androidx.compose.ui.tooling.preview.Preview
@@ -90,6 +94,7 @@ class LogistrationFragment : Fragment() {
9094
}
9195
}
9296

97+
@OptIn(ExperimentalComposeUiApi::class)
9398
@Composable
9499
private fun LogistrationScreen(
95100
onSearchClick: (String) -> Unit,
@@ -105,6 +110,9 @@ private fun LogistrationScreen(
105110
Scaffold(
106111
scaffoldState = scaffoldState,
107112
modifier = Modifier
113+
.semantics {
114+
testTagsAsResourceId = true
115+
}
108116
.fillMaxSize()
109117
.navigationBarsPadding(),
110118
backgroundColor = MaterialTheme.appColors.background
@@ -135,17 +143,22 @@ private fun LogistrationScreen(
135143
text = stringResource(id = R.string.pre_auth_title),
136144
color = MaterialTheme.appColors.textPrimary,
137145
style = MaterialTheme.appTypography.headlineSmall,
138-
modifier = Modifier.padding(bottom = 40.dp)
146+
modifier = Modifier
147+
.testTag("txt_screen_title")
148+
.padding(bottom = 40.dp)
139149
)
140150
val focusManager = LocalFocusManager.current
141151
Column(Modifier.padding(bottom = 8.dp)) {
142152
Text(
143-
modifier = Modifier.padding(bottom = 10.dp),
153+
modifier = Modifier
154+
.testTag("txt_search_label")
155+
.padding(bottom = 10.dp),
144156
style = MaterialTheme.appTypography.titleMedium,
145157
text = stringResource(id = R.string.pre_auth_search_title),
146158
)
147159
SearchBar(
148160
modifier = Modifier
161+
.testTag("tf_discovery_search")
149162
.fillMaxWidth()
150163
.height(48.dp),
151164
label = stringResource(id = R.string.pre_auth_search_hint),
@@ -166,6 +179,7 @@ private fun LogistrationScreen(
166179

167180
Text(
168181
modifier = Modifier
182+
.testTag("txt_explore_all_courses")
169183
.padding(bottom = 32.dp)
170184
.noRippleClickable {
171185
onSearchClick("")

auth/src/main/java/org/openedx/auth/presentation/restore/RestorePasswordFragment.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ import androidx.compose.runtime.remember
3535
import androidx.compose.runtime.saveable.rememberSaveable
3636
import androidx.compose.runtime.setValue
3737
import androidx.compose.ui.Alignment
38+
import androidx.compose.ui.ExperimentalComposeUiApi
3839
import androidx.compose.ui.Modifier
3940
import androidx.compose.ui.graphics.Color
4041
import androidx.compose.ui.layout.ContentScale
4142
import androidx.compose.ui.platform.ComposeView
4243
import androidx.compose.ui.platform.ViewCompositionStrategy
44+
import androidx.compose.ui.platform.testTag
4345
import androidx.compose.ui.res.painterResource
4446
import androidx.compose.ui.res.stringResource
47+
import androidx.compose.ui.semantics.semantics
48+
import androidx.compose.ui.semantics.testTagsAsResourceId
4549
import androidx.compose.ui.text.input.ImeAction
4650
import androidx.compose.ui.text.style.TextAlign
4751
import androidx.compose.ui.tooling.preview.Devices
@@ -112,6 +116,7 @@ class RestorePasswordFragment : Fragment() {
112116
}
113117
}
114118

119+
@OptIn(ExperimentalComposeUiApi::class)
115120
@Composable
116121
private fun RestorePasswordScreen(
117122
windowSize: WindowSize,
@@ -129,6 +134,9 @@ private fun RestorePasswordScreen(
129134
Scaffold(
130135
scaffoldState = scaffoldState,
131136
modifier = Modifier
137+
.semantics {
138+
testTagsAsResourceId = true
139+
}
132140
.fillMaxSize()
133141
.navigationBarsPadding(),
134142
backgroundColor = MaterialTheme.appColors.background
@@ -200,6 +208,7 @@ private fun RestorePasswordScreen(
200208
) {
201209
Text(
202210
modifier = Modifier
211+
.testTag("txt_screen_title")
203212
.fillMaxWidth(),
204213
text = stringResource(id = authR.string.auth_forgot_your_password),
205214
color = Color.White,
@@ -216,8 +225,7 @@ private fun RestorePasswordScreen(
216225
}
217226

218227
Surface(
219-
modifier = Modifier
220-
.fillMaxWidth(),
228+
modifier = Modifier.fillMaxWidth(),
221229
color = MaterialTheme.appColors.background,
222230
shape = MaterialTheme.appShapes.screenBackgroundShape
223231
) {
@@ -239,6 +247,7 @@ private fun RestorePasswordScreen(
239247
) {
240248
Text(
241249
modifier = Modifier
250+
.testTag("txt_forgot_password_title")
242251
.fillMaxWidth(),
243252
text = stringResource(id = authR.string.auth_forgot_your_password),
244253
style = MaterialTheme.appTypography.displaySmall,
@@ -247,6 +256,7 @@ private fun RestorePasswordScreen(
247256
Spacer(Modifier.height(2.dp))
248257
Text(
249258
modifier = Modifier
259+
.testTag("txt_forgot_password_description")
250260
.fillMaxWidth(),
251261
text = stringResource(id = authR.string.auth_please_enter_your_log_in),
252262
style = MaterialTheme.appTypography.titleSmall,
@@ -279,7 +289,7 @@ private fun RestorePasswordScreen(
279289
}
280290
} else {
281291
OpenEdXButton(
282-
width = buttonWidth,
292+
width = buttonWidth.testTag("btn_reset_password"),
283293
text = stringResource(id = authR.string.auth_reset_password),
284294
onClick = {
285295
onRestoreButtonClick(email)

auth/src/main/java/org/openedx/auth/presentation/signin/compose/SignInView.kt

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ import androidx.compose.runtime.remember
3737
import androidx.compose.runtime.saveable.rememberSaveable
3838
import androidx.compose.runtime.setValue
3939
import androidx.compose.ui.Alignment
40+
import androidx.compose.ui.ExperimentalComposeUiApi
4041
import androidx.compose.ui.Modifier
4142
import androidx.compose.ui.graphics.Color
4243
import androidx.compose.ui.layout.ContentScale
4344
import androidx.compose.ui.platform.LocalFocusManager
45+
import androidx.compose.ui.platform.testTag
4446
import androidx.compose.ui.res.painterResource
4547
import androidx.compose.ui.res.stringResource
48+
import androidx.compose.ui.semantics.semantics
49+
import androidx.compose.ui.semantics.testTagsAsResourceId
4650
import androidx.compose.ui.text.input.ImeAction
4751
import androidx.compose.ui.text.input.KeyboardType
4852
import androidx.compose.ui.text.input.PasswordVisualTransformation
@@ -71,6 +75,7 @@ import org.openedx.core.ui.theme.appTypography
7175
import org.openedx.core.ui.windowSizeValue
7276
import org.openedx.core.R as coreR
7377

78+
@OptIn(ExperimentalComposeUiApi::class)
7479
@Composable
7580
internal fun LoginScreen(
7681
windowSize: WindowSize,
@@ -84,6 +89,9 @@ internal fun LoginScreen(
8489
Scaffold(
8590
scaffoldState = scaffoldState,
8691
modifier = Modifier
92+
.semantics {
93+
testTagsAsResourceId = true
94+
}
8795
.fillMaxSize()
8896
.navigationBarsPadding(),
8997
backgroundColor = MaterialTheme.appColors.background
@@ -173,12 +181,15 @@ internal fun LoginScreen(
173181
.then(contentPaddings),
174182
) {
175183
Text(
184+
modifier = Modifier.testTag("txt_sign_in_title"),
176185
text = stringResource(id = coreR.string.core_sign_in),
177186
color = MaterialTheme.appColors.textPrimary,
178187
style = MaterialTheme.appTypography.displaySmall
179188
)
180189
Text(
181-
modifier = Modifier.padding(top = 4.dp),
190+
modifier = Modifier
191+
.testTag("txt_sign_in_description")
192+
.padding(top = 4.dp),
182193
text = stringResource(id = R.string.auth_welcome_back),
183194
color = MaterialTheme.appColors.textPrimary,
184195
style = MaterialTheme.appTypography.titleSmall
@@ -234,19 +245,23 @@ private fun AuthForm(
234245
) {
235246
if (state.isLogistrationEnabled.not()) {
236247
Text(
237-
modifier = Modifier.noRippleClickable {
238-
onEvent(AuthEvent.RegisterClick)
239-
},
248+
modifier = Modifier
249+
.testTag("txt_register")
250+
.noRippleClickable {
251+
onEvent(AuthEvent.RegisterClick)
252+
},
240253
text = stringResource(id = coreR.string.core_register),
241254
color = MaterialTheme.appColors.primary,
242255
style = MaterialTheme.appTypography.labelLarge
243256
)
244257
}
245258
Spacer(modifier = Modifier.weight(1f))
246259
Text(
247-
modifier = Modifier.noRippleClickable {
248-
onEvent(AuthEvent.ForgotPasswordClick)
249-
},
260+
modifier = Modifier
261+
.testTag("txt_forgot_password")
262+
.noRippleClickable {
263+
onEvent(AuthEvent.ForgotPasswordClick)
264+
},
250265
text = stringResource(id = R.string.auth_forgot_password),
251266
color = MaterialTheme.appColors.primary,
252267
style = MaterialTheme.appTypography.labelLarge
@@ -257,7 +272,7 @@ private fun AuthForm(
257272
CircularProgressIndicator(color = MaterialTheme.appColors.primary)
258273
} else {
259274
OpenEdXButton(
260-
width = buttonWidth,
275+
width = buttonWidth.testTag("btn_sign_in"),
261276
text = stringResource(id = coreR.string.core_sign_in),
262277
onClick = {
263278
onEvent(AuthEvent.SignIn(login = login, password = password))
@@ -278,7 +293,9 @@ private fun SocialLoginView(
278293
) {
279294
if (state.isGoogleAuthEnabled) {
280295
OpenEdXOutlinedButton(
281-
modifier = buttonWidth.padding(top = 24.dp),
296+
modifier = buttonWidth
297+
.testTag("btn_google_auth")
298+
.padding(top = 24.dp),
282299
backgroundColor = MaterialTheme.appColors.background,
283300
borderColor = MaterialTheme.appColors.primary,
284301
textColor = Color.Unspecified,
@@ -293,15 +310,19 @@ private fun SocialLoginView(
293310
tint = Color.Unspecified,
294311
)
295312
Text(
296-
modifier = Modifier.padding(start = 10.dp),
313+
modifier = Modifier
314+
.testTag("txt_google_auth")
315+
.padding(start = 10.dp),
297316
text = stringResource(id = R.string.auth_google)
298317
)
299318
}
300319
}
301320
}
302321
if (state.isFacebookAuthEnabled) {
303322
OpenEdXButton(
304-
width = buttonWidth.padding(top = 12.dp),
323+
width = buttonWidth
324+
.testTag("btn_facebook_auth")
325+
.padding(top = 12.dp),
305326
text = stringResource(id = R.string.auth_facebook),
306327
backgroundColor = MaterialTheme.appColors.authFacebookButtonBackground,
307328
onClick = {
@@ -315,7 +336,9 @@ private fun SocialLoginView(
315336
tint = MaterialTheme.appColors.buttonText,
316337
)
317338
Text(
318-
modifier = Modifier.padding(start = 10.dp),
339+
modifier = Modifier
340+
.testTag("txt_facebook_auth")
341+
.padding(start = 10.dp),
319342
color = MaterialTheme.appColors.buttonText,
320343
text = stringResource(id = R.string.auth_facebook)
321344
)
@@ -324,7 +347,9 @@ private fun SocialLoginView(
324347
}
325348
if (state.isMicrosoftAuthEnabled) {
326349
OpenEdXButton(
327-
width = buttonWidth.padding(top = 12.dp),
350+
width = buttonWidth
351+
.testTag("btn_microsoft_auth")
352+
.padding(top = 12.dp),
328353
text = stringResource(id = R.string.auth_microsoft),
329354
backgroundColor = MaterialTheme.appColors.authMicrosoftButtonBackground,
330355
onClick = {
@@ -338,7 +363,9 @@ private fun SocialLoginView(
338363
tint = Color.Unspecified,
339364
)
340365
Text(
341-
modifier = Modifier.padding(start = 10.dp),
366+
modifier = Modifier
367+
.testTag("txt_microsoft_auth")
368+
.padding(start = 10.dp),
342369
color = MaterialTheme.appColors.buttonText,
343370
text = stringResource(id = R.string.auth_microsoft)
344371
)
@@ -360,14 +387,16 @@ private fun PasswordTextField(
360387
}
361388
val focusManager = LocalFocusManager.current
362389
Text(
363-
modifier = Modifier.fillMaxWidth(),
390+
modifier = Modifier
391+
.testTag("txt_password_label")
392+
.fillMaxWidth(),
364393
text = stringResource(id = coreR.string.core_password),
365394
color = MaterialTheme.appColors.textPrimary,
366395
style = MaterialTheme.appTypography.labelLarge
367396
)
368397
Spacer(modifier = Modifier.height(8.dp))
369398
OutlinedTextField(
370-
modifier = modifier,
399+
modifier = modifier.testTag("tf_password"),
371400
value = passwordTextFieldValue,
372401
onValueChange = {
373402
passwordTextFieldValue = it
@@ -380,6 +409,7 @@ private fun PasswordTextField(
380409
shape = MaterialTheme.appShapes.textFieldShape,
381410
placeholder = {
382411
Text(
412+
modifier = Modifier.testTag("txt_password_placeholder"),
383413
text = stringResource(id = R.string.auth_enter_password),
384414
color = MaterialTheme.appColors.textFieldHint,
385415
style = MaterialTheme.appTypography.bodyMedium

0 commit comments

Comments
 (0)