forked from Axionvera/axionvera-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-sidebar.js
More file actions
47 lines (37 loc) · 1.61 KB
/
Copy pathverify-sidebar.js
File metadata and controls
47 lines (37 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Simple verification script for useSidebar hook
// This script can be run in a browser console to verify localStorage functionality
console.log('=== Sidebar State Verification ===');
// Test 1: Check if localStorage is available
console.log('1. localStorage available:', typeof Storage !== 'undefined');
// Test 2: Simulate the useSidebar hook logic
const SIDEBAR_STATE_KEY = 'sidebar-open';
function getInitialSidebarState() {
try {
const savedState = localStorage.getItem(SIDEBAR_STATE_KEY);
return savedState !== null ? JSON.parse(savedState) : true;
} catch (error) {
console.warn('Failed to parse sidebar state from localStorage:', error);
return true;
}
}
function saveSidebarState(isOpen) {
try {
localStorage.setItem(SIDEBAR_STATE_KEY, JSON.stringify(isOpen));
console.log(`✅ Saved sidebar state: ${isOpen}`);
} catch (error) {
console.warn('Failed to save sidebar state to localStorage:', error);
}
}
// Test 3: Initial state
console.log('2. Initial sidebar state:', getInitialSidebarState());
// Test 4: Save different states
console.log('3. Testing state persistence...');
saveSidebarState(false);
console.log('4. State after saving false:', getInitialSidebarState());
saveSidebarState(true);
console.log('5. State after saving true:', getInitialSidebarState());
// Test 5: Clear and test default
localStorage.removeItem(SIDEBAR_STATE_KEY);
console.log('6. State after clearing localStorage (should default to true):', getInitialSidebarState());
console.log('=== Verification Complete ===');
console.log('The useSidebar hook should work correctly with localStorage persistence.');