webRemoteControlFailureScreen.test.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { createElement } from "react";
  2. import { renderToStaticMarkup } from "react-dom/server";
  3. import { describe, expect, it } from "vitest";
  4. import { WebRemoteControlFailureScreen } from "#src/web-remote-control/views.js";
  5. describe("WebRemoteControlFailureScreen", () => {
  6. it("renders structured recovery guidance and the relay detail message", () => {
  7. const html = renderToStaticMarkup(
  8. createElement(WebRemoteControlFailureScreen, {
  9. failure: {
  10. reason: "desktop-disconnected",
  11. message: "Desktop device is offline.",
  12. },
  13. locale: "en-US",
  14. onReload: () => {},
  15. }),
  16. );
  17. expect(html).toContain("Desktop Offline");
  18. expect(html).toContain("What happened");
  19. expect(html).toContain("Desktop device is offline.");
  20. expect(html).toContain("Try Again");
  21. });
  22. it("账号归属失败提供切换账号与选择其他设备两个动作", () => {
  23. const html = renderToStaticMarkup(
  24. createElement(WebRemoteControlFailureScreen, {
  25. failure: { reason: "device-not-owned" },
  26. locale: "zh-CN",
  27. onReload: () => {},
  28. primaryActionLabel: "切换账号",
  29. secondaryAction: { label: "选择其他设备", onClick: () => {} },
  30. }),
  31. );
  32. expect(html).toContain("该设备不属于当前账号");
  33. expect(html).toContain("切换账号");
  34. expect(html).toContain("选择其他设备");
  35. expect(html).not.toContain(">重新连接</button>");
  36. });
  37. });