small validation fixes

This commit is contained in:
counterweight 2025-12-19 10:52:47 +01:00
parent bbc5625b2d
commit ead8a566d0
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
6 changed files with 201 additions and 102 deletions

View file

@ -227,14 +227,27 @@ test.describe("Profile - Validation", () => {
await clearProfileData(page);
});
test("shows error for invalid telegram handle (missing @)", async ({ page }) => {
test("auto-prepends @ for telegram when starting with letter", async ({ page }) => {
await page.goto("/profile");
// Enter invalid telegram (no @)
await page.fill("#telegram", "noatsign");
// Type a letter without @ - should auto-prepend @
await page.fill("#telegram", "testhandle");
// Should show error
await expect(page.getByText(/must start with @/i)).toBeVisible();
// Should show @testhandle in the input
await expect(page.locator("#telegram")).toHaveValue("@testhandle");
});
test("shows error for telegram handle that is too short", async ({ page }) => {
await page.goto("/profile");
// Enter telegram with @ but too short (needs 5+ chars)
await page.fill("#telegram", "@ab");
// Wait for debounced validation
await page.waitForTimeout(600);
// Should show error about length
await expect(page.getByText(/at least 5 characters/i)).toBeVisible();
// Save button should be disabled
const saveButton = page.getByRole("button", { name: /save changes/i });