fix(active-identity): complete component migration to new Active Identity system
Fixes gift recording functionality by migrating remaining components from legacy settings.activeDid to new $getActiveDid() method. Migration 004 dropped settings.activeDid column before all components were updated, causing validation failures in GiftedDialog, OfferDialog, and OnboardingDialog. Added comprehensive logging to $getActiveDid() method and HomeView initialization for debugging. Test "Check User 0 can register a random person" now passes consistently. - GiftedDialog, OfferDialog, OnboardingDialog use new Active Identity system - Enhanced logging in PlatformServiceMixin.$getActiveDid() method - Added debugging logs to HomeView component lifecycle - Fixed Playwright test navigation and element selectors
This commit is contained in:
@@ -218,7 +218,10 @@ export default class GiftedDialog extends Vue {
|
||||
try {
|
||||
const settings = await this.$settings();
|
||||
this.apiServer = settings.apiServer || "";
|
||||
this.activeDid = settings.activeDid || "";
|
||||
// Use new façade method with legacy fallback
|
||||
const retrievedActiveDid = await this.$getActiveDid();
|
||||
this.activeDid = retrievedActiveDid || "";
|
||||
logger.debug("[GiftedDialog] Set activeDid from new system:", this.activeDid);
|
||||
|
||||
this.allContacts = await this.$contacts();
|
||||
|
||||
@@ -292,7 +295,9 @@ export default class GiftedDialog extends Vue {
|
||||
}
|
||||
|
||||
async confirm() {
|
||||
logger.debug("[GiftedDialog] confirm() called with activeDid:", this.activeDid);
|
||||
if (!this.activeDid) {
|
||||
logger.error("[GiftedDialog] Validation failed - activeDid is empty/null:", this.activeDid);
|
||||
this.safeNotify.error(
|
||||
NOTIFY_GIFTED_DETAILS_NO_IDENTIFIER.message,
|
||||
TIMEOUTS.SHORT,
|
||||
|
||||
@@ -175,7 +175,8 @@ export default class OfferDialog extends Vue {
|
||||
|
||||
const settings = await this.$accountSettings();
|
||||
this.apiServer = settings.apiServer || "";
|
||||
this.activeDid = settings.activeDid || "";
|
||||
// Use new façade method with legacy fallback
|
||||
this.activeDid = (await this.$getActiveDid()) || "";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (err: any) {
|
||||
|
||||
@@ -270,7 +270,8 @@ export default class OnboardingDialog extends Vue {
|
||||
async open(page: OnboardPage) {
|
||||
this.page = page;
|
||||
const settings = await this.$accountSettings();
|
||||
this.activeDid = settings.activeDid || "";
|
||||
// Use new façade method with legacy fallback
|
||||
this.activeDid = (await this.$getActiveDid()) || "";
|
||||
this.isRegistered = !!settings.isRegistered;
|
||||
|
||||
const contacts = await this.$getAllContacts();
|
||||
|
||||
@@ -979,13 +979,18 @@ export const PlatformServiceMixin = {
|
||||
*/
|
||||
async $getActiveDid(scope: string = DEFAULT_SCOPE): Promise<string | null> {
|
||||
try {
|
||||
logger.debug("[ActiveDid] Getting activeDid for scope:", scope);
|
||||
|
||||
// Try new active_identity table first
|
||||
const row = await this.$first<ActiveIdentity>(
|
||||
"SELECT active_did FROM active_identity WHERE scope = ? LIMIT 1",
|
||||
[scope],
|
||||
);
|
||||
|
||||
logger.debug("[ActiveDid] New system result:", row?.active_did || "null");
|
||||
|
||||
if (row?.active_did) {
|
||||
logger.debug("[ActiveDid] Using new system value:", row.active_did);
|
||||
return row.active_did;
|
||||
}
|
||||
|
||||
@@ -999,9 +1004,43 @@ export const PlatformServiceMixin = {
|
||||
"SELECT activeDid FROM settings WHERE id = ? LIMIT 1",
|
||||
[MASTER_SETTINGS_KEY],
|
||||
);
|
||||
|
||||
logger.debug("[ActiveDid] Legacy fallback result:", legacy?.activeDid || "null");
|
||||
return legacy?.activeDid || null;
|
||||
}
|
||||
|
||||
logger.debug("[ActiveDid] No fallback available, returning null");
|
||||
|
||||
// Log current database state for debugging
|
||||
try {
|
||||
const activeIdentityCount = await this.$first<{count: number}>(
|
||||
"SELECT COUNT(*) as count FROM active_identity"
|
||||
);
|
||||
const settingsCount = await this.$first<{count: number}>(
|
||||
"SELECT COUNT(*) as count FROM settings"
|
||||
);
|
||||
const accountsCount = await this.$first<{count: number}>(
|
||||
"SELECT COUNT(*) as count FROM accounts"
|
||||
);
|
||||
|
||||
// Also check actual values
|
||||
const activeIdentityValue = await this.$first<{active_did: string}>(
|
||||
"SELECT active_did FROM active_identity WHERE scope = 'default' LIMIT 1"
|
||||
);
|
||||
const settingsValue = await this.$first<{activeDid: string}>(
|
||||
"SELECT activeDid FROM settings WHERE id = 1 LIMIT 1"
|
||||
);
|
||||
const firstAccount = await this.$first<{did: string}>(
|
||||
"SELECT did FROM accounts LIMIT 1"
|
||||
);
|
||||
|
||||
logger.debug("[ActiveDid] Database state - active_identity:", activeIdentityCount?.count, "value:", activeIdentityValue?.active_did || "null");
|
||||
logger.debug("[ActiveDid] Database state - settings:", settingsCount?.count, "value:", settingsValue?.activeDid || "null");
|
||||
logger.debug("[ActiveDid] Database state - accounts:", accountsCount?.count, "first:", firstAccount?.did || "null");
|
||||
} catch (dbError) {
|
||||
logger.debug("[ActiveDid] Could not log database state:", dbError);
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (error) {
|
||||
logger.error("[PlatformServiceMixin] Error getting activeDid:", error);
|
||||
|
||||
@@ -454,6 +454,7 @@ export default class HomeView extends Vue {
|
||||
* Called automatically by Vue lifecycle system
|
||||
*/
|
||||
async mounted() {
|
||||
logger.debug("[HomeView] mounted() starting");
|
||||
try {
|
||||
await this.initializeIdentity();
|
||||
// Settings already loaded in initializeIdentity()
|
||||
@@ -494,6 +495,7 @@ export default class HomeView extends Vue {
|
||||
* @throws Logs error if DID retrieval fails
|
||||
*/
|
||||
private async initializeIdentity() {
|
||||
logger.debug("[HomeView] initializeIdentity() starting");
|
||||
try {
|
||||
// Retrieve DIDs with better error handling
|
||||
try {
|
||||
@@ -539,7 +541,10 @@ export default class HomeView extends Vue {
|
||||
await this.ensureCorrectApiServer();
|
||||
|
||||
// Use new façade method with legacy fallback
|
||||
this.activeDid = (await this.$getActiveDid()) || "";
|
||||
const retrievedActiveDid = await this.$getActiveDid();
|
||||
logger.debug("[HomeView] Retrieved activeDid:", retrievedActiveDid);
|
||||
this.activeDid = retrievedActiveDid || "";
|
||||
logger.debug("[HomeView] Set activeDid to:", this.activeDid);
|
||||
|
||||
// Load contacts with graceful fallback
|
||||
try {
|
||||
|
||||
@@ -43,11 +43,11 @@ test.describe('Active Identity Migration - Smoke Test', () => {
|
||||
|
||||
test('should load home page with active identity without errors', async ({ page }) => {
|
||||
// Navigate to home page (which uses our migrated activeDid logic)
|
||||
await page.goto('./home');
|
||||
await page.goto('./');
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Verify page loads without errors
|
||||
await expect(page.locator('h1:has-text("Home")')).toBeVisible();
|
||||
await expect(page.locator('#ViewHeading')).toBeVisible();
|
||||
|
||||
// This test verifies that:
|
||||
// 1. HomeView.vue loads correctly with our migrated activeDid logic
|
||||
|
||||
Reference in New Issue
Block a user