- Notifications
You must be signed in to change notification settings - Fork1k
chore: perform several small frontend permissions refactors#16735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -13,62 +13,63 @@ test.describe.configure({ mode: "parallel" }); | ||
test.beforeEach(async ({ page }) => { | ||
beforeCoderTest(page); | ||
}); | ||
async function resetSearch(page: Page, username: string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Nit: I think a better name for this function could be | ||
const clearButton = page.getByLabel("Clear search"); | ||
if (await clearButton.isVisible()) { | ||
await clearButton.click(); | ||
} | ||
// Filter by the auditor test user to prevent race conditions | ||
await expect(page.getByText("All users")).toBeVisible(); | ||
await page.getByPlaceholder("Search...").fill(`username:${username}`); | ||
await expect(page.getByText("All users")).not.toBeVisible(); | ||
} | ||
test("logins are logged", async ({ page }) => { | ||
requiresLicense(); | ||
// Go to the audit history | ||
await login(page, users.auditor); | ||
await page.goto("/audit"); | ||
const username = users.auditor.username; | ||
const user = currentUser(page); | ||
const loginMessage = `${username} logged in`; | ||
// Make sure those things we did all actually show up | ||
await resetSearch(page, username); | ||
await expect(page.getByText(loginMessage).first()).toBeVisible(); | ||
}); | ||
test("creating templates and workspaces is logged", async ({ page }) => { | ||
requiresLicense(); | ||
// Do some stuff that should show up in the audit logs | ||
await login(page, users.templateAdmin); | ||
const username = users.templateAdmin.username; | ||
const templateName = await createTemplate(page); | ||
const workspaceName = await createWorkspace(page, templateName); | ||
// Go to the audit history | ||
await login(page, users.auditor); | ||
await page.goto("/audit"); | ||
// Make sure those things we did all actually show up | ||
await resetSearch(page, username); | ||
await expect( | ||
page.getByText(`${username} created template ${templateName}`), | ||
).toBeVisible(); | ||
await expect( | ||
page.getByText(`${username} created workspace ${workspaceName}`), | ||
).toBeVisible(); | ||
await expect( | ||
page.getByText(`${username} started workspace ${workspaceName}`), | ||
).toBeVisible(); | ||
// Make sure we can inspect the details of the log item | ||
const createdWorkspace = page.locator(".MuiTableRow-root", { | ||
hasText: `${username} created workspace ${workspaceName}`, | ||
}); | ||
await createdWorkspace.getByLabel("open-dropdown").click(); | ||
await expect( | ||
@@ -83,18 +84,19 @@ test("inspecting and filtering audit logs", async ({ page }) => { | ||
requiresLicense(); | ||
// Do some stuff that should show up in the audit logs | ||
await login(page, users.templateAdmin); | ||
const username = users.templateAdmin.username; | ||
const templateName = await createTemplate(page); | ||
const workspaceName = await createWorkspace(page, templateName); | ||
// Go to the audit history | ||
await login(page, users.auditor); | ||
await page.goto("/audit"); | ||
const loginMessage = `${username} logged in`; | ||
const startedWorkspaceMessage = `${username} started workspace ${workspaceName}`; | ||
// Filter by resource type | ||
await resetSearch(page, username); | ||
await page.getByText("All resource types").click(); | ||
const workspaceBuildsOption = page.getByText("Workspace Build"); | ||
await workspaceBuildsOption.scrollIntoViewIfNeeded({ timeout: 5000 }); | ||
@@ -107,7 +109,7 @@ test("inspecting and filtering audit logs", async ({ page }) => { | ||
await expect(page.getByText("All resource types")).toBeVisible(); | ||
// Filter by action type | ||
await resetSearch(page, username); | ||
await page.getByText("All actions").click(); | ||
await page.getByText("Login", { exact: true }).click(); | ||
// Logins should be visible | ||
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.