-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
2065 lines (1672 loc) · 64.2 KB
/
test.js
File metadata and controls
2065 lines (1672 loc) · 64.2 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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const lawyer = require('./tests/lawyerFunctions');
const reviewer = require('./tests/reviewerFunctions');
const adminFunctions = require('./tests/adminFunctions')
const investorFunctions = require('./tests/investorFunctions')
const userFunctions = require('./tests/userFunctions')
//const Lawyer = require('./app/models/Lawyer')
const Reviewer = require('./app/models/Reviewer')
//jest.setTimeout(30000)
const axios = require('axios')
/*
Tests for payment
1) first test valid card
2) second test for expired/not valid card
3) third paying for non pending company
////////////////////////PAYING__FEES///////////////////////////////////
*/
test(`paying fees for a company with valid card`, async () => {
const myCase = await axios.post("http://localhost:3000/api/cases", {
form_type: "SSCP",
regulated_law: "44",
arabic_name: "تتتت",
english_name: "Hello6",
government: "ENG",
city: "Cairo",
hq_address: "gftfy",
hq_city: "yes",
main_center_phone: 123515,
main_center_fax: 518563,
currency: "541",
equality_capital: 5054641641562,
caseStatus: "pending",
investorID: "5ca772654d70710fa843bd5f",
managers: [],
});
const charge = await investorFunctions.InvestorPayFees('4242424242424242',12,19,121,myCase.data.data._id);
expect(charge.data.message).toEqual(
"your payment has been made; you will receive an invoice via your mail"
);
});
test(`paying fees for a company with expired card`, async () => {
const charge = await investorFunctions.InvestorPayFees(
4242424242424242,
1,
19,
121,
myCase.data.data._id
);
console.log(charge)
// console.log('myCharge')
// console.log(charge)
expect(charge.data.message).toEqual("card declined");
});
test(`paying fees for a company that is not pending`, async () => {
const myCase = await axios.post("http://localhost:3000/api/cases", {
form_type: "SSCP",
regulated_law: "44",
arabic_name: "تتتت",
english_name: "Hello6",
government: "ENG",
city: "Cairo",
hq_address: "gftfy",
hq_city: "yes",
main_center_phone: 123515,
main_center_fax: 518563,
currency: "541",
equality_capital: 5054641641562,
managers: [],
__v: 0,
caseStatus: "published",
investorID: "5ca772654d70710fa843bd5f",
log: []
});
// console.log(myCase)
const charge = await investorFunctions.InvestorPayFees(
4242424242424242,
1,
19,
121,
myCase.data.data._id
);
//console.log(charge)
expect(charge.data.message).toEqual("company is not ready for payment");
});
test('investor fill form', async () => {
const msg = await investorFunctions.investorFillForm()
expect(msg.data.msg).toEqual('The form was created successfully');
});
test('investor update form', async () => {
const msg = await investorFunctions.investorUpdateForm('5c9501b04f707b3968c9275e')
expect(msg.data.msg).toEqual('Form updated successfully');
});
test('investor view comment', async () => {
const com = await investorFunctions.investorViewComment()
expect(com.data).toEqual({});
});
test('investor view profile', async () => {
const prof= await investorFunctions.investorViewProfile()
expect(prof.data.msg).toEqual('Done');
});
test('lawyer update form', async () => {
const msg = await lawyer.lawyerUpdateForm('5c950069f2380140941b74f0')
expect(msg.data.msg).toEqual('Form updated successfully');
});
test('lawyer fill form', async () => {
const msg = await lawyer.lawyerFillForm()
expect(msg.data.msg).toEqual('The form was created successfully');
});
test('lawyer view comment', async () => {
const comment = await lawyer.lawyerViewComment()
expect(comment.data).toEqual({});
});
test('lawyer view reviewerLeaderBoard', async () => {
const msg = await lawyer.lawyerViewReviewersLeaderBoard()
expect(msg.data.msg).toEqual('Done');
});
test('lawyer view lawyerLeaderBoard', async () => {
const msg = await lawyer.lawyerViewLawyersLeaderBoard()
expect(msg.data.msg).toEqual('Done');
});
test('admin view comment', async () => {
const com = await adminFunctions.adminViewComment()
expect(com.data).toEqual({});
});
// test('Reviewer view lawyersLeaderBoard', async () => {
// const msg = await reviewer.reviewerViewLawyersLeaderBoard()
// expect(msg.data.msg).toEqual('Done');
// });
test('Reviewer view reviewersLeaderBoard', async () => {
const msg = await reviewer.reviewerViewReviewersLeaderBoard()
expect(msg.data.msg).toEqual('Done');
});
test(`case disaproves at reviewer and casestatus should be lawyer`, async () => {
const CASE = await reviewer.caseDisAproveedAtReviewer('5c9512ba8aba002578c01ad6')
expect(CASE.data.data.caseStatus).toEqual('pending')
});
test(`case aproved at reviewer and casestatus should be pending`, async () => {
const CASE = await reviewer.caseAproveedAtReviewer('5c9512ba8aba002578c01ad6')
expect(CASE.data.data.caseStatus).toEqual('lawyer-reviewer')
});
//Hemaya before tests
test('Forgot password with valid mail', async () => {
jest.setTimeout(10000)
const t1 = await axios({
method: 'post',
url:'http://127.0.0.1:3000/api/admin',
headers: {},
data: {
"FName": "FoFu",
"MName": "Ramremo",
"LName": "Gamd",
"email": "modyjack71@gmail.com",
"password": "cnjdqqcrjcsjn151215'",
"gender": "Male",
"Nationality": "Egyptian",
"birthdate": "1980",
"Address": "11 makram",
"fax": "125252",
"telephone_number": "151515",
"total_number_of_cases": "588",
"completed_number_of_cases": "561",
"number_of_cases": "2",
"total_time_on_cases": "25",
"ssid": "15552"
}
});
const msg = await adminFunctions.MailForgotPassword(t1.data.data.email)
await axios.delete('http://127.0.0.1:3000/api/admin/'+t1.data.data._id)
expect(msg.data.message).toEqual('An email has been sent check your email');
});
////////////////////////PAYING__FEES//////////////////////////
/*
Admin Edit Company
not a company
successfully edit company
*/
test(`Editing company that does not exist`, async () => {
const company = await adminFunctions.AdminEditCompany('5c9502b9d2e00c0bc7a')
expect(company.data.message).toEqual('This id is not a valid company.')
});
test(`Editing company successfully that does not exist`, async () => {
const myCase = await axios.post("http://localhost:3000/api/cases", {
form_type: "SSCP",
regulated_law: "44",
arabic_name: "تتتت",
english_name: "Hello6",
government: "ENG",
city: "Cairo",
hq_address: "gftfy",
hq_city: "yes",
main_center_phone: 123515,
main_center_fax: 518563,
currency: "541",
equality_capital: 5054641641562,
managers: [],
__v: 0,
caseStatus: "published",
investorID: "5ca772654d70710fa843bd5f",
log: []
});
const company = await adminFunctions.AdminEditCompany(myCase.data.data._id)
expect(company.data.message).toEqual('you have updated the Company details successfully')
});
/*
Admin Edit lawyer
edit lawyer success
edit lawyer fail
*/
test(`Admin delete lawyer`, async () => {
const lawyer = await axios.post("http://localhost:3000/api/lawyer", {
FName: "Romba",
MName: "Ramremo",
LName: "Gamd",
email: "new_emaill@gmail.com",
password: "cnjdqqcrjcsjn151215'",
gender: "Male",
Nationality: "Egyptian",
birthdate: "1980",
Address: "11 makram",
fax: "125252",
telephone_number: "151515",
total_number_of_cases: "588",
completed_number_of_cases: "561",
number_of_cases: "2",
total_time_on_cases: "25",
ssid: "15552"
});
const result = await adminFunctions.AdminDeleteLawyer(lawyer.data.data._id)
expect(result.data.message).toEqual('lawyer deleted successfully')
});
test(`Admin delete lawyer that does not exist`, async () => {
const lawyer = await adminFunctions.AdminDeleteLawyer('5ca772654d70710fa843bd5f')
expect(lawyer.data.message).toEqual('there is not lawyer by this id to remove')
});
test('Delete a company that does not exist ', async()=>{
const id = await adminFunctions.AdminDeleteCase('5caef099d46a97776c2fbf54')
expect(id.data.message).toEqual('not a case')
});
/*
Admin Edit reviewer
edit reviewer success
edit reviewer fail
*/
test(`Admin delete reviewer`, async () => {
const reviewer = await axios.post("http://localhost:3000/api/reviewer", {
FName: "Romba",
MName: "Ramremo",
LName: "Gamd",
email: "new_emaill@gmail.com",
password: "cnjdqqcrjcsjn151215'",
gender: "Male",
Nationality: "Egyptian",
birthdate: "1980",
Address: "11 makram",
fax: "125252",
telephone_number: "151515",
total_number_of_cases: "588",
completed_number_of_cases: "561",
number_of_cases: "2",
total_time_on_cases: "25",
ssid: "15552"
})
const result = await adminFunctions.AdminDeleteReviewer(reviewer.data.data._id)
expect(result.data.message).toEqual('Reviewer deleted successfully')
});
test(`Admin delete reviewer that does not exist`, async () => {
const result = await adminFunctions.AdminDeleteReviewer('5ca772654d70710fa843bd5f')
expect(result.data.message).toEqual('there is not Reviewer by this id to remove')
});
// test('Delete a company ', async()=>{
// const id = await adminFunctions.AdminDeleteCase('5c94e18af1ef0f3e48b0a2b8')
// console.log('yeeh')
// expect(id.data.message).toEqual('Case was deleted successfully')
// });
test('Delete a Question that does not exist ', async()=>{
const id = await adminFunctions.AdminDeleteQuestion('5caed099e96f7300e0148c45')
console.log('notQUessss')
expect(id.data.message).toEqual('not a ques')
});
// test('Delete a Question ', async()=>{
// const id = await adminFunctions.AdminDeleteQuestion('5c77f15454746a2ec800e532')
// console.log('Quessss')
// expect(id.data.message).toEqual('This question was deleted successfully')
// });
test('view as admin Investor', async()=>{
const id = await adminFunctions.AdminViewing('5ca772654d70710fa843bd5f')
console.log('view')
expect(id.data.message).toEqual('investor')
});
test('view as admin Lawyer', async()=>{
const id = await adminFunctions.AdminViewing('5ca0a85f309f411aa851bdfd')
console.log('view')
expect(id.data.message).toEqual('lawyer')
});
test('view as admin Reviewer', async()=>{
const id = await adminFunctions.AdminViewing('5caa2255a17f105039d06af6')
console.log('view')
expect(id.data.message).toEqual('Rev')
});
test('Forgot password with invalid mail', async () => {
const msg = await adminFunctions.MailForgotPassword('Wrong_mail@gmail.com')
expect(msg.data.message).toEqual('incorrect email');
});
test('Reset password with expired token', async () => {
const msg = await adminFunctions.MailResetPassword('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJGTmFtZSI6IkZhZHkiLCJpYXQiOjE1NTQwNjU1MjMsImV4cCI6MTU1NDA2OTEyM30.ByMt8yx_wNQGwhxH00LD_2xAjJpzkS7SlaX3rOUB2nE','Fady2512')
expect(msg).toEqual('Token is expired please try again');
});
test('Reset password with valid token', async () => {
const t1 = await axios({
method: 'post',
url:'http://127.0.0.1:3000/api/admin',
headers: {},
data: {
"FName": "Romba",
"MName": "Ramremo",
"LName": "Gamd",
"email": "charbil.wasfalla@gmail.com",
"password": "cnjdqqcrjcsjn151215'",
"gender": "Male",
"Nationality": "Egyptian",
"birthdate": "1980",
"Address": "11 makram",
"fax": "125252",
"telephone_number": "151515",
"total_number_of_cases": "588",
"completed_number_of_cases": "561",
"number_of_cases": "2",
"total_time_on_cases": "25",
"ssid": "15552"
}})
const x = await adminFunctions.MailForgotPassword(t1.data.data.email)
console.log(x.data.data , 'OOOOOOOOOOOne',t1.data.data._id)
const tok = await axios.get('http://127.0.0.1:3000/api/admin/'+t1.data.data._id)
console.log('TWo', tok.data.data )
console.log('Three',t1.data.data.token)
const msg = await adminFunctions.MailResetPassword(tok.data.data.token,'Fady22551122')
await axios.delete('http://127.0.0.1:3000/api/admin/'+t1.data.data._id)
expect(msg).toEqual('Password reseted succesfully');
});
test('view as admin Admin', async()=>{
const id = await adminFunctions.AdminViewing('5c9bb0dc5185793518ea84fb')
console.log('view')
expect(id.data.message).toEqual('Admin')
});
test('view as admin neither', async()=>{
const id = await adminFunctions.AdminViewing('5c77f15454789a2ec800e532')
console.log('view')
expect(id.data.message).toEqual('User does not exist')
});
test('view as Admin a published Company', async()=>{
const id = await adminFunctions.AdminViewingCompany('5c9517bdf65058663c3010d3')
console.log('view')
expect(id.data.message).toEqual('case')
});
test('view as Admin an unpublished Company', async()=>{
const id = await adminFunctions.AdminViewingCompany('5c950069f2380140941b74f0')
console.log('view')
expect(id.data.message).toEqual('Case was not published')
});
test('View list of all published companies', async () => {
const msg = await adminFunctions.AdminViewingPublishedCompanies()
expect(msg.data.message).toEqual('Cases');
});
//----------------------------------------------
test('view as Investor a published Company', async()=>{
const id = await investorFunctions.InvestorViewingCompany('5c9517bdf65058663c3010d3')
console.log('view')
expect(id.data.message).toEqual('case')
});
test('view as Investor an unpublished Company', async()=>{
const id = await investorFunctions.InvestorViewingCompany('5c950069f2380140941b74f0')
console.log('view')
expect(id.data.message).toEqual('Case was not published')
});
test('view as Investor Investor', async()=>{
const id = await investorFunctions.InvestorViewing('5ca772654d70710fa843bd5f')
console.log('view')
expect(id.data.message).toEqual('investor')
});
test('view as Investor Lawyer', async()=>{
const id = await investorFunctions.InvestorViewing('5ca0a85f309f411aa851bdfd')
console.log('view')
expect(id.data.message).toEqual('lawyer')
});
test('view as Investor Reviewer', async()=>{
const id = await investorFunctions.InvestorViewing('5caa2255a17f105039d06af6')
console.log('view')
expect(id.data.message).toEqual('Rev')
});
test('view as Investor Admin', async()=>{
const id = await investorFunctions.InvestorViewing('5c9bb0dc5185793518ea84fb')
console.log('view')
expect(id.data.message).toEqual('Admin')
});
test('view as Investor neither', async()=>{
const id = await investorFunctions.InvestorViewing('5c77f15454789a2ec800e532')
console.log('view')
expect(id.data.message).toEqual('User does not exist')
});
test('View list of all published companies', async () => {
const msg = await investorFunctions.InvestorViewingPublishedCompanies()
expect(msg.data.message).toEqual('Cases');
});
//----------------------------------------------
test('view as Reviewer Investor', async()=>{
const id = await reviewer.ReviewerViewing('5ca772654d70710fa843bd5f')
console.log('view')
expect(id.data.message).toEqual('investor')
});
test('view as Reviewer Lawyer', async()=>{
const id = await reviewer.ReviewerViewing('5ca0a85f309f411aa851bdfd')
console.log('view')
expect(id.data.message).toEqual('lawyer')
});
test('view as Reviewer Reviewer', async()=>{
const id = await reviewer.ReviewerViewing('5caa2255a17f105039d06af6')
console.log('view')
expect(id.data.message).toEqual('Rev')
});
test('view as Reviewer Admin', async()=>{
const id = await reviewer.ReviewerViewing('5c9bb0dc5185793518ea84fb')
console.log('view')
expect(id.data.message).toEqual('Admin')
});
test('view as Reviewer neither', async()=>{
const id = await reviewer.ReviewerViewing('5c77f15454789a2ec800e532')
console.log('view')
expect(id.data.message).toEqual('User does not exist')
});
test('view as Reviewer a published Company', async()=>{
const id = await reviewer.ReviewerViewingCompany('5c9517bdf65058663c3010d3')
console.log('view')
expect(id.data.message).toEqual('case')
});
test('view as Reviewer an unpublished Company', async()=>{
const id = await reviewer.ReviewerViewingCompany('5c950069f2380140941b74f0')
console.log('view')
expect(id.data.message).toEqual('Case was not published')
});
test('View list of all published companies', async () => {
const msg = await reviewer.ReviewerViewingPublishedCompanies()
expect(msg.data.message).toEqual('Cases');
});
//----------------------------------------------
// test('view as unregister Investor', async()=>{
// const id = await userFunctions.UnregisterViewing('5ca772654d70710fa843bd5f')
// console.log('view')
// expect(id.data.message).toEqual('investor')
// });
// test('view as unreg Lawyer', async()=>{
// const id = await userFunctions.UnregisterViewing('5ca0a85f309f411aa851bdfd')
// console.log('view')
// expect(id.data.message).toEqual('lawyer')
// });
// test('view as unreg Reviewer', async()=>{
// const id = await userFunctions.UnregisterViewing('5caa2255a17f105039d06af6')
// console.log('view')
// expect(id.data.message).toEqual('Rev')
// });
// test('view as unreg Admin', async()=>{
// const id = await userFunctions.UnregisterViewing('5c9bb0dc5185793518ea84fb')
// console.log('view')
// expect(id.data.message).toEqual('Admin')
// });
// test('view as unreg neither', async()=>{
// const id = await userFunctions.UnregisterViewing('5c77f15454789a2ec800e532')
// console.log('view')
// expect(id.data.message).toEqual('User does not exist')
// });
test('view as Unregistered user a published Company', async()=>{
const id = await userFunctions.UnregisterViewingCompany('5c9517bdf65058663c3010d3')
console.log('view')
expect(id.data.message).toEqual('case')
});
test('view as Unregistered user an unpublished Company', async()=>{
const id = await userFunctions.UnregisterViewingCompany('5c950069f2380140941b74f0')
console.log('view')
expect(id.data.message).toEqual('Case was not published')
});
test('View list of all published companies', async () => {
const msg = await userFunctions.UnregisterViewingPublishedCompanies()
expect(msg.data.message).toEqual('Cases');
});
//----------------------------------------------
test('view as Lawyer Investor', async()=>{
const id = await lawyer.LawyerViewing('5ca772654d70710fa843bd5f')
console.log('view')
expect(id.data.message).toEqual('investor')
});
test('view as Lawyer Lawyer', async()=>{
const id = await lawyer.LawyerViewing('5ca0a85f309f411aa851bdfd')
console.log('view')
expect(id.data.message).toEqual('lawyer')
});
test('view as Lawyer Reviewer', async()=>{
const id = await lawyer.LawyerViewing('5caa2255a17f105039d06af6')
console.log('view')
expect(id.data.message).toEqual('Rev')
});
test('view as Lawyer Admin', async()=>{
const id = await lawyer.LawyerViewing('5c9bb0dc5185793518ea84fb')
console.log('view')
expect(id.data.message).toEqual('Admin')
});
test('view as Lawyer neither', async()=>{
const id = await lawyer.LawyerViewing('5c77f15454789a2ec800e532')
console.log('view')
expect(id.data.message).toEqual('User does not exist')
});
test('view as lawyer a published Company', async()=>{
const id = await lawyer.LawyerViewingCompany('5c9517bdf65058663c3010d3')
console.log('view')
expect(id.data.message).toEqual('case')
});
test('view as lawyer an unpublished Company', async()=>{
const id = await lawyer.LawyerViewingCompany('5c950069f2380140941b74f0')
console.log('view')
expect(id.data.message).toEqual('Case was not published')
});
test('View list of all published companies', async () => {
const msg = await lawyer.LawyerViewingPublishedCompanies()
expect(msg.data.message).toEqual('Cases');
});
/*
test ('Editing lawEntity to Malak', async () => {
let law = await adminFunctions.adminChangePricingStrategy('5c9e4b6c4edad508b45adac6')
expect(law.data.msg).toEqual('Laws updated successfully')
})
/////// //////// //////////
test(`case disaproves at lawyer and casestatus should be investor`, async () => {
const CASE = await lawyer.caseDisAproveedAtLawyer('5c95121386ba314a882d8d7f')
expect(CASE.data.data.caseStatus).toEqual('investor')
});
//small problem
// test(`case aproved at lawyer and casestatus should be reviewer`, async () => {
// const CASE = await lawyer.caseAproveedAtLawyer('5c9512ba8aba002578c01ad6')
// expect(CASE.data.data.caseStatus).toEqual('reviewer')
// });
//==========================MONICA==========================
//TESTING CHECK FORM
test('successful form' , async() => {
const newInvestor = await axios({
method:'post',
url: 'http://localhost:3000/api/Investor',
headers:{},
data:{
"FirstName": "gegegegeg",
"MiddleName":"gogggggg",
"LastName":"fay",
"email": "hehehhehe.achrwwwf@gma.com",
"ID_type":"regular",
"SSID" :"930240219012394",
"Nationality":"egy",
"gender":"female",
"Type":"pass",
"Address":"3489ihkbnke",
"telephone_number":"894094820"
}
})
const idI = newInvestor.data.data._id
console.log(idI)
const newC = await axios({
method:'post',
url: 'http://localhost:3000/api/Cases',
headers:{},
data:{
"form_type": "SPC",
"regulated_law": "44",
"arabic_name": "ققتت",
"english_name": "Hooo",
"government": "ENG",
"city": "Cairo",
"hq_address": "gftfy",
"hq_city": "yes",
"main_center_phone": 123,
"main_center_fax": 518563,
"currency": "541",
"equality_capital": 150000,
"managers": [],
"caseStatus": "published",
"investorID": idI,
"log": []
}
})
const cr1 = newC.data.data._id
console.log(cr1)
expect(newC.data.msg).toEqual('Case was created successfully')
console.log('done testc')
});
test('lawyer views all cases', async () => {
const CASE = await lawyer.viewCasesLawyer( )
expect(CASE.data.msg).toEqual('Done');
//console.log(newC)
});
test('Reviewer views all cases', async () => {
const CASE = await reviewer.viewCasesReviewer( )
expect(CASE.data.msg).toEqual('Done');
});
/////////////////// /////// //////// ////////// /////// //////// //////////
})
*/
// //Admin tests
// test('lawyer fill form', async () => {
// const msg = await Lawyer.lawyerFillForm()
// expect(msg.data.msg).toEqual('The form was created successfully');
// });
//either this test works or the previous two work
//they are contradicting due hardcoding admin id in my function which is not of type super
//test ('Non-superAdmin tries to change law', async () => {
//let law= await adminFunctions.adminChangePricingStrategy('5c9e4b6c4edad508b45adac6')
//expect(law.data.data.message).toEqual('Only super admins have access')
//})
// test ('Creating a new Law', async () =>{
// jest.setTimeout(30000)
// let law= await adminFunctions.adminCreateNewLaw()
// expect(law.data.msg).toEqual('Law was created successfully')
// })
// test ('Creating a new Law', async () =>{
// let law= await adminFunctions.adminCreateNewLaw()
// expect(law.data.msg).toEqual('Law was created successfully')
// })
//either this test works or the previous one work
//they are contradicting due hardcoding admin id in my function which is not of type super
//test ('Non-superAdmin create new law', async() =>{
//let law= await adminFunctions.adminCreateNewLaw()
//expect(law.data.msg).toEqual('Only super admins have access')
//})
// test(`Case assigned to lawyer successfully`, async() =>{
// const cases = await adminFunctions.AdminAssignLawyer()
// console.log(cases)
// expect(cases.data.lawyerID).toBe('5c9e4dc353415c34a0f35cd1')
// })
// test('Admin assign lawyer' ,async() => {
// const msg = await adminFunctions.AdminAssignLawyer('5c93e4ae5b66b31668f0e28c','5c9e4dc353415c34a0f35cd1')
// expect(msg).toEqual('Case updated successfully')
// },
//testing for checkForms
test('unsuccessful form' , async() => {
const newInvestor = await axios({
method:'post',
url: 'http://localhost:3000/api/Investor',
headers:{},
data:{
"FirstName": "gegegege",
"MiddleName":"gogoloulo",
"LastName":"fay",
"email": "hehehee.achwwf@gma.com",
"ID_type":"regular",
"SSID" :"930240219012394",
"Nationality":"french",
"gender":"female",
"Type":"pass",
"Address":"3489ihkbnke",
"telephone_number":"894094820"
}
})
const idI = newInvestor.data.data._id
console.log(idI)
const newC = await axios({
method:'post',
url: 'http://localhost:3000/api/Cases',
headers:{},
data:{
"form_type": "SPC",
"regulated_law": "44",
"arabic_name": "قتخججت",
"english_name": "KKKoo",
"government": "ENG",
"city": "Cairo",
"hq_address": "gftfy",
"hq_city": "yes",
"main_center_phone": 1236,
"main_center_fax": 518563,
"currency": "541",
"equality_capital": 150000,
"managers": [],
"caseStatus": "published",
"investorID": idI,
"managers": [
{
"_id": "5cad6203dc92d028730630fe",
"name": "Paul"
}
],
"log": []
}
})
const cr1 = newC.data.data._id
console.log(cr1)
//console.log(newC)
expect(newC.data.msg).toEqual('Could not create case')
console.log('done testc')
const delInvestor = await axios({
method:'delete',
url: 'http://localhost:3000/api/Investor/'+ idI,
})
})
//testing sending attachement
test(`send attachment with a valid mail`, async () => {
const newInvestor = await axios({
method:'post',
url: 'http://localhost:3000/api/Investor',
headers:{},
data:{
"FirstName": "shouuu",
"MiddleName":"moumou",
"LastName":"fayez",
"email": "moumou@gmail.com",
"ID_type":"regular",
"SSID" :"930240219012394",
"Nationality":"Egyptian",
"gender":"female",
"Type":"pass",
"Address":"3489ihkbnknwe",
"telephone_number":"89409820"
}
})
console.log(newInvestor.data.data.email)
const msg = await adminFunctions.SendAttachmentMail(newInvestor.data.data.email)
expect(msg).toEqual('Please check your email')
const delReviewer = await axios({
method:'delete',
url: 'http://localhost:3000/api/Investor/'+ newInvestor.data.data._id,
})
});
//testing sending attachement
test(`send attachment with an invalid mail`, async () => {
const email = 'wrong_mail@gmail.com'
const msg = await adminFunctions.SendAttachmentMail(email)
expect(msg).toEqual('Incorrect Mail')
});
//====================Hemaya tests===========================================================
test(`View Board of directors`, async () => {
const board = await userFunctions.UnregisterViewDirectorsID()
expect(board.data.data.managers[0].name).toEqual("Fady")
}),
//Investor tests
// test(`paying fees for a company with valid card`, async () => {
// const charge = await investorFunctions.InvestorPayFees(4242424242424242,12,19,121)
// expect(charge.data.message).toEqual('your payment has been made; you will receive an invoice via your mail.')
// });
// test(`paying fees for a company with expired card`, async () => {
// const charge = await investorFunctions.InvestorPayFees(4242424242424242,1,19,121)
// //console.log(charge)
// expect(charge.data.message).toEqual
// ('card declined' )
// });
// test('Investor view his fees', async () => {
// const Case= await investorFunctions.InvestorViewFees('5c9512ba8aba002578c01ad6')
// expect(Case.data.msg).toEqual('This is your fees')
// })
// test('Investor view his fees giving a wrong id', async () => {
// const Case= await investorFunctions.InvestorViewFees('5c9512ba8aba002578c01a')
// expect(Case.data.msg).toEqual('Cannot find company')
// })
// test ('View notification of an investor with an invalid ID', async () => {
// var validInvestorID = "x"
// //expect.assertions(1)
// try {
// const response = await Investor.investorMyNotifications(validInvestorID)
// } catch (e) {
// // console.log(e.response.data)
// expect(e.response.data.error).toMatch('Error processing query.');
// }
// })
// test ('View pending companies of an investor', async () => {
// var validInvestorID = "5c7a9b46470a360ac8b0d412"
// //expect.assegit push --set-upstream origin Lawyertions(1)
// const response = await investorFunctions.viewMyPendingCompanies(validInvestorID)
// //console.log(response)
// expect(response.data.msg).toEqual('Done')
// })
// test ('View pending companies of an investor with an invalid ID', async () => {
// var validInvestorID = "x"
// //expect.assertions(1)
// try {
// const response = await investorFunctions.viewMyPendingCompanies(validInvestorID)
// } catch (e) {
// //console.log(e.response.data)
// expect(e.response.data.error).toMatch('Error processing query.');
// }
// })
test(`Unregister view questions`, async () => {
// adding question to database --before all--
const newQuestion = await axios({
method: 'post',
url: 'http://localhost:3000/api/Questions',
headers: {},
data:
{
"senderID":"5c93ac9555b21722fc46eb9b",
"AdminID": "5c9bb1e18308bb316ce15a70",
"question" :"what is GAFI?",
"answer" :"Yes",
"time" :"2019"
}});
const ques = await userFunctions.UnregisterViewQuestions()
found = false
for (let i = 0; i < ques.data.data.length; i += 1) {
if (ques.data.data[i].question ==="what is GAFI?") {
found = true
}
}
//Deleting the added question -- after all--
await axios({
method: 'delete',
url: 'http://localhost:3000/api/Questions/'+newQuestion.data.data._id,
headers: {},
data:
{
}});
expect(found).toEqual(true)
});