File size: 1,572 Bytes
fc93158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { describe, expect, it } from "vitest";
import { collectBlueBubblesStatusIssues } from "./bluebubbles.js";

describe("collectBlueBubblesStatusIssues", () => {
  it("reports unconfigured enabled accounts", () => {
    const issues = collectBlueBubblesStatusIssues([
      {
        accountId: "default",
        enabled: true,
        configured: false,
      },
    ]);

    expect(issues).toEqual([
      expect.objectContaining({
        channel: "bluebubbles",
        accountId: "default",
        kind: "config",
      }),
    ]);
  });

  it("reports probe failure and runtime error for configured running accounts", () => {
    const issues = collectBlueBubblesStatusIssues([
      {
        accountId: "work",
        enabled: true,
        configured: true,
        running: true,
        lastError: "timeout",
        probe: {
          ok: false,
          status: 503,
        },
      },
    ]);

    expect(issues).toHaveLength(2);
    expect(issues[0]).toEqual(
      expect.objectContaining({
        channel: "bluebubbles",
        accountId: "work",
        kind: "runtime",
      }),
    );
    expect(issues[1]).toEqual(
      expect.objectContaining({
        channel: "bluebubbles",
        accountId: "work",
        kind: "runtime",
        message: "Channel error: timeout",
      }),
    );
  });

  it("skips disabled accounts", () => {
    const issues = collectBlueBubblesStatusIssues([
      {
        accountId: "disabled",
        enabled: false,
        configured: false,
      },
    ]);
    expect(issues).toEqual([]);
  });
});