major RBAC imrpovements + fix thumbnails

This commit is contained in:
KingKDot
2026-07-21 13:18:30 -05:00
parent 9b885ad2ef
commit d602de396e
23 changed files with 599 additions and 213 deletions
+24 -1
View File
@@ -56,7 +56,7 @@ test.describe("authentication and authorization", () => {
const denied = await page.goto("/users");
expect(denied?.status()).toBe(403);
await expect(page.locator("body")).toContainText("Admin access required");
await expect(page.locator("body")).toContainText("missing permission users:manage");
const allowed = await page.goto("/metrics");
expect(allowed?.status()).toBe(200);
@@ -78,6 +78,29 @@ test.describe("authentication and authorization", () => {
});
});
test("admin can generate passwords and inspect combined permission sources", async ({ page }) => {
await login(page);
await page.goto("/users");
await page.locator("#add-user-btn").click();
await page.locator("#generate-password-btn").click();
const generatedPassword = await page.locator("#password").inputValue();
expect(generatedPassword.length).toBeGreaterThanOrEqual(20);
await expect(page.locator("#generated-password-hint")).toBeVisible();
await page.locator("#cancel-btn").click();
await expect(page.locator(`[data-action="feature-permissions"]`)).toHaveCount(0);
await page.locator(`[data-action="permissions"][data-username="${OPERATOR.username}"]`).click();
await expect(page.locator("#user-perms-modal")).toBeVisible();
await expect(page.locator("#user-features-list")).toContainText("Console");
await expect(page.locator("#user-features-list")).toContainText("console");
await expect(page.locator("#user-effective-perms-list")).toContainText("clients:control");
await expect(page.locator("#user-effective-perms-list")).toContainText("operator role");
await expect(page.locator("#user-effective-perms-list")).toContainText("clients:build");
await expect(page.locator("#user-effective-perms-list")).toContainText("Build permission toggle");
await expect(page.locator("#user-effective-perms-list")).toContainText("Client scope");
});
test("admin page sweep loads without browser errors", async ({ page }) => {
test.setTimeout(60_000);
await login(page);
+24
View File
@@ -64,6 +64,30 @@ test.describe("authenticated browser smoke tests", () => {
}
});
test("dashboard thumbnail preview modal opens when requested", async ({ page }) => {
await login(page);
await page.waitForFunction(() => document.getElementById("role-badge")?.textContent?.includes("Admin"));
await page.waitForFunction(() => getComputedStyle(document.getElementById("pagination")!).visibility !== "hidden");
await page.evaluate(() => {
const grid = document.getElementById("grid");
if (!grid) throw new Error("Dashboard grid not found");
grid.innerHTML = `
<article class="cv-row" data-client-row="rows" data-id="thumb-test" data-online="false">
<div class="cv-thumb cv-thumb-host" data-thumb-host data-thumb-client="thumb-test" style="width: 80px; height: 50px;">
<img class="thumb-img cv-thumb-img cv-thumb-overlay" data-thumb-img src="data:image/gif;base64,R0lGODlhAQABAAAAACw=" alt="" />
</div>
</article>
`;
const host = grid.querySelector("[data-thumb-host]");
if (!host) throw new Error("Thumbnail host not found");
host.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
});
const modal = page.locator(".modal").last();
await expect(modal).toHaveClass(/flex/);
await expect(modal).not.toHaveClass(/hidden/);
await expect(page.locator("#modal-img")).toHaveAttribute("src", /data:image\/gif/);
});
test("password inputs expose browser-safe form semantics", async ({ page }) => {
const issues = collectBrowserIssues(page);
await login(page);