040-system-settings.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. Critical path: system settings.
  3. Opens the real System Setting web UI as the administrator, verifies
  4. the settings catalogue API (including admin-only module filtering)
  5. and the host information endpoint that the settings pages rely on.
  6. */
  7. "use strict";
  8. const h = require("../lib/system-harness");
  9. h.run("SYSTEM-SETTINGS", async function (env) {
  10. const base = env.baseURL;
  11. const page = await h.newPage(env.browser);
  12. await h.loginViaAPI(page, base, env.admin.username, env.admin.password);
  13. // ── 1. Settings UI renders its shell and populates the card grid ──
  14. await page.goto(base + "/SystemAO/system_setting/index.html", { waitUntil: "domcontentloaded" });
  15. await page.waitForSelector("#app", { state: "visible", timeout: 20000 });
  16. await page.waitForSelector("#sidebar", { state: "attached", timeout: 20000 });
  17. await page.waitForFunction(function () {
  18. var grid = document.getElementById("card-grid");
  19. return grid && grid.children.length > 0;
  20. }, { timeout: 20000 });
  21. h.ok("System Setting UI renders and loads setting groups");
  22. // ── 2. Setting group catalogue contains the critical groups ──
  23. const groups = await h.getJSON(page, base + "/system/setting/list");
  24. const groupStr = JSON.stringify(groups);
  25. ["Users", "Security", "Info"].forEach(function (g) {
  26. if (groupStr.indexOf('"' + g + '"') === -1) {
  27. h.fail("setting group '" + g + "' missing from /system/setting/list: " + groupStr.slice(0, 400));
  28. }
  29. });
  30. h.ok("setting catalogue includes the Users, Security and Info groups");
  31. // ── 3. Admin sees the admin-only user management modules ──
  32. const userGroupModules = await h.getJSON(page, base + "/system/setting/list?listGroup=Users");
  33. const moduleNames = userGroupModules.map(function (m) { return m.Name; });
  34. ["User List", "Permission Groups"].forEach(function (name) {
  35. if (moduleNames.indexOf(name) === -1) {
  36. h.fail("admin should see '" + name + "' in the Users group. Got: " + moduleNames.join(", "));
  37. }
  38. });
  39. h.ok("admin sees User List and Permission Groups setting modules");
  40. // ── 4. Host information endpoint feeds the settings pages ──
  41. const arozInfo = await h.getJSON(page, base + "/system/info/getArOZInfo");
  42. if (!arozInfo.HostName || arozInfo.HostName.indexOf("E2E ArozOS") === -1) {
  43. h.fail("getArOZInfo HostName unexpected: " + JSON.stringify(arozInfo));
  44. }
  45. h.ok("getArOZInfo reports the configured host name");
  46. // ── 5. Permission group listing works for the administrator ──
  47. const permGroups = await h.getJSON(page, base + "/system/permission/listgroup");
  48. if (JSON.stringify(permGroups).indexOf("administrator") === -1) {
  49. h.fail("listgroup does not include the administrator group: " + JSON.stringify(permGroups));
  50. }
  51. h.ok("permission group listing includes the administrator group");
  52. await page.close();
  53. });