Skip to content

Commit

Permalink
update: [ANDROAPP-5575] Tests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAparicioAlbaAsenjo committed Oct 17, 2023
1 parent 1d4ac5e commit 4ec4a64
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const val CLEAR_BUTTON_TEST_TAG = "CLEAR_BUTTON"
const val UPLOAD_BUTTON_TEST_TAG = "UPLOAD_BUTTON"
const val ADD_BUTTON_TEST_TAG = "ADD_BUTTON"
const val PROGRESS_INDICATOR_TEST_TAG = "PROGRESS_INDICATOR"
const val UPLOAD_HELPER_TEST_TAG = "UPLOAD_HELPER"
const val UPLOAD_TEXT_FILE_NAME_TEST_TAG = "UPLOAD_TEXT_FILE_NAME"
const val UPLOAD_TEXT_FILE_WEIGHT_TEST_TAG = "UPLOAD_TEXT_FILE_WEIGHT"
const val SUPPORTING_TEXT_TEST_TAG = "SUPPORTING_TEXT"

@Composable
Expand Down Expand Up @@ -158,13 +159,15 @@ fun InputFileResource(
text = it,
style = MaterialTheme.typography.bodyLarge.copy(color = if (inputShellState != InputShellState.DISABLED) TextColor.OnSurface else TextColor.OnDisabledSurface),
maxLines = 1,
modifier = Modifier.testTag(INPUT_FILE_TEST_TAG + UPLOAD_TEXT_FILE_NAME_TEST_TAG),
)
}
fileWeight.value?.let {
Text(
text = " $it",
style = MaterialTheme.typography.bodyLarge.copy(TextColor.OnDisabledSurface),
maxLines = 1,
modifier = Modifier.testTag(INPUT_FILE_TEST_TAG + UPLOAD_TEXT_FILE_WEIGHT_TEST_TAG),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ class InputFileResourceTest {

rule.onNodeWithTag(INPUT_FILE_TEST_TAG + ADD_BUTTON_TEST_TAG).performClick()
rule.onNodeWithTag(INPUT_FILE_TEST_TAG + UPLOAD_BUTTON_TEST_TAG).assertExists()
rule.onNodeWithTag(INPUT_FILE_TEST_TAG + UPLOAD_HELPER_TEST_TAG).assertExists()
rule.onNodeWithTag(INPUT_FILE_TEST_TAG + UPLOAD_HELPER_TEST_TAG).assert(hasText(testFileName.value.toString() + " " + testFileWeight.value.toString()))
rule.onNodeWithTag(INPUT_FILE_TEST_TAG + UPLOAD_TEXT_FILE_NAME_TEST_TAG).assertExists()
rule.onNodeWithTag(INPUT_FILE_TEST_TAG + UPLOAD_TEXT_FILE_WEIGHT_TEST_TAG).assertExists()
rule.onNodeWithTag(INPUT_FILE_TEST_TAG + UPLOAD_TEXT_FILE_NAME_TEST_TAG).assert(hasText(testFileName.value.toString()))
rule.onNodeWithTag(INPUT_FILE_TEST_TAG + UPLOAD_TEXT_FILE_WEIGHT_TEST_TAG).assert(hasText(" " + testFileWeight.value.toString()))
}

@Test
Expand Down Expand Up @@ -94,12 +96,14 @@ class InputFileResourceTest {
onUploadFile = {},
)
}
rule.onNodeWithTag(INPUT_FILE_TEST_TAG + UPLOAD_HELPER_TEST_TAG).assert(hasText("test.filename.extension 256kb"))
rule.onNodeWithTag(INPUT_FILE_TEST_TAG + UPLOAD_TEXT_FILE_NAME_TEST_TAG).assert(hasText("test.filename.extension"))
rule.onNodeWithTag(INPUT_FILE_TEST_TAG + UPLOAD_TEXT_FILE_WEIGHT_TEST_TAG).assert(hasText(" 256kb"))
rule.onNodeWithTag(INPUT_FILE_TEST_TAG + CLEAR_BUTTON_TEST_TAG).performClick()
newFileName = "test_file"
newFileWeight = "512gb"
rule.onNodeWithTag(INPUT_FILE_TEST_TAG + ADD_BUTTON_TEST_TAG).performClick()
rule.onNodeWithTag(INPUT_FILE_TEST_TAG + UPLOAD_HELPER_TEST_TAG).assert(hasText("test_file 512gb"))
rule.onNodeWithTag(INPUT_FILE_TEST_TAG + UPLOAD_TEXT_FILE_NAME_TEST_TAG).assert(hasText("test_file"))
rule.onNodeWithTag(INPUT_FILE_TEST_TAG + UPLOAD_TEXT_FILE_WEIGHT_TEST_TAG).assert(hasText(" 512gb"))
}

@Test
Expand Down

0 comments on commit 4ec4a64

Please sign in to comment.