Skip to content

Commit 9e7a4b0

Browse files
authored
close popup afterEach test case (#4521)
1 parent 4c49439 commit 9e7a4b0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/popup/CodeWhispererPopupManager.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ class CodeWhispererPopupManager {
8989
var sessionContext = SessionContext()
9090
private set
9191

92+
private var myPopup: JBPopup? = null
93+
9294
init {
9395
// Listen for global scheme changes
9496
ApplicationManager.getApplication().messageBus.connect().subscribe(
@@ -268,6 +270,10 @@ class CodeWhispererPopupManager {
268270
popup.closeOk(null)
269271
}
270272

273+
fun closePopup() {
274+
myPopup?.closeOk(null)
275+
}
276+
271277
fun showPopup(
272278
states: InvocationContext,
273279
sessionContext: SessionContext,
@@ -384,7 +390,9 @@ class CodeWhispererPopupManager {
384390
.setCancelOnOtherWindowOpen(true)
385391
.setCancelKeyEnabled(true)
386392
.setCancelOnWindowDeactivation(true)
387-
.createPopup()
393+
.createPopup().also {
394+
myPopup = it
395+
}
388396

389397
fun getReformattedRecommendation(detailContext: DetailContext, userInput: String) =
390398
detailContext.reformatted.content().substring(userInput.length)

plugins/toolkit/jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTestBase.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ open class CodeWhispererTestBase {
156156
stateManager.loadState(originalExplorerActionState)
157157
settingsManager.loadState(originalSettings)
158158
popupManagerSpy.reset()
159+
runInEdtAndWait {
160+
popupManagerSpy.closePopup()
161+
}
159162
}
160163

161164
fun withCodeWhispererServiceInvokedAndWait(runnable: (InvocationContext) -> Unit) {

0 commit comments

Comments
 (0)