test(playwright): fix Active Identity migration test element selectors

Fixed failing Playwright tests for Active Identity migration by correcting
DOM element selectors and test expectations.

- Replace basic smoke tests with comprehensive step-by-step debugging tests
- Fix test assertions to expect "Your Identity" heading instead of "Account"
- Update identity switcher element targeting to use `li div` selectors
- Add proper wait conditions for advanced settings visibility
- Enhance switchToUser() utility with better error handling and waits

Resolves issue where tests were clicking wrong elements (QuickNav instead
of identity list items) and expecting incorrect page headings. Tests now
properly verify that identity switching functionality works correctly
with the Active Identity migration.
This commit is contained in:
Matthew Raymer
2025-08-22 13:09:27 +00:00
parent 4ea72162ec
commit 28c541e682
3 changed files with 284 additions and 32 deletions

View File

@@ -17,13 +17,24 @@ test.describe('Active Identity Migration', () => {
const userZeroData = getTestUserData('00');
const userOneData = getTestUserData('01');
// Import User One if not already present
// Import both users to ensure they exist
try {
await importUser(page, '00');
await page.waitForLoadState('networkidle');
} catch (error) {
// User Zero might already exist, continue
}
try {
await importUser(page, '01');
await page.waitForLoadState('networkidle');
} catch (error) {
// User One might already exist, continue
}
// Ensure we start with User Zero active
await switchToUser(page, userZeroData.did);
// Start with User Zero (default)
await page.goto('./account');
await page.waitForLoadState('networkidle');
@@ -34,7 +45,11 @@ test.describe('Active Identity Migration', () => {
// Switch to User One using the identity switcher
await page.getByTestId('advancedSettings').click();
await page.locator('#switch-identity-link').click();
// Wait for the switch identity link to be visible
const switchIdentityLink = page.locator('#switch-identity-link');
await switchIdentityLink.waitFor({ state: 'visible', timeout: 10000 });
await switchIdentityLink.click();
// Wait for identity switcher to load
await page.waitForLoadState('networkidle');
@@ -49,7 +64,7 @@ test.describe('Active Identity Migration', () => {
await expect(didWrapper).toContainText(userOneData.did);
// Verify the switch was successful by checking the account page
await expect(page.locator('h1:has-text("Account")')).toBeVisible();
await expect(page.locator('h1:has-text("Your Identity")')).toBeVisible();
});
test('should maintain identity state after page refresh', async ({ page }) => {
@@ -72,7 +87,11 @@ test.describe('Active Identity Migration', () => {
// Navigate to identity switcher
await page.goto('./account');
await page.getByTestId('advancedSettings').click();
await page.locator('#switch-identity-link').click();
// Wait for the switch identity link to be visible
const switchIdentityLink = page.locator('#switch-identity-link');
await switchIdentityLink.waitFor({ state: 'visible', timeout: 10000 });
await switchIdentityLink.click();
// Wait for identity switcher to load
await page.waitForLoadState('networkidle');