forked from AdeepaK2/quickshift-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-test-data.js
More file actions
252 lines (240 loc) · 7.92 KB
/
create-test-data.js
File metadata and controls
252 lines (240 loc) · 7.92 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
const mongoose = require('mongoose');
const bcrypt = require('bcrypt');
const User = require('./src/models/user');
const Employer = require('./src/models/employer');
const Admin = require('./src/models/admin');
// Connect to MongoDB
mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/quickshift', {
useNewUrlParser: true,
useUnifiedTopology: true,
});
async function createTestData() {
try {
console.log('Creating test data...');
// Create test users (students)
const testUsers = [
{
firstName: 'John',
lastName: 'Doe',
email: 'john.doe@student.com',
password: await bcrypt.hash('password123', 10),
role: 'job_seeker',
university: 'University of Technology',
faculty: 'Computer Science',
yearOfStudy: 3,
phone: '+1234567890',
isActive: true,
isVerified: true,
studentIdVerified: true,
gender: 'Male',
city: 'Colombo',
address: '123 Main St',
postalCode: '10001',
bio: 'Computer Science student with passion for web development',
gpa: 3.8,
},
{
firstName: 'Jane',
lastName: 'Smith',
email: 'jane.smith@student.com',
password: await bcrypt.hash('password123', 10),
role: 'job_seeker',
university: 'National University',
faculty: 'Engineering',
yearOfStudy: 2,
phone: '+1234567891',
isActive: true,
isVerified: true,
studentIdVerified: false,
gender: 'Female',
city: 'Kandy',
address: '456 Oak Ave',
postalCode: '20001',
bio: 'Engineering student interested in mechanical design',
gpa: 3.6,
},
{
firstName: 'Mike',
lastName: 'Johnson',
email: 'mike.johnson@student.com',
password: await bcrypt.hash('password123', 10),
role: 'job_seeker',
university: 'International University',
faculty: 'Business',
yearOfStudy: 4,
phone: '+1234567892',
isActive: true,
isVerified: false,
studentIdVerified: false,
gender: 'Male',
city: 'Galle',
address: '789 Pine St',
postalCode: '30001',
bio: 'Business student with focus on marketing',
gpa: 3.4,
},
{
firstName: 'Sarah',
lastName: 'Wilson',
email: 'sarah.wilson@student.com',
password: await bcrypt.hash('password123', 10),
role: 'job_seeker',
university: 'University of Technology',
faculty: 'Information Technology',
yearOfStudy: 1,
phone: '+1234567893',
isActive: false,
isVerified: true,
studentIdVerified: true,
gender: 'Female',
city: 'Colombo',
address: '321 Elm St',
postalCode: '10002',
bio: 'First-year IT student passionate about cybersecurity',
gpa: 3.9,
},
{
firstName: 'Alex',
lastName: 'Brown',
email: 'alex.brown@student.com',
password: await bcrypt.hash('password123', 10),
role: 'job_seeker',
university: 'State University',
faculty: 'Arts',
yearOfStudy: 3,
phone: '+1234567894',
isActive: true,
isVerified: true,
studentIdVerified: true,
gender: 'Non-binary',
city: 'Jaffna',
address: '654 Maple Dr',
postalCode: '40001',
bio: 'Arts student with focus on graphic design',
gpa: 3.7,
},
];
// Create test employers
const testEmployers = [
{
companyName: 'Tech Solutions Inc.',
email: 'hr@techsolutions.com',
password: await bcrypt.hash('password123', 10),
contactPersonName: 'Robert Manager',
phone: '+1234567800',
location: 'Colombo',
companyDescription: 'Leading technology company specializing in web development and software solutions',
isActive: true,
isVerified: true,
industryType: 'Technology',
companySize: '50-100',
website: 'https://techsolutions.com',
ratings: {
averageRating: 4.5,
totalReviews: 12,
},
},
{
companyName: 'Marketing Masters',
email: 'contact@marketingmasters.com',
password: await bcrypt.hash('password123', 10),
contactPersonName: 'Lisa Director',
phone: '+1234567801',
location: 'Kandy',
companyDescription: 'Creative marketing agency helping businesses grow their online presence',
isActive: true,
isVerified: false,
industryType: 'Marketing',
companySize: '10-50',
website: 'https://marketingmasters.com',
ratings: {
averageRating: 4.2,
totalReviews: 8,
},
},
{
companyName: 'Design Studio Pro',
email: 'info@designstudiopro.com',
password: await bcrypt.hash('password123', 10),
contactPersonName: 'David Creative',
phone: '+1234567802',
location: 'Galle',
companyDescription: 'Professional design studio offering branding and UI/UX services',
isActive: true,
isVerified: true,
industryType: 'Design',
companySize: '10-50',
website: 'https://designstudiopro.com',
ratings: {
averageRating: 4.8,
totalReviews: 15,
},
},
{
companyName: 'Global Logistics',
email: 'jobs@globallogistics.com',
password: await bcrypt.hash('password123', 10),
contactPersonName: 'Emma Operations',
phone: '+1234567803',
location: 'Colombo',
companyDescription: 'International logistics company providing supply chain solutions',
isActive: false,
isVerified: true,
industryType: 'Logistics',
companySize: '100+',
website: 'https://globallogistics.com',
ratings: {
averageRating: 3.9,
totalReviews: 6,
},
},
{
companyName: 'FinTech Innovations',
email: 'careers@fintechinnovations.com',
password: await bcrypt.hash('password123', 10),
contactPersonName: 'James CEO',
phone: '+1234567804',
location: 'Colombo',
companyDescription: 'Innovative financial technology company developing mobile payment solutions',
isActive: true,
isVerified: true,
industryType: 'Finance',
companySize: '50-100',
website: 'https://fintechinnovations.com',
ratings: {
averageRating: 4.6,
totalReviews: 20,
},
},
];
// Clear existing data
console.log('Clearing existing test data...');
await User.deleteMany({ email: { $regex: '@student.com$' } });
await Employer.deleteMany({ email: { $regex: '@(techsolutions|marketingmasters|designstudiopro|globallogistics|fintechinnovations).com$' } });
// Insert test users
console.log('Creating test users...');
const createdUsers = await User.insertMany(testUsers);
console.log(`Created ${createdUsers.length} test users`);
// Insert test employers
console.log('Creating test employers...');
const createdEmployers = await Employer.insertMany(testEmployers);
console.log(`Created ${createdEmployers.length} test employers`);
// Display summary
console.log('\n=== TEST DATA SUMMARY ===');
console.log('Users created:');
createdUsers.forEach(user => {
console.log(`- ${user.firstName} ${user.lastName} (${user.email}) - ${user.university}`);
});
console.log('\nEmployers created:');
createdEmployers.forEach(employer => {
console.log(`- ${employer.companyName} (${employer.email}) - ${employer.location}`);
});
console.log('\nTest data created successfully!');
console.log('You can now test the admin dashboard with this data.');
} catch (error) {
console.error('Error creating test data:', error);
} finally {
mongoose.disconnect();
}
}
createTestData();