Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: use user admin and template admin for even more e2e tests#16974

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

Merged
aslilac merged 8 commits intomainfromlilac/even-more-e2e-roles-tests
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletionssite/e2e/helpers.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -267,9 +267,8 @@ export const createTemplate = async (
);
}

// pickerisdisabled if only oneorg is available
//The organizationpickerwill bedisabled ifthere isonly oneoption.
const pickerIsDisabled = await orgPicker.isDisabled();

if (!pickerIsDisabled) {
await orgPicker.click();
await page.getByText(orgName, { exact: true }).click();
Expand DownExpand Up@@ -1094,8 +1093,12 @@ export async function createUser(
const orgPicker = page.getByLabel("Organization *");
const organizationsEnabled = await orgPicker.isVisible();
if (organizationsEnabled) {
await orgPicker.click();
await page.getByText(orgName, { exact: true }).click();
// The organization picker will be disabled if there is only one option.
const pickerIsDisabled = await orgPicker.isDisabled();
if (!pickerIsDisabled) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

suggestion: don't use no double negatives

BrunoQuaresma reacted with thumbs up emoji
await orgPicker.click();
await page.getByText(orgName, { exact: true }).click();
}
}

await page.getByLabel("Login Type").click();
Expand Down
179 changes: 96 additions & 83 deletionssite/e2e/tests/auditLogs.spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
import { type Page, expect, test } from "@playwright/test";
import { users } from "../constants";
import {defaultPassword,users } from "../constants";
import {
createTemplate,
createUser,
createWorkspace,
currentUser,
login,
randomName,
requiresLicense,
} from "../helpers";
import { beforeCoderTest } from "../hooks";
Expand All@@ -15,6 +16,14 @@ test.beforeEach(async ({ page }) => {
beforeCoderTest(page);
});

const name = randomName();
const userToAudit = {
username: `peep-${name}`,
password: defaultPassword,
email: `peep-${name}@coder.com`,
roles: ["Template Admin", "User Admin"],
};

async function resetSearch(page: Page, username: string) {
const clearButton = page.getByLabel("Clear search");
if (await clearButton.isVisible()) {
Expand All@@ -27,92 +36,96 @@ async function resetSearch(page: Page, username: string) {
await expect(page.getByText("All users")).not.toBeVisible();
}

test("logins are logged",async ({ page }) => {
test.describe("audit logs",() => {
requiresLicense();

// Go to the audit history
await login(page, users.auditor);
await page.goto("/audit");
const username = users.auditor.username;

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.beforeAll(async ({ browser }) => {
const context = await browser.newContext();
const page = await context.newPage();
await login(page);
await createUser(page, userToAudit);
});

test("creating templates and workspaces is logged", async ({ page }) => {
requiresLicense();
test("logins are logged", async ({ page }) => {
// Go to the audit history
await login(page, users.auditor);
await page.goto("/audit");

// 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}`,
// Make sure those things we did all actually show up
await resetSearch(page, users.auditor.username);
const loginMessage = `${users.auditor.username} logged in`;
await expect(page.getByText(loginMessage).first()).toBeVisible();
});
await createdWorkspace.getByLabel("open-dropdown").click();
await expect(
createdWorkspace.getByText(`automatic_updates: "never"`),
).toBeVisible();
await expect(
createdWorkspace.getByText(`name: "${workspaceName}"`),
).toBeVisible();
});

test("inspecting and filtering audit logs", async ({ page }) => {
requiresLicense();
test("creating templates and workspaces is logged", async ({ page }) => {
// Do some stuff that should show up in the audit logs
await login(page, userToAudit);
const username = userToAudit.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(
createdWorkspace.getByText(`automatic_updates: "never"`),
).toBeVisible();
await expect(
createdWorkspace.getByText(`name: "${workspaceName}"`),
).toBeVisible();
});

// 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 });
await workspaceBuildsOption.click();
// Our workspace build should be visible
await expect(page.getByText(startedWorkspaceMessage)).toBeVisible();
// Logins should no longer be visible
await expect(page.getByText(loginMessage)).not.toBeVisible();
await page.getByLabel("Clear search").click();
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
await expect(page.getByText(loginMessage).first()).toBeVisible();
// Our workspace build should no longer be visible
await expect(page.getByText(startedWorkspaceMessage)).not.toBeVisible();
test("inspecting and filtering audit logs", async ({ page }) => {
// Do some stuff that should show up in the audit logs
await login(page, userToAudit);
const username = userToAudit.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 });
await workspaceBuildsOption.click();
// Our workspace build should be visible
await expect(page.getByText(startedWorkspaceMessage)).toBeVisible();
// Logins should no longer be visible
await expect(page.getByText(loginMessage)).not.toBeVisible();
await page.getByLabel("Clear search").click();
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
await expect(page.getByText(loginMessage).first()).toBeVisible();
// Our workspace build should no longer be visible
await expect(page.getByText(startedWorkspaceMessage)).not.toBeVisible();
});
});
21 changes: 6 additions & 15 deletionssite/e2e/tests/deployment/idpOrgSync.spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,8 +5,8 @@ import {
deleteOrganization,
setupApiCalls,
} from "../../api";
import {randomName, requiresLicense} from "../../helpers";
import { login } from "../../helpers";
import {users} from "../../constants";
import { login, randomName, requiresLicense } from "../../helpers";
import { beforeCoderTest } from "../../hooks";

test.beforeEach(async ({ page }) => {
Expand All@@ -15,13 +15,14 @@ test.beforeEach(async ({ page }) => {
await setupApiCalls(page);
});

test.describe("IdpOrgSyncPage", () => {
test.describe("IdP organization sync", () => {
requiresLicense();

test.describe.configure({ retries: 1 });

test("show empty table when no org mappings are present", async ({
page,
}) => {
requiresLicense();
await page.goto("/deployment/idp-org-sync", {
waitUntil: "domcontentloaded",
});
Expand All@@ -35,8 +36,6 @@ test.describe("IdpOrgSyncPage", () => {
});

test("add new IdP organization mapping with API", async ({ page }) => {
requiresLicense();

await createOrganizationSyncSettings();

await page.goto("/deployment/idp-org-sync", {
Expand All@@ -59,7 +58,6 @@ test.describe("IdpOrgSyncPage", () => {
});

test("delete a IdP org to coder org mapping row", async ({ page }) => {
requiresLicense();
await createOrganizationSyncSettings();
await page.goto("/deployment/idp-org-sync", {
waitUntil: "domcontentloaded",
Expand All@@ -77,7 +75,6 @@ test.describe("IdpOrgSyncPage", () => {
});

test("update sync field", async ({ page }) => {
requiresLicense();
await page.goto("/deployment/idp-org-sync", {
waitUntil: "domcontentloaded",
});
Expand All@@ -100,7 +97,6 @@ test.describe("IdpOrgSyncPage", () => {
});

test("toggle off default organization assignment", async ({ page }) => {
requiresLicense();
await page.goto("/deployment/idp-org-sync", {
waitUntil: "domcontentloaded",
});
Expand All@@ -126,8 +122,6 @@ test.describe("IdpOrgSyncPage", () => {
test("export policy button is enabled when sync settings are present", async ({
page,
}) => {
requiresLicense();

await page.goto("/deployment/idp-org-sync", {
waitUntil: "domcontentloaded",
});
Expand All@@ -140,10 +134,7 @@ test.describe("IdpOrgSyncPage", () => {
});

test("add new IdP organization mapping with UI", async ({ page }) => {
requiresLicense();

const orgName = randomName();

await createOrganizationWithName(orgName);

await page.goto("/deployment/idp-org-sync", {
Expand DownExpand Up@@ -172,7 +163,7 @@ test.describe("IdpOrgSyncPage", () => {
await orgSelector.click();
await page.waitForTimeout(1000);

const option =awaitpage.getByRole("option", { name: orgName });
const option = page.getByRole("option", { name: orgName });
await expect(option).toBeAttached({ timeout: 30000 });
await expect(option).toBeVisible();
await option.click();
Expand Down
7 changes: 3 additions & 4 deletionssite/e2e/tests/groups/addMembers.spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,14 +5,13 @@ import {
getCurrentOrgId,
setupApiCalls,
} from "../../api";
import { defaultOrganizationName } from "../../constants";
import { requiresLicense } from "../../helpers";
import { login } from "../../helpers";
import { defaultOrganizationName, users } from "../../constants";
import { login, requiresLicense } from "../../helpers";
import { beforeCoderTest } from "../../hooks";

test.beforeEach(async ({ page }) => {
beforeCoderTest(page);
await login(page);
await login(page, users.userAdmin);
await setupApiCalls(page);
});

Expand Down
7 changes: 3 additions & 4 deletionssite/e2e/tests/groups/addUsersToDefaultGroup.spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
import { expect, test } from "@playwright/test";
import { createUser, getCurrentOrgId, setupApiCalls } from "../../api";
import { defaultOrganizationName } from "../../constants";
import { requiresLicense } from "../../helpers";
import { login } from "../../helpers";
import { defaultOrganizationName, users } from "../../constants";
import { login, requiresLicense } from "../../helpers";
import { beforeCoderTest } from "../../hooks";

test.beforeEach(async ({ page }) => {
beforeCoderTest(page);
await login(page);
await login(page, users.userAdmin);
});

const DEFAULT_GROUP_NAME = "Everyone";
Expand Down
7 changes: 3 additions & 4 deletionssite/e2e/tests/groups/createGroup.spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
import { expect, test } from "@playwright/test";
import { defaultOrganizationName } from "../../constants";
import { randomName, requiresLicense } from "../../helpers";
import { login } from "../../helpers";
import { defaultOrganizationName, users } from "../../constants";
import { login, randomName, requiresLicense } from "../../helpers";
import { beforeCoderTest } from "../../hooks";

test.beforeEach(async ({ page }) => {
beforeCoderTest(page);
await login(page);
await login(page, users.userAdmin);
});

test("create group", async ({ page, baseURL }) => {
Expand Down
7 changes: 3 additions & 4 deletionssite/e2e/tests/groups/removeGroup.spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
import { expect, test } from "@playwright/test";
import { createGroup, getCurrentOrgId, setupApiCalls } from "../../api";
import { defaultOrganizationName } from "../../constants";
import { requiresLicense } from "../../helpers";
import { login } from "../../helpers";
import { defaultOrganizationName, users } from "../../constants";
import { login, requiresLicense } from "../../helpers";
import { beforeCoderTest } from "../../hooks";

test.beforeEach(async ({ page }) => {
beforeCoderTest(page);
await login(page);
await login(page, users.userAdmin);
await setupApiCalls(page);
});

Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp