020-desktop.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. Critical path: desktop shell.
  3. Loads the real desktop.html as an authenticated user and checks the
  4. shell furniture (wallpaper layer, task bar), the start/list menu with
  5. its module launcher entries, the quick-access panel user identity,
  6. the desktop APIs and the sign-out button.
  7. */
  8. "use strict";
  9. const h = require("../lib/system-harness");
  10. h.run("DESKTOP", async function (env) {
  11. const base = env.baseURL;
  12. const page = await h.newPage(env.browser);
  13. await h.loginViaAPI(page, base, env.admin.username, env.admin.password);
  14. // ── 1. Desktop shell loads ──
  15. await page.goto(base + "/desktop.html", { waitUntil: "domcontentloaded" });
  16. await page.waitForSelector("#bgwrapper", { state: "visible", timeout: 20000 });
  17. await page.waitForSelector("#navimenu", { state: "visible", timeout: 20000 });
  18. h.ok("desktop shell renders wallpaper layer and task bar");
  19. // ── 2. Desktop APIs answer for the logged-in user ──
  20. const userInfo = await h.getJSON(page, base + "/system/desktop/user");
  21. const userInfoStr = JSON.stringify(userInfo);
  22. if (userInfoStr.indexOf(env.admin.username) === -1) {
  23. h.fail("/system/desktop/user does not mention the logged-in user: " + userInfoStr);
  24. }
  25. h.ok("/system/desktop/user identifies the logged-in user");
  26. const hostInfo = await h.getJSON(page, base + "/system/desktop/host");
  27. if (JSON.stringify(hostInfo).indexOf("E2E ArozOS") === -1) {
  28. h.fail("/system/desktop/host does not carry the configured hostname: " + JSON.stringify(hostInfo));
  29. }
  30. h.ok("/system/desktop/host reports the configured hostname");
  31. // ── 3. Module list includes the critical built-ins ──
  32. const modules = await h.getJSON(page, base + "/system/modules/list");
  33. const moduleNames = modules.map(function (m) { return m.Name; });
  34. ["System Setting", "File Manager", "Desktop"].forEach(function (name) {
  35. if (moduleNames.indexOf(name) === -1) {
  36. h.fail("module list missing '" + name + "'. Got: " + moduleNames.join(", "));
  37. }
  38. });
  39. h.ok("module list includes Desktop, File Manager and System Setting");
  40. // ── 4. Start (list) menu opens and offers module entries ──
  41. await page.click('#navimenu div.item[onclick*="toggleListMenu"]');
  42. await page.waitForSelector("#listMenu", { state: "visible", timeout: 10000 });
  43. await page.waitForFunction(function () {
  44. var holder = document.getElementById("listMenuItem");
  45. return holder && holder.children.length > 0;
  46. }, { timeout: 15000 });
  47. if (!(await page.isVisible("#searchBar"))) h.fail("start menu search bar not visible");
  48. h.ok("start menu opens with module entries and a search bar");
  49. // Close it again so it does not overlap the quick access panel.
  50. await page.click('#navimenu div.item[onclick*="toggleListMenu"]');
  51. // ── 5. Quick access panel shows the user identity ──
  52. await page.click('#navimenu div.item[onclick*="showToolPanel"]');
  53. await page.waitForSelector("#quickAccessPanel", { state: "visible", timeout: 10000 });
  54. await page.waitForFunction(function (uname) {
  55. var el = document.getElementById("username");
  56. return el && el.textContent.trim().toLowerCase().indexOf(uname) !== -1;
  57. }, env.admin.username.toLowerCase(), { timeout: 10000 });
  58. h.ok("quick access panel shows the logged-in username");
  59. // ── 6. Sign out from the desktop UI ──
  60. // The desktop logout() asks with a native confirm() dialog first.
  61. page.on("dialog", function (dialog) { dialog.accept(); });
  62. await page.click("#logoutBtn");
  63. await page.waitForURL(function (url) { return url.pathname.indexOf("desktop.html") === -1; }, { timeout: 20000 });
  64. if (await h.isLoggedIn(page, base)) h.fail("desktop logout button left the session alive");
  65. h.ok("desktop sign-out button ends the session and leaves the desktop");
  66. await page.close();
  67. });