-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-admin-functionality.js
More file actions
149 lines (128 loc) Β· 4.25 KB
/
Copy pathtest-admin-functionality.js
File metadata and controls
149 lines (128 loc) Β· 4.25 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env node
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
// Get __dirname equivalent in ES modules
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
console.log('π§ͺ Testing Admin Functionality...');
// Check for required admin components
const adminComponents = [
'src/pages/AdminLogin.jsx',
'src/pages/LocalAdminPanel.jsx',
'src/contexts/AuthContext.jsx',
'src/components/ProtectedRoute.jsx'
];
let allComponentsExist = true;
for (const component of adminComponents) {
const componentPath = path.join(__dirname, component);
if (fs.existsSync(componentPath)) {
console.log(`β
Admin component found: ${component}`);
} else {
console.error(`β Admin component missing: ${component}`);
allComponentsExist = false;
}
}
// Check for admin routes in App.jsx
const appPath = path.join(__dirname, 'src', 'App.jsx');
if (fs.existsSync(appPath)) {
const appContent = fs.readFileSync(appPath, 'utf8');
const requiredRoutes = [
'/admin/login',
'/admin/dashboard'
];
const requiredComponents = [
'AdminLogin',
'LocalAdminPanel',
'ProtectedRoute'
];
let allRoutesFound = true;
let allComponentsFound = true;
for (const route of requiredRoutes) {
if (appContent.includes(route)) {
console.log(`β
Admin route found: ${route}`);
} else {
console.error(`β Admin route missing: ${route}`);
allRoutesFound = false;
}
}
for (const component of requiredComponents) {
if (appContent.includes(component)) {
console.log(`β
Admin component reference found: ${component}`);
} else {
console.error(`β Admin component reference missing: ${component}`);
allComponentsFound = false;
}
}
if (appContent.includes('<AuthProvider>')) {
console.log('β
AuthProvider found in App.jsx');
} else {
console.error('β AuthProvider missing in App.jsx');
allComponentsExist = false;
}
} else {
console.error('β App.jsx not found');
allComponentsExist = false;
}
// Check for authentication context usage
const authContextPath = path.join(__dirname, 'src', 'contexts', 'AuthContext.jsx');
if (fs.existsSync(authContextPath)) {
const authContent = fs.readFileSync(authContextPath, 'utf8');
const requiredFunctions = [
'useAuth',
'AuthProvider',
'adminLogin',
'adminLogout'
];
for (const func of requiredFunctions) {
if (authContent.includes(func)) {
console.log(`β
Auth function found: ${func}`);
} else {
console.error(`β Auth function missing: ${func}`);
allComponentsExist = false;
}
}
} else {
console.error('β AuthContext.jsx not found');
allComponentsExist = false;
}
// Check for protected route implementation
const protectedRoutePath = path.join(__dirname, 'src', 'components', 'ProtectedRoute.jsx');
if (fs.existsSync(protectedRoutePath)) {
const protectedContent = fs.readFileSync(protectedRoutePath, 'utf8');
const requiredElements = [
'useAuth',
'Navigate',
'loading',
'admin'
];
for (const element of requiredElements) {
if (protectedContent.includes(element)) {
console.log(`β
ProtectedRoute element found: ${element}`);
} else {
console.error(`β ProtectedRoute element missing: ${element}`);
allComponentsExist = false;
}
}
} else {
console.error('β ProtectedRoute.jsx not found');
allComponentsExist = false;
}
// Summary
console.log('\n' + '='.repeat(60));
if (allComponentsExist) {
console.log('π All admin functionality components are properly configured!');
console.log('\nπ Admin Panel Features:');
console.log(' β
Secure login with authentication');
console.log(' β
Protected routes for dashboard');
console.log(' β
Order management system');
console.log(' β
Payment settings configuration');
console.log(' β
QR code upload functionality');
console.log(' β
CSV export for orders');
console.log(' β
Order status management');
console.log('\nπ Ready for deployment!');
} else {
console.log('β Some admin functionality components are missing or misconfigured.');
console.log(' Please check the errors above and ensure all components are present.');
}
console.log('='.repeat(60));