From 19e766548b40302d747db2417ecf87066bef059b Mon Sep 17 00:00:00 2001 From: dadachi Date: Thu, 30 Apr 2026 08:00:42 +0900 Subject: [PATCH] Fix dead password tests and add ItemTag whitespace-name regression tests Two bugs in test assertions found while auditing validators: 1. Three password tests in SignInEmailAndPasswordViewModelTest and SignUpViewModelTest called hasInvalidDataEmail() instead of hasInvalidDataPassword(). Email is blank by default in those setups, so assertions passed for the wrong reason and the password rules were never actually exercised. Pointed them at hasInvalidDataPassword(). 2. Added whitespaceOnlyName_isInvalid regression tests for both ItemTagCreateViewModel and ItemTagEditViewModel to lock in the isBlank() name validation already in place. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../app_root/SignInEmailAndPasswordViewModelTest.kt | 4 ++-- .../ui/app_root/SignUpViewModelTest.kt | 2 +- .../item_tag_detail/ItemTagEditViewModelTest.kt | 13 +++++++++++++ .../item_tag_list/ItemTagCreateViewModelTest.kt | 10 ++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/app_root/SignInEmailAndPasswordViewModelTest.kt b/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/app_root/SignInEmailAndPasswordViewModelTest.kt index 78919d8..a685535 100644 --- a/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/app_root/SignInEmailAndPasswordViewModelTest.kt +++ b/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/app_root/SignInEmailAndPasswordViewModelTest.kt @@ -97,7 +97,7 @@ class SignInEmailAndPasswordViewModelTest { viewModel.updatePassword("") - assertTrue(viewModel.hasInvalidDataEmail()) + assertTrue(viewModel.hasInvalidDataPassword()) } @Test @@ -106,7 +106,7 @@ class SignInEmailAndPasswordViewModelTest { viewModel.updatePassword("1234567") - assertTrue(viewModel.hasInvalidDataEmail()) + assertTrue(viewModel.hasInvalidDataPassword()) } } diff --git a/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/app_root/SignUpViewModelTest.kt b/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/app_root/SignUpViewModelTest.kt index ccd9dc2..00f01d2 100644 --- a/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/app_root/SignUpViewModelTest.kt +++ b/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/app_root/SignUpViewModelTest.kt @@ -109,7 +109,7 @@ class SignUpViewModelTest { viewModel.updatePassword("1234567") - assertTrue(viewModel.hasInvalidDataEmail()) + assertTrue(viewModel.hasInvalidDataPassword()) } } diff --git a/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/shop_settings/item_tag_detail/ItemTagEditViewModelTest.kt b/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/shop_settings/item_tag_detail/ItemTagEditViewModelTest.kt index 10a1aa2..c36c3dd 100644 --- a/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/shop_settings/item_tag_detail/ItemTagEditViewModelTest.kt +++ b/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/shop_settings/item_tag_detail/ItemTagEditViewModelTest.kt @@ -129,6 +129,19 @@ class ItemTagEditViewModelTest { assertTrue(viewModel.hasInvalidData()) } + @Test + fun whitespaceOnlyName_isInvalid() = runTest { + backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.uiState.collect() } + + itemTagRepository.sendItemTag(testInputItemTag) + viewModel.reload() + + viewModel.updateName(" ") + + assertTrue(viewModel.hasInvalidDataName()) + assertTrue(viewModel.hasInvalidData()) + } + @Test fun nameWithSymbolsAndUnicode_isValid() = runTest { backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.uiState.collect() } diff --git a/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/shop_settings/item_tag_list/ItemTagCreateViewModelTest.kt b/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/shop_settings/item_tag_list/ItemTagCreateViewModelTest.kt index 2381950..0e08bba 100644 --- a/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/shop_settings/item_tag_list/ItemTagCreateViewModelTest.kt +++ b/app/src/test/kotlin/com/nativeapptemplate/nativeapptemplatefree/ui/shop_settings/item_tag_list/ItemTagCreateViewModelTest.kt @@ -81,6 +81,16 @@ class ItemTagCreateViewModelTest { assertTrue(viewModel.hasInvalidData()) } + @Test + fun whitespaceOnlyName_isInvalid() = runTest { + backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.uiState.collect() } + + viewModel.updateName(" ") + + assertTrue(viewModel.hasInvalidDataName()) + assertTrue(viewModel.hasInvalidData()) + } + @Test fun singleCharacterName_isValid() = runTest { backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.uiState.collect() }