1package daemon
2
3import (
4 "errors"
5 "testing"
6
7 "github.com/stretchr/testify/require"
8)
9
10func TestSnapshotFailureNoticeDeduplicatesStableCauseAndClearsOnSuccess(t *testing.T) {
11 d, _, client, _ := newNoticeFixture(t, newNoticeClock())
12 capture := &snapshotCapture{session: newSnapshotTestSession(t, "failed", false, "/work"), name: "failed"}
13
14 d.reportSnapshotFailure(capture, "publish", errors.New("first transient failure"))
15 d.reportSnapshotFailure(capture, "publish", errors.New("same class, changed details"))
16
17 history := d.notices.history()
18 require.Len(t, history, 1)
19 require.EqualValues(t, 2, history[0].Count)
20 require.Len(t, awaitToastCount(t, client, 1), 1)
21
22 d.finishSnapshotCapture(capture, true)
23 d.reportSnapshotFailure(capture, "publish", errors.New("failure after success"))
24 require.Len(t, awaitToastCount(t, client, 1), 1)
25 require.Len(t, d.notices.history(), 1)
26 require.EqualValues(t, 3, d.notices.history()[0].Count)
27}