-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set expiry for dismissed notifications #5186
Merged
+112
−11
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ebdce9b
dismiss notification expiry
samgst-amazon bcfbb27
test
samgst-amazon a23cd78
Merge branch 'main' into samgst/NotificationDismissedExpire
samgst-amazon 4367447
fix tests
samgst-amazon 824314d
redundant cleanExpired function calls
samgst-amazon dc61742
converter
samgst-amazon 3d26f16
detekt
samgst-amazon 3dcac05
Merge branch 'main' into samgst/NotificationDismissedExpire
samgst-amazon 97acf1c
Merge branch 'main' into samgst/NotificationDismissedExpire
samgst-amazon ef6ec85
remove whitespace from conflict
samgst-amazon ba2638f
detekt
samgst-amazon 9d3e162
Merge branch 'main' into samgst/NotificationDismissedExpire
samgst-amazon ed92b9f
Merge branch 'main' into samgst/NotificationDismissedExpire
samgst-amazon 2a96250
remove attribute tags, unnecessary clear
samgst-amazon 35d1134
replace attribute tags
samgst-amazon 960f5f1
change properties to var for serialization
samgst-amazon 2475c07
simplify getState
samgst-amazon 5ae5b7f
detekt
samgst-amazon 1c244db
Merge branch 'main' into samgst/NotificationDismissedExpire
samgst-amazon 66d27e6
Merge branch 'main' into samgst/NotificationDismissedExpire
samgst-amazon cb7d9f9
reduntant test
samgst-amazon 3afef56
Merge branch 'main' into samgst/NotificationDismissedExpire
samgst-amazon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
.../tst/software/aws/toolkits/jetbrains/core/notifications/NotificationDismissalStateTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.core.notifications | ||
|
||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Assertions.assertFalse | ||
import org.junit.jupiter.api.Assertions.assertTrue | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import java.time.Instant | ||
import java.time.temporal.ChronoUnit | ||
|
||
class NotificationDismissalStateTest { | ||
private lateinit var state: NotificationDismissalState | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
state = NotificationDismissalState() | ||
} | ||
|
||
@Test | ||
fun `notifications less than 2 months old are not removed`() { | ||
val recentNotification = DismissedNotification( | ||
id = "recent-notification", | ||
dismissedAt = Instant.now().minus(30, ChronoUnit.DAYS).toEpochMilli().toString() | ||
) | ||
|
||
state.loadState(NotificationDismissalConfiguration(mutableSetOf(recentNotification))) | ||
|
||
val persistedState = state.getState() | ||
|
||
assertEquals(1, persistedState.dismissedNotifications.size) | ||
assertTrue(persistedState.dismissedNotifications.any { it.id == "recent-notification" }) | ||
assertTrue(state.isDismissed("recent-notification")) | ||
} | ||
|
||
@Test | ||
fun `notifications older than 2 months are removed`() { | ||
val oldNotification = DismissedNotification( | ||
id = "old-notification", | ||
dismissedAt = Instant.now().minus(61, ChronoUnit.DAYS).toEpochMilli().toString() | ||
) | ||
|
||
state.loadState(NotificationDismissalConfiguration(mutableSetOf(oldNotification))) | ||
|
||
val persistedState = state.getState() | ||
|
||
assertEquals(0, persistedState.dismissedNotifications.size) | ||
assertFalse(state.isDismissed("old-notification")) | ||
} | ||
|
||
@Test | ||
fun `mixed age notifications are handled correctly`() { | ||
val recentNotification = DismissedNotification( | ||
id = "recent-notification", | ||
dismissedAt = Instant.now().minus(30, ChronoUnit.DAYS).toEpochMilli().toString() | ||
) | ||
val oldNotification = DismissedNotification( | ||
id = "old-notification", | ||
dismissedAt = Instant.now().minus(61, ChronoUnit.DAYS).toEpochMilli().toString() | ||
) | ||
|
||
state.loadState( | ||
NotificationDismissalConfiguration( | ||
mutableSetOf(recentNotification, oldNotification) | ||
) | ||
) | ||
|
||
val persistedState = state.getState() | ||
|
||
assertEquals(1, persistedState.dismissedNotifications.size) | ||
assertTrue(state.isDismissed("recent-notification")) | ||
assertFalse(state.isDismissed("old-notification")) | ||
} | ||
|
||
@Test | ||
fun `dismissing new notification retains it`() { | ||
state.dismissNotification("new-notification") | ||
|
||
assertTrue(state.isDismissed("new-notification")) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These properties need to be var for the serialization to work without the property/attribute tags