I'm trying to write some test cases for my compose functions. I have an outlined Text field with a maximum value of 16 characters. So I want to test this feature. Here is the test:
    @Test
    fun checkMaxTaxCodeLength_16Character() {
        val taxCode = composeRule.onNodeWithTag(testTag = AUTHENTICATION_SCREEN_TAX_CODE_EDIT_TEXT)
        for (i in 'A'..'Z')
            taxCode.performTextInput(i.toString())
        taxCode.assertTextEquals("ABCDEFGHIJKLMNOP")
    }
But although I can see the input is correct, the test fails, and it seems assertTextEquals doesn't work correctly. So:
- first of all, what am I doing wrong?
 - Second, is there any way to, instead of checking the equality, check the text does not contain specific characters?
 
here is the code of text field:
                OutlinedTextField(
                    value = state.taxCode,
                    maxLines = 1,
                    onValueChange = { string ->
                        viewModel.onEvent(
                            AuthenticationEvent.TaxCodeChanged(string)
                        )
                    },
                    label = {
                        Text(text = stringResource(id = R.string.tax_code))
                    },
                    modifier = Modifier
                        .fillMaxWidth()
                        .testTag(TestingConstant.AUTHENTICATION_SCREEN_TAX_CODE_EDIT_TEXT)
                )
The maximum length is handled in the view model. If the user adds more characters than 16, the view model won't update the state and keep the old value.