package com.complycube.reactnative.config import com.complycube.reactnative.config.* import com.complycube.reactnative.config.helper.TestColorConverter import kotlin.test.Test import kotlin.test.assertTrue import kotlin.test.assertEquals class ComplyCubeConfigBuilderTest { @Test fun workflowTemplateSkipsStageParsing() { val builder = ComplyCubeConfigurationFactory(TestColorConverter()).createConfigBuilder() val settings = TestFixtures.baseSettings().apply { put("workflowTemplateId", "wf_123") put("designTokens", TestFixtures.designTokens()) } val result = builder.build(settings) assertTrue(result is ValidationResult.Success) val config = (result as ValidationResult.Success).data assertEquals("wf_123", config.workflowTemplateId) assertTrue(config.stages.isEmpty()) assertTrue(config.designTokens != null) } @Test fun stagesDesignTokensLookAndFeelAndSchemeAreParsed() { val builder = ComplyCubeConfigurationFactory(TestColorConverter()).createConfigBuilder() val settings = TestFixtures.baseSettings().apply { put("stages", listOf(TestFixtures.stageDocumentCapture())) put("designTokens", TestFixtures.designTokens()) put("lookAndFeel", mapOf( "uiInterfaceStyle" to "dark", "borderRadius" to 6, "primaryButtonBgColor" to "#010203" )) put("colorScheme", mapOf( "docTypeBgColor" to "#0A0B0C", "primaryButtonTextColor" to "#010203" )) } val result = builder.build(settings) assertTrue(result is ValidationResult.Success) val config = (result as ValidationResult.Success).data assertTrue(config.stages.isNotEmpty()) assertTrue(config.designTokens != null) assertTrue(config.lookAndFeel != null) assertTrue(config.colorScheme != null) assertTrue(config.countries.isNotEmpty()) } @Test fun errorsDuringParsingReturnValidationError() { val builder = ComplyCubeConfigurationFactory(TestColorConverter()).createConfigBuilder() val settings = TestFixtures.baseSettings().apply { put("stages", listOf(TestFixtures.stageDocumentCapture())) put("lookAndFeel", mapOf( "primaryButtonBgColor" to 123 )) } val result = builder.build(settings) assertTrue(result is ValidationResult.Error) } @Test fun invalidDesignTokensReturnValidationError() { val builder = ComplyCubeConfigurationFactory(TestColorConverter()).createConfigBuilder() val settings = TestFixtures.baseSettings().apply { put("workflowTemplateId", "wf_123") put( "designTokens", mapOf( "theme" to "dark", "animations" to "enabled" ) ) } val result = builder.build(settings) assertTrue(result is ValidationResult.Error) } }