Skip to content

Commit d820241

Browse files
authored
Fix 2020.1 UI tests broken by the deprecation prompt (#2487)
- The deprecation prompt was breaking 2020.1 SQS tests since it was over the send button - Add a system property and check for it so we never show the prompt in UI tests
1 parent 1fa22f3 commit d820241

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ subprojects {
256256
systemProperty("ide.show.tips.on.startup.default.value", false)
257257

258258
systemProperty("aws.telemetry.skip_prompt", "true")
259+
systemProperty("aws.suppress_deprecation_prompt", true)
259260
ciOnly {
260261
systemProperty("aws.sharedCredentialsFile", "/tmp/.aws/credentials")
261262
}

jetbrains-core/src/software/aws/toolkits/jetbrains/core/notification/JetBrainsMinimumVersionChange.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class JetBrainsMinimumVersionChange : NoticeType {
2323
override fun getSuppressNotificationValue(): String = ApplicationInfo.getInstance().fullVersion
2424

2525
override fun isNotificationSuppressed(previousSuppressNotificationValue: String?): Boolean {
26+
if (System.getProperty(SKIP_PROMPT, null)?.toBoolean() == true) {
27+
return true
28+
}
2629
previousSuppressNotificationValue?.let {
2730
return previousSuppressNotificationValue == getSuppressNotificationValue()
2831
}
@@ -33,4 +36,9 @@ class JetBrainsMinimumVersionChange : NoticeType {
3336

3437
override fun getNoticeContents(): NoticeContents = noticeContents
3538
override fun getNoticeType(): NotificationType = NotificationType.WARNING
39+
40+
private companion object {
41+
// Used by tests to make sure the prompt never shows up
42+
const val SKIP_PROMPT = "aws.suppress_deprecation_prompt"
43+
}
3644
}

jetbrains-core/src/software/aws/toolkits/jetbrains/core/notification/NoticeManager.kt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,9 @@ class DefaultNoticeManager :
4848
/**
4949
* Returns the notices that require notification
5050
*/
51-
override fun getRequiredNotices(notices: List<NoticeType>, project: Project): List<NoticeType> = notices.filter { it.isNotificationRequired() }
52-
.filter {
53-
internalState[it.id]?.let { state ->
54-
state.noticeSuppressedValue?.let { previouslySuppressedValue ->
55-
return@filter !it.isNotificationSuppressed(previouslySuppressedValue)
56-
}
57-
}
58-
59-
true
60-
}
51+
override fun getRequiredNotices(notices: List<NoticeType>, project: Project): List<NoticeType> = notices
52+
.filter { it.isNotificationRequired() }
53+
.filter { !it.isNotificationSuppressed(internalState[it.id]?.noticeSuppressedValue) }
6154

6255
override fun notify(notices: List<NoticeType>, project: Project) {
6356
notices.forEach { notify(it, project) }

jetbrains-core/tst/software/aws/toolkits/jetbrains/core/notification/NoticeManagerTest.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package software.aws.toolkits.jetbrains.core.notification
66
import com.intellij.testFramework.ProjectRule
77
import com.nhaarman.mockitokotlin2.eq
88
import com.nhaarman.mockitokotlin2.mock
9+
import com.nhaarman.mockitokotlin2.spy
910
import com.nhaarman.mockitokotlin2.times
1011
import com.nhaarman.mockitokotlin2.verify
1112
import com.nhaarman.mockitokotlin2.whenever
@@ -47,13 +48,15 @@ class NoticeManagerTest {
4748
}
4849

4950
@Test
50-
fun nonSerializedNoticeDoesRequiresNotification() {
51-
val notice = createSampleNotice(true, true)
51+
fun nonSerializedNoticeCallsIsNotificationSuppressed() {
52+
val notice = spy(createSampleNotice(requiresNotification = true, isNotificationSuppressed = false))
5253

5354
val notices = sut.getRequiredNotices(listOf(notice), projectRule.project)
5455

5556
assertThat(notices).hasSize(1)
5657
assertThat(notices).contains(notice)
58+
59+
verify(notice).isNotificationSuppressed(null)
5760
}
5861

5962
@Test

0 commit comments

Comments
 (0)