fix: use setItem helper and safer Playwright selector in tests

- Replace direct localStorage.setItem() with setItem helper in use-settings-migration.ts (line 472) for consistent storage-availability checks and error handling
- Replace brittle attribute selector with Playwright's getByRole in open-existing-project.spec.ts (line 162) to handle names containing special characters

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
DhanushSantosh
2026-01-18 19:06:07 +05:30
parent 505a2b1e0b
commit 980006d40e
4 changed files with 10 additions and 2 deletions

View File

@@ -469,7 +469,7 @@ export function useSettingsMigration(): MigrationState {
// Update localStorage with fresh server data to keep cache in sync // Update localStorage with fresh server data to keep cache in sync
// This prevents stale localStorage data from being used when switching between modes // This prevents stale localStorage data from being used when switching between modes
try { try {
localStorage.setItem('automaker-settings-cache', JSON.stringify(serverSettings)); setItem('automaker-settings-cache', JSON.stringify(serverSettings));
logger.debug('Updated localStorage with fresh server settings'); logger.debug('Updated localStorage with fresh server settings');
} catch (storageError) { } catch (storageError) {
logger.warn('Failed to update localStorage cache:', storageError); logger.warn('Failed to update localStorage cache:', storageError);

View File

@@ -159,7 +159,7 @@ test.describe('Open Project', () => {
// The project name appears in the project switcher button with title attribute // The project name appears in the project switcher button with title attribute
// (The button uses data-testid with projectId, not projectName) // (The button uses data-testid with projectId, not projectName)
if (targetProjectName) { if (targetProjectName) {
const projectSwitcherButton = page.locator(`button[title="${targetProjectName}"]`).first(); const projectSwitcherButton = page.getByRole('button', { name: targetProjectName }).first();
await expect(projectSwitcherButton).toBeVisible({ await expect(projectSwitcherButton).toBeVisible({
timeout: 15000, timeout: 15000,
}); });

View File

@@ -0,0 +1,4 @@
{
"name": "test-project-1768743000887",
"version": "1.0.0"
}

View File

@@ -0,0 +1,4 @@
{
"name": "test-project-1768742910934",
"version": "1.0.0"
}