/
course.spec.ts
105 lines (81 loc) · 3.93 KB
/
course.spec.ts
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
import { NavBarPage, SignInPage } from '../page-objects/jhi-page-objects';
import { browser, by, element, ExpectedConditions as ec } from 'protractor';
import { CoursePage, NewCoursePage } from '../page-objects/entities/course-page-object';
const expect = chai.expect;
describe('course', () => {
let navBarPage: NavBarPage;
let signInPage: SignInPage;
let coursePage: CoursePage;
let newCoursePage: NewCoursePage;
let courseName: string;
before(async () => {
await browser.get('/');
navBarPage = new NavBarPage(true);
signInPage = await navBarPage.getSignInPage();
coursePage = new CoursePage();
newCoursePage = new NewCoursePage();
courseName = `Protractor${Date.now()}`;
await signInPage.autoSignInUsing(process.env.bamboo_admin_user, process.env.bamboo_admin_password);
});
beforeEach(async () => {
await navBarPage.clickOnCourseAdminMenu();
});
it('should load course list', async () => {
const expect1 = 'arTeMiSApp.course.home.title';
const value1 = await element(by.id('course-page-heading')).getAttribute('jhiTranslate');
expect(value1).to.eq(expect1);
});
it('should not create new course with empty input', async () => {
await coursePage.clickOnCreateNewCourse();
expect(await newCoursePage.save.getAttribute('disabled')).to.equal('true');
await newCoursePage.clickCancel();
});
it('should not create new course without groups', async () => {
await coursePage.clickOnCreateNewCourse();
await newCoursePage.setTitle(courseName);
await newCoursePage.setShortName(courseName);
expect(await newCoursePage.save.getAttribute('disabled')).to.equal('true');
await newCoursePage.clickCancel();
});
it('should allow to create new course without tutor group', async () => {
await coursePage.clickOnCreateNewCourse();
await newCoursePage.setTitle(courseName);
await newCoursePage.setShortName(courseName);
await newCoursePage.setStudentGroupName('tumuser');
await newCoursePage.setInstructorGroupName('ls1instructor');
expect(await newCoursePage.save.getAttribute('disabled')).to.equal(null);
await newCoursePage.clickCancel();
});
it('should save course with title, short title, student, tutor and instructor groups', async () => {
await coursePage.clickOnCreateNewCourse();
await newCoursePage.setTitle(courseName);
await newCoursePage.setShortName(courseName);
await newCoursePage.setStudentGroupName('tumuser');
await newCoursePage.setTutorGroupName('artemis-dev');
await newCoursePage.setInstructorGroupName('ls1instructor');
expect(await newCoursePage.save.getAttribute('disabled')).to.equal(null);
await newCoursePage.clickSave();
browser.wait(ec.urlContains('/course'), 5000).then((result: any) => expect(result).to.be.true);
});
it('should show the created course in the list', async () => {
const rows = element.all(by.tagName('tbody')).all(by.tagName('tr'));
const lastTitle = await rows
.last()
.element(by.css('td:nth-child(2) > span.bold'))
.getText();
expect(lastTitle).contains(courseName);
});
it('can be deleted', async () => {
let rows = element.all(by.tagName('tbody')).all(by.tagName('tr'));
const numberOfCourses = await rows.count();
const deleteButton = rows.last().element(by.className('btn-danger'));
await deleteButton.click();
const confirmDeleteButton = element(by.tagName('jhi-course-delete-dialog')).element(by.className('btn-danger'));
await confirmDeleteButton.click();
rows = element.all(by.tagName('tbody')).all(by.tagName('tr'));
expect(await rows.count()).to.equal(numberOfCourses - 1);
});
after(async () => {
await navBarPage.autoSignOut();
});
});