Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Paysafe Interns Valentin-Kaloyan
Student Managment
kaloyan-bojilski-student-management-2023
Commits
311d8a13
Commit
311d8a13
authored
1 year ago
by
Kaloyan Bojilski
Browse files
Options
Download
Email Patches
Plain Diff
unit test
parent
2e002af0
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
StudentManagementFrontend/cypress/e2e/change-student-to-teacher-and-add-to-course.cy.ts
+4
-4
...ess/e2e/change-student-to-teacher-and-add-to-course.cy.ts
StudentManagementFrontend/cypress/e2e/choose-course-add-grade-to-student.cy.ts
+3
-3
...tend/cypress/e2e/choose-course-add-grade-to-student.cy.ts
StudentManagementFrontend/cypress/e2e/choose-course-remove-teacher.cy.ts
+3
-3
...ntFrontend/cypress/e2e/choose-course-remove-teacher.cy.ts
StudentManagementFrontend/cypress/e2e/create-course-add-teacher-and-students.cy.ts
+7
-7
.../cypress/e2e/create-course-add-teacher-and-students.cy.ts
StudentManagementFrontend/cypress/e2e/login.cy.ts
+5
-5
StudentManagementFrontend/cypress/e2e/login.cy.ts
StudentManagementFrontend/cypress/e2e/method-util.ts
+1
-3
StudentManagementFrontend/cypress/e2e/method-util.ts
StudentManagementFrontend/src/app/components/course-page/course-page.component.spec.ts
+1
-5
.../app/components/course-page/course-page.component.spec.ts
StudentManagementFrontend/src/app/components/login-form/login-form.component.spec.ts
+36
-2
...rc/app/components/login-form/login-form.component.spec.ts
StudentManagementFrontend/src/app/services/course.service.spec.ts
+2
-3
...anagementFrontend/src/app/services/course.service.spec.ts
with
62 additions
and
35 deletions
+62
-35
StudentManagementFrontend/cypress/e2e/change-student-to-teacher-and-add-to-course.cy.ts
+
4
-
4
View file @
311d8a13
import
{
Util
}
from
"
./util
"
;
import
{
Method
Util
}
from
"
./
method-
util
"
;
describe
(
'
change role
'
,
()
=>
{
it
(
'
change student role to teacher and add to course
'
,
()
=>
{
Util
.
loginSuccess
(
'
Admin
'
,
'
user
'
,
'
12345678
'
,
cy
);
Util
.
changeStudentRoleToTeacher
(
'
user
'
,
'
hgf
'
,
"
Gosho
"
,
"
PHD
"
,
cy
);
Util
.
addTeacherToCourse
(
'
courz
'
,
'
hgf
'
,
cy
);
Method
Util
.
loginSuccess
(
'
Admin
'
,
'
user
'
,
'
12345678
'
,
cy
);
Method
Util
.
changeStudentRoleToTeacher
(
'
user
'
,
'
hgf
'
,
"
Gosho
"
,
"
PHD
"
,
cy
);
Method
Util
.
addTeacherToCourse
(
'
courz
'
,
'
hgf
'
,
cy
);
})
})
This diff is collapsed.
Click to expand it.
StudentManagementFrontend/cypress/e2e/choose-course-add-grade-to-student.cy.ts
+
3
-
3
View file @
311d8a13
import
{
Util
}
from
"
./util
"
;
import
{
Method
Util
}
from
"
./
method-
util
"
;
describe
(
'
choose course
'
,
()
=>
{
it
(
'
choose course and add a grade to student
'
,
()
=>
{
Util
.
loginSuccess
(
'
Admin
'
,
'
user
'
,
'
12345678
'
,
cy
);
Util
.
addGradeToStudentForCourse
(
'
Rizzlogy
'
,
'
coolname
'
,
5.5
,
cy
);
Method
Util
.
loginSuccess
(
'
Admin
'
,
'
user
'
,
'
12345678
'
,
cy
);
Method
Util
.
addGradeToStudentForCourse
(
'
Rizzlogy
'
,
'
coolname
'
,
5.5
,
cy
);
})
})
This diff is collapsed.
Click to expand it.
StudentManagementFrontend/cypress/e2e/choose-course-remove-teacher.cy.ts
+
3
-
3
View file @
311d8a13
import
{
Util
}
from
"
./util
"
;
import
{
Method
Util
}
from
"
./
method-
util
"
;
describe
(
'
choose course
'
,
()
=>
{
it
(
'
choose course and delete teacher and delete grades
'
,
()
=>
{
Util
.
loginSuccess
(
'
Admin
'
,
'
user
'
,
'
12345678
'
,
cy
);
Util
.
deleteTeacherFromCourse
(
'
courz
'
,
cy
);
Method
Util
.
loginSuccess
(
'
Admin
'
,
'
user
'
,
'
12345678
'
,
cy
);
Method
Util
.
deleteTeacherFromCourse
(
'
Geography
'
,
cy
);
})
})
This diff is collapsed.
Click to expand it.
StudentManagementFrontend/cypress/e2e/create-course-add-teacher-and-students.cy.ts
+
7
-
7
View file @
311d8a13
import
{
Util
}
from
"
./util
"
;
import
{
Method
Util
}
from
"
./
method-
util
"
;
describe
(
'
create course
'
,
()
=>
{
it
(
'
create course and add teacher and three students
'
,
()
=>
{
Util
.
loginSuccess
(
'
Admin
'
,
'
user
'
,
'
12345678
'
,
cy
);
Util
.
createCourse
(
'
Test
'
,
20
,
cy
);
Util
.
addTeacherToCourse
(
'
Test
'
,
'
teacher
'
,
cy
);
Util
.
addStudentToCourse
(
'
Test
'
,
'
studi
'
,
cy
);
Util
.
addStudentToCourse
(
'
Test
'
,
'
studi123
'
,
cy
);
Util
.
addStudentToCourse
(
'
Test
'
,
'
stu
'
,
cy
);
Method
Util
.
loginSuccess
(
'
Admin
'
,
'
user
'
,
'
12345678
'
,
cy
);
Method
Util
.
createCourse
(
'
Test
'
,
20
,
cy
);
Method
Util
.
addTeacherToCourse
(
'
Test
'
,
'
teacher
'
,
cy
);
Method
Util
.
addStudentToCourse
(
'
Test
'
,
'
studi
'
,
cy
);
Method
Util
.
addStudentToCourse
(
'
Test
'
,
'
studi123
'
,
cy
);
Method
Util
.
addStudentToCourse
(
'
Test
'
,
'
stu
'
,
cy
);
})
})
This diff is collapsed.
Click to expand it.
StudentManagementFrontend/cypress/e2e/login.cy.ts
+
5
-
5
View file @
311d8a13
import
{
Util
}
from
"
./util
"
;
import
{
Method
Util
}
from
"
./
method-
util
"
;
describe
(
'
login
'
,
()
=>
{
it
(
'
Visits the initial project page
'
,
()
=>
{
cy
.
visit
(
'
/
'
)
cy
.
contains
(
'
Login
'
)
Util
.
loginSuccess
(
'
Student
'
,
'
studi
'
,
'
123
'
,
cy
);
Util
.
loginSuccess
(
'
Teacher
'
,
'
teacher
'
,
'
12345678
'
,
cy
);
Util
.
loginSuccess
(
'
Admin
'
,
'
user
'
,
'
12345678
'
,
cy
);
Util
.
loginFail
(
cy
);
Method
Util
.
loginSuccess
(
'
Student
'
,
'
studi
'
,
'
123
'
,
cy
);
Method
Util
.
loginSuccess
(
'
Teacher
'
,
'
teacher
'
,
'
12345678
'
,
cy
);
Method
Util
.
loginSuccess
(
'
Admin
'
,
'
user
'
,
'
12345678
'
,
cy
);
Method
Util
.
loginFail
(
cy
);
})
})
This diff is collapsed.
Click to expand it.
StudentManagementFrontend/cypress/e2e/util.ts
→
StudentManagementFrontend/cypress/e2e/
method-
util.ts
+
1
-
3
View file @
311d8a13
export
class
Util
{
export
class
Method
Util
{
static
loginSuccess
(
role
:
string
,
username
:
string
,
password
:
string
,
cy
:
Cypress
.
cy
&
CyEventEmitter
)
{
const
url
=
'
http://localhost:4200/
'
;
...
...
@@ -21,8 +21,6 @@ export class Util {
static
createCourse
(
courseName
:
string
,
totalHours
:
number
,
cy
:
Cypress
.
cy
&
CyEventEmitter
)
{
const
urlCoursePage
=
'
http://localhost:4200/course/Math
'
;
const
urlAddStudent
=
'
http://localhost:8080/grades/add-student-to-course-by-username
'
;
const
urlCreateCourse
=
'
http://localhost:8080/courses/add
'
;
cy
.
visit
(
urlCoursePage
);
cy
.
get
(
'
#courseName
'
).
type
(
courseName
);
cy
.
get
(
'
#totalHours
'
).
type
(
`
${
totalHours
}
`
);
...
...
This diff is collapsed.
Click to expand it.
StudentManagementFrontend/src/app/components/course-page/course-page.component.spec.ts
+
1
-
5
View file @
311d8a13
...
...
@@ -20,14 +20,10 @@ fdescribe('CoursePageComponent', () => {
return
of
(
course
);
})
/*courseServiceSpy.addStudentToCourse.and.callFake(function (username, courseName) {
//response
})*/
TestBed
.
configureTestingModule
({
declarations
:
[
CoursePageComponent
],
imports
:
[
RouterTestingModule
.
withRoutes
([])
RouterTestingModule
],
providers
:
[
{
...
...
This diff is collapsed.
Click to expand it.
StudentManagementFrontend/src/app/components/login-form/login-form.component.spec.ts
+
36
-
2
View file @
311d8a13
import
{
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
LoginFormComponent
}
from
'
./login-form.component
'
;
import
{
LoginServiceService
}
from
"
../../services/login-service.service
"
;
import
{
of
}
from
"
rxjs
"
;
import
{
FormsModule
,
ReactiveFormsModule
}
from
"
@angular/forms
"
;
describe
(
'
LoginFormComponent
'
,
()
=>
{
f
describe
(
'
LoginFormComponent
'
,
()
=>
{
let
component
:
LoginFormComponent
;
let
fixture
:
ComponentFixture
<
LoginFormComponent
>
;
let
loginService
:
jasmine
.
SpyObj
<
LoginServiceService
>
beforeEach
(()
=>
{
loginService
=
jasmine
.
createSpyObj
(
'
LoginServiceService
'
,
[
'
onSubmit
'
]);
TestBed
.
configureTestingModule
({
declarations
:
[
LoginFormComponent
]
declarations
:
[
LoginFormComponent
],
imports
:
[
FormsModule
,
ReactiveFormsModule
],
providers
:
[
{
provide
:
LoginServiceService
,
useValue
:
loginService
}
]
});
fixture
=
TestBed
.
createComponent
(
LoginFormComponent
);
component
=
fixture
.
componentInstance
;
...
...
@@ -18,4 +30,26 @@ describe('LoginFormComponent', () => {
it
(
'
should create
'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
it
(
'
should call loginService.login with username and password on form submission
'
,
()
=>
{
const
username
=
'
test-user
'
;
const
password
=
'
test-password
'
;
const
jwtToken
=
'
fake-jwt-token
'
;
;
component
.
username
=
username
;
component
.
password
=
password
;
loginService
.
onSubmit
.
and
.
returnValue
(
of
(
{
jwt
:
jwtToken
,
userRole
:
'
admin
'
,
username
:
username
}
))
const
mySpy
=
spyOn
(
localStorage
,
'
setItem
'
);
component
.
onSubmit
();
expect
(
loginService
.
onSubmit
).
toHaveBeenCalledWith
(
username
,
password
);
expect
(
mySpy
).
toHaveBeenCalledWith
(
'
auth_token
'
,
jwtToken
);
});
});
This diff is collapsed.
Click to expand it.
StudentManagementFrontend/src/app/services/course.service.spec.ts
+
2
-
3
View file @
311d8a13
import
{
TestBed
}
from
'
@angular/core/testing
'
;
import
{
TestBed
}
from
'
@angular/core/testing
'
;
import
{
CourseService
}
from
'
./course.service
'
;
import
{
CourseService
}
from
'
./course.service
'
;
import
{
HttpClientTestingModule
,
HttpTestingController
}
from
"
@angular/common/http/testing
"
;
import
{
Teacher
}
from
"
../RequestResponseObjects/teacher
"
;
fdescribe
(
'
CourseService
'
,
()
=>
{
let
service
:
CourseService
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help