forked from jsnbuchanan/crowd-funder-for-time-pwa
refactor: move duplicate account import warnings to notification constants
- Add NOTIFY_DUPLICATE_ACCOUNT_IMPORT constant for import warnings - Add NOTIFY_DUPLICATE_DERIVED_ACCOUNT constant for derived account warnings - Update ImportAccountView.vue to use notification constants - Update ImportDerivedAccountView.vue to use notification constants - Update test file to use notification constants for assertions Centralizes notification messages for better maintainability and consistency with the existing notification system. Files modified: - src/constants/notifications.ts: Add new notification constants - src/views/ImportAccountView.vue: Replace hardcoded messages with constants - src/views/ImportDerivedAccountView.vue: Replace hardcoded messages with constants - test-playwright/duplicate-import-test.spec.ts: Update test assertions
This commit is contained in:
@@ -1689,3 +1689,19 @@ export const NOTIFY_CONTACTS_ADDED_CONFIRM = {
|
|||||||
title: "They're Added To Your List",
|
title: "They're Added To Your List",
|
||||||
message: "Would you like to go to the main page now?",
|
message: "Would you like to go to the main page now?",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ImportAccountView.vue specific constants
|
||||||
|
// Used in: ImportAccountView.vue (onImportClick method - duplicate account warning)
|
||||||
|
export const NOTIFY_DUPLICATE_ACCOUNT_IMPORT = {
|
||||||
|
title: "Account Already Imported",
|
||||||
|
message:
|
||||||
|
"This account has already been imported. Please use a different seed phrase or check your existing accounts.",
|
||||||
|
};
|
||||||
|
|
||||||
|
// ImportDerivedAccountView.vue specific constants
|
||||||
|
// Used in: ImportDerivedAccountView.vue (incrementDerivation method - duplicate derived account warning)
|
||||||
|
export const NOTIFY_DUPLICATE_DERIVED_ACCOUNT = {
|
||||||
|
title: "Derived Account Already Exists",
|
||||||
|
message:
|
||||||
|
"This derived account already exists. Please try a different derivation path.",
|
||||||
|
};
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ import {
|
|||||||
import { retrieveAccountCount, importFromMnemonic } from "../libs/util";
|
import { retrieveAccountCount, importFromMnemonic } from "../libs/util";
|
||||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||||
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
||||||
|
import { NOTIFY_DUPLICATE_ACCOUNT_IMPORT } from "@/constants/notifications";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import Account View Component
|
* Import Account View Component
|
||||||
@@ -206,7 +207,7 @@ export default class ImportAccountView extends Vue {
|
|||||||
const isDuplicate = await this.checkForDuplicateAccount();
|
const isDuplicate = await this.checkForDuplicateAccount();
|
||||||
if (isDuplicate) {
|
if (isDuplicate) {
|
||||||
this.notify.warning(
|
this.notify.warning(
|
||||||
"This account has already been imported. Please use a different seed phrase or check your existing accounts.",
|
NOTIFY_DUPLICATE_ACCOUNT_IMPORT.message,
|
||||||
TIMEOUTS.LONG,
|
TIMEOUTS.LONG,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@@ -246,7 +247,7 @@ export default class ImportAccountView extends Vue {
|
|||||||
errorMessage.includes("Cannot import duplicate account")
|
errorMessage.includes("Cannot import duplicate account")
|
||||||
) {
|
) {
|
||||||
this.notify.warning(
|
this.notify.warning(
|
||||||
"This account has already been imported. Please use a different seed phrase or check your existing accounts.",
|
NOTIFY_DUPLICATE_ACCOUNT_IMPORT.message,
|
||||||
TIMEOUTS.LONG,
|
TIMEOUTS.LONG,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ import { createNotifyHelpers, TIMEOUTS, NotifyFunction } from "@/utils/notify";
|
|||||||
import {
|
import {
|
||||||
NOTIFY_ACCOUNT_DERIVATION_SUCCESS,
|
NOTIFY_ACCOUNT_DERIVATION_SUCCESS,
|
||||||
NOTIFY_ACCOUNT_DERIVATION_ERROR,
|
NOTIFY_ACCOUNT_DERIVATION_ERROR,
|
||||||
|
NOTIFY_DUPLICATE_DERIVED_ACCOUNT,
|
||||||
} from "@/constants/notifications";
|
} from "@/constants/notifications";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -175,7 +176,7 @@ export default class ImportAccountView extends Vue {
|
|||||||
const isDuplicate = await this.checkForDuplicateAccount(newId.did);
|
const isDuplicate = await this.checkForDuplicateAccount(newId.did);
|
||||||
if (isDuplicate) {
|
if (isDuplicate) {
|
||||||
this.notify.warning(
|
this.notify.warning(
|
||||||
"This derived account already exists. Please try a different derivation path.",
|
NOTIFY_DUPLICATE_DERIVED_ACCOUNT.message,
|
||||||
TIMEOUTS.LONG,
|
TIMEOUTS.LONG,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -243,13 +243,19 @@
|
|||||||
:project-name="name"
|
:project-name="name"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<h3 class="text-lg font-bold leading-tight mb-3">Offered To This Idea</h3>
|
<h3 class="text-lg font-bold leading-tight mb-3">
|
||||||
|
Offered To This Idea
|
||||||
|
</h3>
|
||||||
|
|
||||||
<div v-if="offersToThis.length === 0" class="text-sm">
|
<div v-if="offersToThis.length === 0" class="text-sm">
|
||||||
(None yet.<span v-if="activeDid && isRegistered"> Wanna
|
(None yet.<span v-if="activeDid && isRegistered">
|
||||||
<span class="cursor-pointer text-blue-500" @click="openOfferDialog()"
|
Wanna
|
||||||
>offer something… especially if others join you</span
|
<span
|
||||||
>?</span>)
|
class="cursor-pointer text-blue-500"
|
||||||
|
@click="openOfferDialog()"
|
||||||
|
>offer something… especially if others join you</span
|
||||||
|
>?</span
|
||||||
|
>)
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul v-else class="text-sm border-t border-slate-300">
|
<ul v-else class="text-sm border-t border-slate-300">
|
||||||
@@ -325,7 +331,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3 class="text-lg font-bold leading-tight mb-3">Given To This Project</h3>
|
<h3 class="text-lg font-bold leading-tight mb-3">
|
||||||
|
Given To This Project
|
||||||
|
</h3>
|
||||||
|
|
||||||
<div v-if="givesToThis.length === 0" class="text-sm">
|
<div v-if="givesToThis.length === 0" class="text-sm">
|
||||||
(None yet. If you've seen something, say something by clicking a
|
(None yet. If you've seen something, say something by clicking a
|
||||||
@@ -498,7 +506,9 @@
|
|||||||
Benefitted From This Project
|
Benefitted From This Project
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div v-if="givesProvidedByThis.length === 0" class="text-sm">(None yet.)</div>
|
<div v-if="givesProvidedByThis.length === 0" class="text-sm">
|
||||||
|
(None yet.)
|
||||||
|
</div>
|
||||||
|
|
||||||
<ul v-else class="text-sm border-t border-slate-300">
|
<ul v-else class="text-sm border-t border-slate-300">
|
||||||
<li
|
<li
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from '@playwright/test';
|
||||||
import { importUserFromAccount, getTestUserData } from './testUtils';
|
import { importUserFromAccount, getTestUserData } from './testUtils';
|
||||||
|
import { NOTIFY_DUPLICATE_ACCOUNT_IMPORT } from '../src/constants/notifications';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test duplicate account import functionality
|
* Test duplicate account import functionality
|
||||||
@@ -30,8 +31,7 @@ test.describe('Duplicate Account Import', () => {
|
|||||||
|
|
||||||
// Verify duplicate import shows warning message
|
// Verify duplicate import shows warning message
|
||||||
// The warning can appear either from the pre-check or from the saveNewIdentity error handling
|
// The warning can appear either from the pre-check or from the saveNewIdentity error handling
|
||||||
await expect(page.getByText("This account has already been imported")).toBeVisible();
|
await expect(page.getByText(NOTIFY_DUPLICATE_ACCOUNT_IMPORT.message)).toBeVisible();
|
||||||
await expect(page.getByText("Please use a different seed phrase or check your existing accounts")).toBeVisible();
|
|
||||||
|
|
||||||
// Verify we're still on the import page (not redirected to account)
|
// Verify we're still on the import page (not redirected to account)
|
||||||
await expect(page.getByPlaceholder("Seed Phrase")).toBeVisible();
|
await expect(page.getByPlaceholder("Seed Phrase")).toBeVisible();
|
||||||
@@ -58,6 +58,6 @@ test.describe('Duplicate Account Import', () => {
|
|||||||
|
|
||||||
// Verify second import was successful (should not show duplicate warning)
|
// Verify second import was successful (should not show duplicate warning)
|
||||||
await expect(page.getByRole("code")).toContainText(userOneData.did);
|
await expect(page.getByRole("code")).toContainText(userOneData.did);
|
||||||
await expect(page.getByText("This account has already been imported")).not.toBeVisible();
|
await expect(page.getByText(NOTIFY_DUPLICATE_ACCOUNT_IMPORT.message)).not.toBeVisible();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user