Repository navigation
Expand file tree
/
Copy pathLOCAL_TEST_SCRIPT.js
More file actions
94 lines (85 loc) · 3.74 KB
/
Copy pathLOCAL_TEST_SCRIPT.js
File metadata and controls
94 lines (85 loc) · 3.74 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Local Test Script for Payment Settings Synchronization
// Run this in the browser console at http://localhost:3012
console.log('=== LOCAL PAYMENT SETTINGS SYNCHRONIZATION TEST ===');
// Test 1: Verify initial state
console.log('\n1. Checking initial payment settings...');
try {
const initialSettings = localStorage.getItem('giftEasePaymentSettings');
if (initialSettings) {
const parsed = JSON.parse(initialSettings);
console.log('✅ Initial settings found:', {
upiId: parsed.upiId,
upiName: parsed.upiName,
hasInstructions: !!parsed.paymentInstructions
});
} else {
console.log('ℹ️ No initial settings found (will use defaults)');
}
} catch (error) {
console.log('❌ Error checking initial settings:', error);
}
// Test 2: Simulate admin panel updating payment settings
console.log('\n2. Simulating admin panel payment settings update...');
try {
const testSettings = {
upiId: 'localtest@upi',
upiName: 'Local Test Payments',
paymentInstructions: 'LOCAL TEST: Please make payment using UPI\n1. Open your UPI app\n2. Scan QR or enter UPI ID\n3. Pay exact amount\n4. Note transaction ID',
qrCodeImage: 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect width="100" height="100" fill="lightblue"/><text x="50" y="50" font-family="Arial" font-size="12" text-anchor="middle" fill="darkblue">TEST QR</text></svg>'
};
// Save to localStorage (simulating what admin panel does)
localStorage.setItem('giftEasePaymentSettings', JSON.stringify(testSettings));
console.log('✅ Test settings saved to localStorage');
// Dispatch storage event (simulating cross-tab update)
const storageEvent = new StorageEvent('storage', {
key: 'giftEasePaymentSettings',
oldValue: initialSettings,
newValue: JSON.stringify(testSettings),
url: window.location.href,
storageArea: window.localStorage
});
window.dispatchEvent(storageEvent);
console.log('✅ Storage event dispatched');
} catch (error) {
console.log('❌ Error simulating admin update:', error);
}
// Test 3: Verify polling mechanism
console.log('\n3. Testing polling mechanism...');
console.log('ℹ️ Please wait 3 seconds to see if polling picks up changes...');
setTimeout(() => {
try {
const currentSettings = localStorage.getItem('giftEasePaymentSettings');
if (currentSettings) {
const parsed = JSON.parse(currentSettings);
if (parsed.upiId === 'localtest@upi') {
console.log('✅ Polling mechanism working - settings updated');
} else {
console.log('ℹ️ Polling test complete - check manually in UI');
}
}
} catch (error) {
console.log('❌ Error in polling test:', error);
}
}, 3000);
// Test 4: Instructions for manual verification
console.log('\n=== MANUAL VERIFICATION INSTRUCTIONS ===');
console.log('1. Open TWO tabs:');
console.log(' - Tab 1: http://localhost:3012/admin/dashboard (login as admin)');
console.log(' - Tab 2: http://localhost:3012/packages/play-store (or any product)');
console.log('');
console.log('2. In Tab 1 Admin Panel:');
console.log(' - Go to "Payment Settings" tab');
console.log(' - Change UPI ID to: test@localtest');
console.log(' - Change UPI Name to: Local Test Name');
console.log(' - Click "Save Settings"');
console.log('');
console.log('3. In Tab 2 Payment Page:');
console.log(' - Look for UPI ID and Name to update within 2-3 seconds');
console.log(' - No page refresh should be needed');
console.log('');
console.log('4. Expected Result:');
console.log(' - UPI ID should show: test@localtest');
console.log(' - UPI Name should show: Local Test Name');
console.log('');
console.log('If this works, the fix is successful!');
console.log('If not, there may be additional issues to resolve.');