59582cf8f5
* fix
* Update UserForm.tsx
* test: add e2e tests for admin user creation and editing
- Add test for successful user creation via /settings/admin/users/add
- Add test for successful user editing via /settings/admin/users/{id}
- Tests verify form submission, API responses, and database changes
- Follow Cal.com e2e testing patterns with admin authentication
- Use Playwright for end-to-end form interaction testing
Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
* Update admin-users.e2e.ts
* Update admin-users.e2e.ts
* update
* tweak
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
70 lines
1.9 KiB
TypeScript
70 lines
1.9 KiB
TypeScript
import { expect } from "@playwright/test";
|
|
|
|
import { test } from "./lib/fixtures";
|
|
|
|
test.describe.configure({ mode: "parallel" });
|
|
|
|
test.describe("Admin Users Management", () => {
|
|
test("should add a new user successfully", async ({ page, users }) => {
|
|
const adminUser = await users.create({
|
|
role: "ADMIN",
|
|
});
|
|
|
|
await adminUser.apiLogin();
|
|
|
|
await page.goto("/settings/admin/users/add");
|
|
|
|
await page.waitForLoadState();
|
|
|
|
await page.fill('input[name="name"]', "Test User");
|
|
await page.fill('input[name="username"]', "testuser");
|
|
await page.fill('input[name="email"]', "testuser@example.com");
|
|
await page.fill('input[name="bio"]', "Test user bio");
|
|
|
|
await page.locator('[data-testid="timezone-select"] div').first().click();
|
|
|
|
const responsePromise = page.waitForResponse((response) =>
|
|
response.url().includes("/api/trpc/users/add")
|
|
);
|
|
|
|
await page.click('button[type="submit"]');
|
|
|
|
const response = await responsePromise;
|
|
expect(response.status()).toBe(200);
|
|
|
|
await page.waitForURL("/settings/admin/users");
|
|
});
|
|
|
|
test("should edit an existing user successfully", async ({ page, users }) => {
|
|
const adminUser = await users.create({
|
|
role: "ADMIN",
|
|
});
|
|
|
|
const userToEdit = await users.create({
|
|
name: "Edit User",
|
|
username: "edituser",
|
|
});
|
|
|
|
await adminUser.apiLogin();
|
|
|
|
await page.goto(`/settings/admin/users/${userToEdit.id}/edit`);
|
|
|
|
await page.waitForLoadState();
|
|
|
|
await expect(page.locator('input[name="name"]')).toHaveValue("Edit User");
|
|
|
|
await page.fill('input[name="name"]', "Updated User");
|
|
|
|
const responsePromise = page.waitForResponse((response) =>
|
|
response.url().includes("/api/trpc/users/update")
|
|
);
|
|
|
|
await page.click('button[type="submit"]');
|
|
|
|
const response = await responsePromise;
|
|
expect(response.status()).toBe(200);
|
|
|
|
await page.waitForURL("/settings/admin/users");
|
|
});
|
|
});
|