You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Missed clean FlakySafeSemanticsBehaviorInterceptor when removing flakySafely intrceptors inside FlakySafeInterceptorScalpel
temp solution to local fix:
Fix
importcom.kaspersky.components.composesupport.config.ComposeConfigimportcom.kaspersky.components.composesupport.config.ComposeInterceptorsInjectorimportcom.kaspersky.components.composesupport.interceptors.behavior.impl.flakysafety.FlakySafeSemanticsBehaviorInterceptorimportcom.kaspersky.kaspresso.flakysafety.FlakySafetyProviderGlobalImplimportcom.kaspersky.kaspresso.kaspresso.Kaspressoimportcom.kaspersky.kaspresso.testcases.core.testcontext.BaseTestContextimportcom.kaspersky.kaspresso.testcases.core.testcontext.TestContextimportio.mockk.everyimportio.mockk.spyk/*** Магия рефлексии вперемешку с рантайм моками и всякой грязью, если вы читаете эти строки, то лучше* закройте этот файл и забудьте, что когда-либо заходили сюда.** Если вы все еще хотите продолжить, то в начале найлейте себе бокальчик пива и забейте кальян ибо дальше* вас ждет ад.** АСТАНАВИТЕСЬ, не надо!** @param kaspressoBuilder - надо.*/internalfun TestContext<Unit>.fixFlakySafety(kaspressoBuilder:Kaspresso.Builder) {
val fakeBuilder =ComposeConfig.Builder.default(
kaspressoBuilder = kaspressoBuilder,
lateComposeCustomize = {}
)
val context =thisval flakySafetyProvider = context.flakySafetyProvider
val originalScalpel = flakySafetyProvider.flakySafeInterceptorScalpel
val flakySafeInterceptorScalpelClass =this::class.java.classLoader!!
.loadClass("com.kaspersky.kaspresso.flakysafety.scalpel.FlakySafeInterceptorScalpel")
val scalpelSwitcherField = flakySafeInterceptorScalpelClass.getDeclaredField("scalpelSwitcher")
scalpelSwitcherField.isAccessible =trueval scalpelSwitcher = scalpelSwitcherField.get(originalScalpel)!!val scalpelSwitcherSpy = spyk(scalpelSwitcher)
scalpelSwitcherField.set(originalScalpel, scalpelSwitcherSpy)
val originalCalAttemptRestoreScalp = scalpelSwitcher::class.java.getDeclaredMethod(
"attemptRestoreScalp",
this.javaClass.classLoader!!.loadClass("kotlin.jvm.functions.Function0")!!,
)
originalCalAttemptRestoreScalp.isAccessible =true
every { scalpelSwitcherSpy["attemptRestoreScalp"](any<() ->Unit>()) } answers {
originalCalAttemptRestoreScalp.invoke(scalpelSwitcher, {
println("QWQWQW: set default interceptors")
ComposeInterceptorsInjector.injectKaspressoInKakaoCompose(
fakeBuilder.semanticsBehaviorInterceptors,
fakeBuilder.semanticsWatcherInterceptors,
)
// Если вы дочитали до сюда, то вот вам прикольная штука из скобок=)
(args[0]!!as () ->Unit)()
})
Unit
}
val scalpelSpy = spyk(originalScalpel)
flakySafetyProvider.flakySafeInterceptorScalpel = scalpelSpy
every { scalpelSpy["scalpKakaoInterceptors"]() } answers {
println("QWQWQW: set cleanered interceptors")
ComposeInterceptorsInjector.injectKaspressoInKakaoCompose(
fakeBuilder.semanticsBehaviorInterceptors.filter {
it !isFlakySafeSemanticsBehaviorInterceptor
},
fakeBuilder.semanticsWatcherInterceptors,
)
callOriginal()
}
}
/*** Достает [FlakySafetyProviderGlobalImpl] из [BaseTestContext] через рефлексию*/privatevalBaseTestContext.flakySafetyProvider:FlakySafetyProviderGlobalImpl
get() {
val safetyDelegateField =BaseTestContext::class.java.getDeclaredField("\$\$delegate_0")
safetyDelegateField.isAccessible =truereturn safetyDelegateField.get(this) asFlakySafetyProviderGlobalImpl
}
privatevarFlakySafetyProviderGlobalImpl.flakySafeInterceptorScalpel:Any
get() {
val flakySafeInterceptorScalpelField =this::class.java.getDeclaredField("flakySafeInterceptorScalpel")
flakySafeInterceptorScalpelField.isAccessible =truereturn flakySafeInterceptorScalpelField.get(this)!!
}
set(value) {
val flakySafeInterceptorScalpelField =this::class.java.getDeclaredField("flakySafeInterceptorScalpel")
flakySafeInterceptorScalpelField.isAccessible =true
flakySafeInterceptorScalpelField.set(this, value)
}
The text was updated successfully, but these errors were encountered:
Missed clean FlakySafeSemanticsBehaviorInterceptor when removing flakySafely intrceptors inside FlakySafeInterceptorScalpel
temp solution to local fix:
Fix
The text was updated successfully, but these errors were encountered: