diff --git a/src/views/auth/CreateIdentity.svelte b/src/views/auth/CreateIdentity.svelte index d36d3b87b..ef4c8e1ce 100644 --- a/src/views/auth/CreateIdentity.svelte +++ b/src/views/auth/CreateIdentity.svelte @@ -16,10 +16,10 @@ let notMatchingPassphrases = $state(); let passphraseRepeat = $state(""); let alias = $state(""); - const errors: { alias: ErrorWrapper[]; passphrase: ErrorWrapper[] } = { + const errors = $state<{ alias: ErrorWrapper[]; passphrase: ErrorWrapper[] }>({ alias: [], passphrase: [], - }; + }); const validatePassphraseRepeat = debounce(() => { if (passphrase !== passphraseRepeat && passphraseRepeat.length !== 0) { diff --git a/tests/e2e/createIdentity.spec.ts b/tests/e2e/createIdentity.spec.ts new file mode 100644 index 000000000..afeb2ce63 --- /dev/null +++ b/tests/e2e/createIdentity.spec.ts @@ -0,0 +1,33 @@ +import { expect, test } from "@tests/support/fixtures.js"; + +test("explains why an alias is invalid", async ({ page }) => { + await page.route( + url => url.pathname === "/startup", + route => + route.fulfill({ + status: 500, + json: { + code: "IdentityError.MissingProfile", + message: "No profile found", + }, + }), + ); + await page.goto("/"); + + const alias = page.getByPlaceholder("Enter desired alias"); + await alias.fill("has space"); + await expect( + page.getByText("Alias cannot contain whitespace."), + ).toBeVisible(); + + await alias.fill("a".repeat(33)); + await expect( + page.getByText("Alias is too long, max 32 characters."), + ).toBeVisible(); + await expect(page.getByText("Alias cannot contain whitespace.")).toBeHidden(); + + await alias.fill("alice"); + await expect( + page.getByText("Max 32 characters, no whitespace."), + ).toBeVisible(); +});