From 61b855b8ef3e61c53927a5989bd43bc65520660c Mon Sep 17 00:00:00 2001 From: Jerome Manzano Date: Mon, 19 Dec 2022 07:31:16 +0800 Subject: [PATCH] fix: invalid address error message Show error message instead of translation path --- src/components/settings/AddressBook.vue | 2 +- tests/e2e/settings/settings.test.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/components/settings/AddressBook.vue b/src/components/settings/AddressBook.vue index e55585b8..7919fcb2 100644 --- a/src/components/settings/AddressBook.vue +++ b/src/components/settings/AddressBook.vue @@ -68,7 +68,7 @@ const validVerifier = (value: string) => { const getErrorMessage = () => { const selectedType = newContactState.transferType?.value || ""; if (!selectedType) return ""; - return ALLOWED_VERIFIERS_ERRORS[selectedType]; + return t(ALLOWED_VERIFIERS_ERRORS[selectedType]); }; const validNewContact = (value: string): boolean => { diff --git a/tests/e2e/settings/settings.test.ts b/tests/e2e/settings/settings.test.ts index 22417ffd..d0468ad0 100644 --- a/tests/e2e/settings/settings.test.ts +++ b/tests/e2e/settings/settings.test.ts @@ -71,6 +71,25 @@ test.describe("Settings Page", async () => { await page.click("button >> text=Close"); }); + test("Empty contact name should show required error message", async () => { + // // see navigation works correctly + await switchTab(page, "settings"); + + // if contact is empty, show Required error message + await page.click("text=Add Contact"); + await expect(page.locator("div >> text=Required")).toHaveCount(1); + }); + + test("Invalid public key should show invalid error message", async () => { + // // see navigation works correctly + await switchTab(page, "settings"); + + // if public key is invalid, show Invalid SOL Address error message + await page.fill("input[placeholder='Enter SOL Public Key']", `invalid-${IMPORT_ACC_ADDRESS}`); + await page.click("text=Add Contact"); + await expect(page.locator("div >> text=Invalid SOL Address")).toHaveCount(1); + }); + test("Contact should be added and then deleted", async () => { // // see navigation works correctly await switchTab(page, "settings");