remoteProjectConnectionState.test.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. formatRemoteProjectConnectionAddress,
  4. resolveRemoteConnectionPresentation,
  5. } from "@/lib/remoteConnectionPresentation.js";
  6. describe("RPN-14 remote project connection state", () => {
  7. it("does not display credentials or query tokens from a direct-server URL", () => {
  8. expect(
  9. formatRemoteProjectConnectionAddress({
  10. kind: "server",
  11. url: "https://user:secret@server.example:8787/ws?token=hidden#private",
  12. }),
  13. ).toBe("server.example:8787");
  14. });
  15. it("does not paint a retained attachment green after the device went offline", () => {
  16. expect(resolveRemoteConnectionPresentation({ attached: true, state: "offline" }).status).toBe(
  17. "offline",
  18. );
  19. });
  20. it("shows an active retry ahead of the previous attempt's error", () => {
  21. expect(
  22. resolveRemoteConnectionPresentation({
  23. attached: false,
  24. reconnecting: true,
  25. error: "previous failure",
  26. }).status,
  27. ).toBe("connecting");
  28. });
  29. it("keeps a single failed attachment distinct from a healthy device", () => {
  30. expect(
  31. resolveRemoteConnectionPresentation({
  32. attached: false,
  33. state: "online",
  34. error: "bind failed",
  35. }).status,
  36. ).toBe("failed");
  37. });
  38. it("uses connecting for device bootstrap and keeps installation gates non-error", () => {
  39. expect(
  40. resolveRemoteConnectionPresentation({ attached: false, state: "connecting" }).status,
  41. ).toBe("connecting");
  42. expect(resolveRemoteConnectionPresentation({ attached: false, state: "pending" }).status).toBe(
  43. "pending",
  44. );
  45. });
  46. });