diff --git a/src/services/platforms/WebPlatformService.ts b/src/services/platforms/WebPlatformService.ts index b4c3c075..28ccdaf9 100644 --- a/src/services/platforms/WebPlatformService.ts +++ b/src/services/platforms/WebPlatformService.ts @@ -693,6 +693,7 @@ export class WebPlatformService implements PlatformService { const setClause = keys.map((key) => `${key} = ?`).join(", "); const sql = `UPDATE settings SET ${setClause} WHERE accountDid = ?`; const params = [...keys.map((key) => settings[key]), did]; + console.log("[WebPlatformService] updateDidSpecificSettings", sql, JSON.stringify(params, null, 2)); await this.dbExec(sql, params); } diff --git a/src/utils/PlatformServiceMixin.ts b/src/utils/PlatformServiceMixin.ts index d87b9f46..86f21ede 100644 --- a/src/utils/PlatformServiceMixin.ts +++ b/src/utils/PlatformServiceMixin.ts @@ -707,6 +707,7 @@ export const PlatformServiceMixin = { // Merge with any provided defaults (these take highest precedence) const finalSettings = { ...mergedSettings, ...defaults }; + console.log("[PlatformServiceMixin] $accountSettings", JSON.stringify(finalSettings, null, 2)); return finalSettings; } catch (error) { logger.error( diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index 81d84233..ab525e3a 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -828,15 +828,19 @@ export default class ContactsView extends Vue { * Handle registration prompt for new contacts */ private async handleRegistrationPrompt(newContact: Contact): Promise { + console.log("[ContactsView] handleRegistrationPrompt", this.isRegistered, this.hideRegisterPromptOnNewContact, newContact.registered); if ( - !this.isRegistered || - this.hideRegisterPromptOnNewContact || - newContact.registered + this.isRegistered === false || // the current Identity is not registered OR + this.hideRegisterPromptOnNewContact === true || // the user has hidden the registrationprompt OR + newContact.registered === true // the new contact is already registered ) { + // if any of the above are true, we do not want to show the registration prompt + console.log("[ContactsView] handleRegistrationPrompt we do not want to show the registration prompt"); return; } setTimeout(() => { + console.log("[ContactsView] handleRegistrationPrompt setTimeout"); this.$notify( { group: "modal", @@ -844,18 +848,22 @@ export default class ContactsView extends Vue { title: "Register", text: "Do you want to register them?", onCancel: async (stopAsking?: boolean) => { + console.log("[ContactsView] handleRegistrationPrompt onCancel", stopAsking); await this.handleRegistrationPromptResponse(stopAsking); }, onNo: async (stopAsking?: boolean) => { + console.log("[ContactsView] handleRegistrationPrompt onNo", stopAsking); await this.handleRegistrationPromptResponse(stopAsking); }, onYes: async () => { + console.log("[ContactsView] handleRegistrationPrompt onYes"); await this.register(newContact); }, promptToStopAsking: true, }, -1, ); + console.log("[ContactsView] handleRegistrationPrompt setTimeout done"); }, 1000); } diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 8eabc363..34cd1a60 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -9,7 +9,7 @@ Raymer * @version 1.0.0 */ -
+

{{ AppString.APP_NAME }} {{ package.version }} diff --git a/src/views/ImportAccountView.vue b/src/views/ImportAccountView.vue index 3c87e681..3f9cbc77 100644 --- a/src/views/ImportAccountView.vue +++ b/src/views/ImportAccountView.vue @@ -189,6 +189,7 @@ export default class ImportAccountView extends Vue { * Uses importFromMnemonic utility for secure import */ public async onImportClick() { + console.log("[ImportAccountView] onImportClick", this.mnemonic); if (!this.mnemonic?.trim()) { this.notify.warning( "Seed phrase is required to import an account.", @@ -206,6 +207,7 @@ export default class ImportAccountView extends Vue { // Check what was actually imported const settings = await this.$accountSettings(); + console.log("[ImportAccountView] settings", JSON.stringify(settings, null, 2)); // Check account-specific settings if (settings?.activeDid) { diff --git a/test-playwright/60-new-activity.spec.ts b/test-playwright/60-new-activity.spec.ts index e0a5633f..136ff5d0 100644 --- a/test-playwright/60-new-activity.spec.ts +++ b/test-playwright/60-new-activity.spec.ts @@ -1,15 +1,48 @@ import { test, expect } from '@playwright/test'; -import { importUser, generateNewEthrUser, switchToUser } from './testUtils'; +import { switchToUser, getTestUserData } from './testUtils'; test('New offers for another user', async ({ page }) => { - const user01Did = await generateNewEthrUser(page); await page.goto('./'); + + // Get the auto-created DID from the HomeView + await page.waitForLoadState('networkidle'); + const autoCreatedDid = await page.getAttribute('#Content', 'data-active-did'); + console.log("[New offers for another user] Auto-created DID:", autoCreatedDid); + + if (!autoCreatedDid) { + throw new Error('Auto-created DID not found in HomeView'); + } + await page.getByTestId('closeOnboardingAndFinish').click(); await expect(page.getByTestId('newDirectOffersActivityNumber')).toBeHidden(); - await importUser(page, '00'); + // Navigate to AccountViewView to use the Identity Switcher + await page.goto('./account'); + + // Click "Show Advanced Settings" to reveal the identity switcher + await page.getByTestId('advancedSettings').click(); + + // Use the identity switcher to add User Zero + await page.locator('#switch-identity-link').click(); + await page.locator('#start-link').click(); + + // Select "You have a seed" option + await page.getByText('You have a seed').click(); + + // Get User Zero's seed phrase using the new method + const userZeroData = getTestUserData('00'); + + // Enter User Zero's seed phrase + await page.getByPlaceholder('Seed Phrase').fill(userZeroData.seedPhrase); + + await page.getByRole('button', { name: 'Import' }).click(); + + // Wait for import to complete + await page.waitForLoadState('networkidle'); + + // As User Zero, add the auto-created DID as a contact await page.goto('./contacts'); - await page.getByPlaceholder('URL or DID, Name, Public Key').fill(user01Did + ', A Friend'); + await page.getByPlaceholder('URL or DID, Name, Public Key').fill(autoCreatedDid + ', A Friend'); await expect(page.locator('button > svg.fa-plus')).toBeVisible(); await page.locator('button > svg.fa-plus').click(); await page.locator('div[role="alert"] button:has-text("No")').click(); // don't register @@ -41,8 +74,8 @@ test('New offers for another user', async ({ page }) => { await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert await expect(page.locator('div[role="alert"] button > svg.fa-xmark')).toBeHidden(); // ensure alert is gone - // as user 1, go to the home page and check that two offers are shown as new - await switchToUser(page, user01Did); + // Switch back to the auto-created DID (the "another user") to see the offers + await switchToUser(page, autoCreatedDid); await page.goto('./'); let offerNumElem = page.getByTestId('newDirectOffersActivityNumber'); await expect(offerNumElem).toHaveText('2'); diff --git a/test-playwright/testUtils.ts b/test-playwright/testUtils.ts index 8b991f50..5733f4ea 100644 --- a/test-playwright/testUtils.ts +++ b/test-playwright/testUtils.ts @@ -1,24 +1,30 @@ import { expect, Page } from '@playwright/test'; -// Import the seed and switch to the user based on the ID. +// Get test user data based on the ID. // '01' -> user 111 // otherwise -> user 000 // (... which is a weird convention but I haven't taken the time to change it) -export async function importUser(page: Page, id?: string): Promise { - let seedPhrase, userName, did; - - // Set seed phrase and DID based on user ID +export function getTestUserData(id?: string): { seedPhrase: string, userName: string, did: string } { switch(id) { case '01': - seedPhrase = 'island fever beef wine urban aim vacant quit afford total poem flame service calm better adult neither color gaze forum month sister imitate excite'; - userName = 'User One'; - did = 'did:ethr:0x111d15564f824D56C7a07b913aA7aDd03382aA39'; - break; + return { + seedPhrase: 'island fever beef wine urban aim vacant quit afford total poem flame service calm better adult neither color gaze forum month sister imitate excite', + userName: 'User One', + did: 'did:ethr:0x111d15564f824D56C7a07b913aA7aDd03382aA39' + }; default: // to user 00 - seedPhrase = 'rigid shrug mobile smart veteran half all pond toilet brave review universe ship congress found yard skate elite apology jar uniform subway slender luggage'; - userName = 'User Zero'; - did = 'did:ethr:0x0000694B58C2cC69658993A90D3840C560f2F51F'; + return { + seedPhrase: 'rigid shrug mobile smart veteran half all pond toilet brave review universe ship congress found yard skate elite apology jar uniform subway slender luggage', + userName: 'User Zero', + did: 'did:ethr:0x0000694B58C2cC69658993A90D3840C560f2F51F' + }; } +} + +// Import the seed and switch to the user based on the ID. +export async function importUser(page: Page, id?: string): Promise { + const userData = getTestUserData(id); + const { seedPhrase, userName, did } = userData; // Import ID await page.goto('./start'); @@ -109,7 +115,7 @@ export async function generateRandomString(length: number): Promise { // Function to create an array of unique strings export async function createUniqueStringsArray(count: number): Promise { - const stringsArray = []; + const stringsArray: string[] = []; const stringLength = 16; for (let i = 0; i < count; i++) { @@ -122,7 +128,7 @@ export async function createUniqueStringsArray(count: number): Promise // Function to create an array of two-digit non-zero numbers export async function createRandomNumbersArray(count: number): Promise { - const numbersArray = []; + const numbersArray: number[] = []; for (let i = 0; i < count; i++) { let randomNumber = Math.floor(Math.random() * 99) + 1;