Add notification feedback settings
This commit is contained in:
@@ -2914,6 +2914,27 @@ func TestUIStatusToastExpiresAfterTimeout(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIStatusToastExpiresAfterConfiguredTimeout(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
now := time.Date(2026, time.March, 29, 12, 0, 0, 0, time.UTC)
|
||||
u := newUIWithModel("desktop", vault.Model{})
|
||||
u.now = func() time.Time { return now }
|
||||
u.statusBannerTTL = statusBannerLong
|
||||
u.state.StatusMessage = "save complete"
|
||||
u.statusExpiresAt = now.Add(u.statusBannerTTL)
|
||||
|
||||
now = now.Add(statusBannerDuration + time.Second)
|
||||
if got := u.statusToastSurface(); got.Kind != bannerStatus {
|
||||
t.Fatalf("statusToastSurface() before configured expiry = %#v, want visible status toast", got)
|
||||
}
|
||||
|
||||
now = now.Add(statusBannerLong)
|
||||
if got := u.statusToastSurface(); got.Kind != bannerNone {
|
||||
t.Fatalf("statusToastSurface() after configured expiry = %#v, want no toast", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIAutofillStatusSurfaceUsesPendingApproval(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -2945,6 +2966,41 @@ func TestUIAutofillStatusSurfaceUsesPendingApproval(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIAutofillStatusSurfaceRespectsNoticePreference(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
now := time.Date(2026, time.March, 29, 12, 0, 0, 0, time.UTC)
|
||||
u := newUIWithModel("desktop", vault.Model{})
|
||||
u.now = func() time.Time { return now }
|
||||
u.auditLog = &apiaudit.Log{}
|
||||
u.auditLog.Record(apiaudit.Event{
|
||||
Type: apiaudit.EventAutofillFound,
|
||||
TokenName: "Browser Extension",
|
||||
ClientName: "Firefox",
|
||||
Operation: apitokens.OperationCopyPassword,
|
||||
At: now,
|
||||
})
|
||||
|
||||
u.autofillNoticePreference = autofillNoticeApprovals
|
||||
if got := u.autofillStatusSurface(); got.Kind != autofillStatusNone {
|
||||
t.Fatalf("autofillStatusSurface() with approvals-only preference = %#v, want no recent notice", got)
|
||||
}
|
||||
|
||||
u.autofillNoticePreference = autofillNoticeSuppressed
|
||||
u.state.Approvals = &mainStubApprovalManager{
|
||||
pending: []apiapproval.Request{{
|
||||
ID: "approval-1",
|
||||
TokenName: "Browser Extension",
|
||||
ClientName: "Firefox",
|
||||
Operation: apitokens.OperationCopyPassword,
|
||||
Resource: apitokens.Resource{Kind: apitokens.ResourceEntry, EntryID: "entry-1"},
|
||||
}},
|
||||
}
|
||||
if got := u.autofillStatusSurface(); got.Kind != autofillStatusNone {
|
||||
t.Fatalf("autofillStatusSurface() with suppressed preference = %#v, want no notice", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIAutofillStatusSurfaceUsesAuditEventsForFoundAmbiguousAndBlocked(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -3502,6 +3558,31 @@ func TestUIEntryRowMetricsUseDenseLayout(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUINotificationPreferencesPersist(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
configPath := filepath.Join(t.TempDir(), "ui-prefs.json")
|
||||
|
||||
first := newUIWithSession("desktop", &session.Manager{})
|
||||
first.uiPreferencesPath = configPath
|
||||
first.statusBannerTTL = statusBannerLong
|
||||
first.autofillNoticePreference = autofillNoticeApprovals
|
||||
first.saveUIPreferences()
|
||||
|
||||
second := newUIWithSession("desktop", &session.Manager{})
|
||||
second.uiPreferencesPath = configPath
|
||||
second.statusBannerTTL = statusBannerDuration
|
||||
second.autofillNoticePreference = autofillNoticeAll
|
||||
second.loadUIPreferences()
|
||||
|
||||
if got := second.statusBannerTTL; got != statusBannerLong {
|
||||
t.Fatalf("statusBannerTTL after reload = %v, want %v", got, statusBannerLong)
|
||||
}
|
||||
if got := second.autofillNoticePreference; got != autofillNoticeApprovals {
|
||||
t.Fatalf("autofillNoticePreference after reload = %q, want %q", got, autofillNoticeApprovals)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSelectingRecentRemoteConnectionKeepsPasswordMasked(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user