[PR #24663] [CLOSED] chore: mock localStorage in web tests #17957

Closed
opened 2026-02-05 16:30:14 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/immich-app/immich/pull/24663
Author: @timonrieger
Created: 12/18/2025
Status: Closed

Base: mainHead: tests/fix-localstorage-mock-web-tests


📝 Commits (2)

  • e6694d7 test(web): mock localStorage for svelte-persisted-store in setup.ts
  • de32c72 test(web): use vi.stubGlobal to mock localStorage in setup.ts

📊 Changes

1 file changed (+10 additions, -0 deletions)

View changed files

📝 web/src/test-data/setup.ts (+10 -0)

📄 Description

Test Fix

Fixed test environment issue where svelte-persisted-store was failing to access localStorage during test initialization, causing 20 test files to fail. The fix ensures localStorage is properly available in the test environment, resolving all localStorage-related errors and allowing all tests to run correctly.

Test results:

  • Run with: cd web && pnpm test
  • Before fix: See before.log - 20 failed test files due to localStorage errors
  • After fix: See after.log - 35 passed test files, localStorage errors resolved

Note: The remaining failing tests in timeline-manager.svelte.spec.ts are unrelated to this fix and are out of scope for this PR. These appear to be pre-existing test issues.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/immich-app/immich/pull/24663 **Author:** [@timonrieger](https://github.com/timonrieger) **Created:** 12/18/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `tests/fix-localstorage-mock-web-tests` --- ### 📝 Commits (2) - [`e6694d7`](https://github.com/immich-app/immich/commit/e6694d72e38dc0818243085a31fca31a4900fe9a) test(web): mock localStorage for svelte-persisted-store in setup.ts - [`de32c72`](https://github.com/immich-app/immich/commit/de32c7208205286ddf9dc89fe1cd4dc4c5a64d37) test(web): use vi.stubGlobal to mock localStorage in setup.ts ### 📊 Changes **1 file changed** (+10 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `web/src/test-data/setup.ts` (+10 -0) </details> ### 📄 Description ## Test Fix Fixed test environment issue where `svelte-persisted-store` was failing to access `localStorage` during test initialization, causing 20 test files to fail. The fix ensures `localStorage` is properly available in the test environment, resolving all localStorage-related errors and allowing all tests to run correctly. **Test results:** - Run with: `cd web && pnpm test` - Before fix: See [before.log](https://github.com/user-attachments/files/24237697/before.log) - 20 failed test files due to localStorage errors - After fix: See [after.log](https://github.com/user-attachments/files/24237696/after.log) - 35 passed test files, localStorage errors resolved **Note:** The remaining failing tests in `timeline-manager.svelte.spec.ts` are unrelated to this fix and are out of scope for this PR. These appear to be pre-existing test issues. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 16:30:14 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#17957