more merging

This commit is contained in:
counterweight 2025-12-25 00:06:32 +01:00
parent 67ffe6a823
commit d6f955d2d9
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
5 changed files with 107 additions and 251 deletions

View file

@ -119,7 +119,7 @@ test.describe("Profile - Form Behavior", () => {
await clearProfileData(page);
});
test("form state management - empty fields, button states", async ({ page }) => {
test("form state management, save, persistence, and clearing fields", async ({ page }) => {
await page.goto("/profile");
// All editable fields should be empty
@ -135,12 +135,8 @@ test.describe("Profile - Form Behavior", () => {
// Make a change - button should be enabled
await page.fill("#telegram", "@testhandle");
await expect(saveButton).toBeEnabled();
});
test("can save profile, values persist, and can clear fields", async ({ page }) => {
await page.goto("/profile");
// Fill in all fields
// Now test saving and persistence - fill in all fields
await page.fill("#contact_email", "contact@test.com");
await page.fill("#telegram", "@testuser");
await page.fill("#signal", "signal.42");
@ -181,7 +177,7 @@ test.describe("Profile - Validation", () => {
await clearProfileData(page);
});
test("validation - telegram auto-prepend, errors for invalid inputs", async ({ page }) => {
test("validation - all field validations and error fixing", async ({ page }) => {
await page.goto("/profile");
// Test telegram auto-prepend
@ -190,8 +186,7 @@ test.describe("Profile - Validation", () => {
// Test telegram error - no characters after @
await page.fill("#telegram", "@");
await page.waitForTimeout(600);
await expect(page.getByText(/at least one character after @/i)).toBeVisible();
await expect(page.getByText(/at least one character after @/i)).toBeVisible({ timeout: 2000 });
const saveButton = page.getByRole("button", { name: /save changes/i });
await expect(saveButton).toBeDisabled();
@ -199,45 +194,29 @@ test.describe("Profile - Validation", () => {
await page.fill("#nostr_npub", "invalidnpub");
await expect(page.getByText(/must start with 'npub1'/i)).toBeVisible();
await expect(saveButton).toBeDisabled();
});
test("can fix validation error and save", async ({ page }) => {
await page.goto("/profile");
// Test invalid email format
await page.fill("#contact_email", "not-an-email");
await expect(page.getByText(/valid email/i)).toBeVisible();
await expect(saveButton).toBeDisabled();
// Enter invalid telegram (just @ with no handle)
await page.fill("#telegram", "@");
// Wait for debounced validation
await page.waitForTimeout(600);
await expect(page.getByText(/at least one character after @/i)).toBeVisible();
// Fix it
// Fix all validation errors and save
await page.fill("#telegram", "@validhandle");
await expect(page.getByText(/at least one character after @/i)).not.toBeVisible({
timeout: 2000,
});
// Wait for debounced validation
await page.waitForTimeout(600);
await page.fill("#nostr_npub", VALID_NPUB);
await expect(page.getByText(/must start with 'npub1'/i)).not.toBeVisible({ timeout: 2000 });
// Error should disappear
await expect(page.getByText(/at least one character after @/i)).not.toBeVisible();
await page.fill("#contact_email", "valid@email.com");
await expect(page.getByText(/valid email/i)).not.toBeVisible({ timeout: 2000 });
// Should be able to save
const saveButton = page.getByRole("button", { name: /save changes/i });
// Now all errors are fixed, save button should be enabled
await expect(saveButton).toBeEnabled();
await page.click('button:has-text("Save Changes")');
await expect(page.getByText(/saved successfully/i)).toBeVisible();
});
test("shows error for invalid email format", async ({ page }) => {
await page.goto("/profile");
// Enter invalid email
await page.fill("#contact_email", "not-an-email");
// Should show error
await expect(page.getByText(/valid email/i)).toBeVisible();
});
});
test.describe("Profile - Admin User Access", () => {