Browse Source

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
pull/190/head
Jose Olarte III 6 days ago
parent
commit
c4f2bb5e3a
  1. 16
      src/constants/notifications.ts
  2. 5
      src/views/ImportAccountView.vue
  3. 3
      src/views/ImportDerivedAccountView.vue
  4. 24
      src/views/ProjectViewView.vue
  5. 6
      test-playwright/duplicate-import-test.spec.ts

16
src/constants/notifications.ts

@ -1689,3 +1689,19 @@ export const NOTIFY_CONTACTS_ADDED_CONFIRM = {
title: "They're Added To Your List",
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.",
};

5
src/views/ImportAccountView.vue

@ -95,6 +95,7 @@ import {
import { retrieveAccountCount, importFromMnemonic } from "../libs/util";
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
import { NOTIFY_DUPLICATE_ACCOUNT_IMPORT } from "@/constants/notifications";
/**
* Import Account View Component
@ -206,7 +207,7 @@ export default class ImportAccountView extends Vue {
const isDuplicate = await this.checkForDuplicateAccount();
if (isDuplicate) {
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,
);
return;
@ -246,7 +247,7 @@ export default class ImportAccountView extends Vue {
errorMessage.includes("Cannot import duplicate account")
) {
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,
);
return;

3
src/views/ImportDerivedAccountView.vue

@ -91,6 +91,7 @@ import { createNotifyHelpers, TIMEOUTS, NotifyFunction } from "@/utils/notify";
import {
NOTIFY_ACCOUNT_DERIVATION_SUCCESS,
NOTIFY_ACCOUNT_DERIVATION_ERROR,
NOTIFY_DUPLICATE_DERIVED_ACCOUNT,
} from "@/constants/notifications";
@Component({
@ -175,7 +176,7 @@ export default class ImportAccountView extends Vue {
const isDuplicate = await this.checkForDuplicateAccount(newId.did);
if (isDuplicate) {
this.notify.warning(
"This derived account already exists. Please try a different derivation path.",
NOTIFY_DUPLICATE_DERIVED_ACCOUNT.message,
TIMEOUTS.LONG,
);
return;

24
src/views/ProjectViewView.vue

@ -243,13 +243,19 @@
: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">
(None yet.<span v-if="activeDid && isRegistered"> Wanna
<span class="cursor-pointer text-blue-500" @click="openOfferDialog()"
>offer something&hellip; especially if others join you</span
>?</span>)
(None yet.<span v-if="activeDid && isRegistered">
Wanna
<span
class="cursor-pointer text-blue-500"
@click="openOfferDialog()"
>offer something&hellip; especially if others join you</span
>?</span
>)
</div>
<ul v-else class="text-sm border-t border-slate-300">
@ -325,7 +331,9 @@
</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">
(None yet. If you've seen something, say something by clicking a
@ -498,7 +506,9 @@
Benefitted From This Project
</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">
<li

6
test-playwright/duplicate-import-test.spec.ts

@ -1,5 +1,6 @@
import { test, expect } from '@playwright/test';
import { importUserFromAccount, getTestUserData } from './testUtils';
import { NOTIFY_DUPLICATE_ACCOUNT_IMPORT } from '../src/constants/notifications';
/**
* Test duplicate account import functionality
@ -30,8 +31,7 @@ test.describe('Duplicate Account Import', () => {
// Verify duplicate import shows warning message
// 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("Please use a different seed phrase or check your existing accounts")).toBeVisible();
await expect(page.getByText(NOTIFY_DUPLICATE_ACCOUNT_IMPORT.message)).toBeVisible();
// Verify we're still on the import page (not redirected to account)
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)
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();
});
});

Loading…
Cancel
Save