fix(front): clean localStorage on user change
- fix issue with selected drive and user logout/login via another user
(was raising a "404 not found")
- normalize all localStorage to "oxi-" prefix
- add a specific frontend/AGENTS.md for frontend part (stop increasing the global AGENTS.md)
This commit is contained in:
@@ -1,11 +1,22 @@
|
||||
import { it, expect, vi, beforeEach } from 'vitest';
|
||||
import { render, screen, fireEvent, waitFor } from '@testing-library/svelte';
|
||||
|
||||
const { goto, pageState, session } = vi.hoisted(() => ({
|
||||
goto: vi.fn(),
|
||||
pageState: { url: new URL('http://localhost/login') } as { url: URL },
|
||||
session: { user: null } as { user: unknown }
|
||||
}));
|
||||
const { goto, pageState, session } = vi.hoisted(() => {
|
||||
// `setUser` mirrors the real SessionStore method: sets the user and
|
||||
// runs `ensureActiveUser` (localStorage cleanup on account switch).
|
||||
// Tests don't care about the cleanup; the mock just assigns.
|
||||
const store: { user: unknown; setUser: (u: unknown) => void } = {
|
||||
user: null,
|
||||
setUser(u) {
|
||||
store.user = u;
|
||||
}
|
||||
};
|
||||
return {
|
||||
goto: vi.fn(),
|
||||
pageState: { url: new URL('http://localhost/login') } as { url: URL },
|
||||
session: store
|
||||
};
|
||||
});
|
||||
vi.mock('$app/navigation', () => ({ goto }));
|
||||
vi.mock('$app/state', () => ({ page: pageState }));
|
||||
vi.mock('$lib/stores/session.svelte', () => ({ session }));
|
||||
|
||||
Reference in New Issue
Block a user