Skip to content

Commit

Permalink
Development: Fix flaky e2e tests (#9326)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonEntholzer authored Oct 3, 2024
1 parent c3ab176 commit 9e04de4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,17 @@ test.describe('Test Exam - student exams', () => {

await studentExamManagement.checkExamStudent(studentOne.username);
await studentExamManagement.checkExamStudent(studentTwo.username);
await studentExamManagement.checkExamStudent(studentThree.username);

await expect(studentExamManagement.getStudentExamRows()).toHaveCount(2);
await expect(studentExamManagement.getStudentExamRows()).toHaveCount(3);

await studentExamManagement.checkStudentExamProperty(studentOne.username, 'Started', 'Yes');
await studentExamManagement.checkStudentExamProperty(studentTwo.username, 'Started', 'Yes');
await studentExamManagement.checkStudentExamProperty(studentThree.username, 'Started', 'No');

await studentExamManagement.checkStudentExamProperty(studentOne.username, 'Submitted', 'Yes');
await studentExamManagement.checkStudentExamProperty(studentTwo.username, 'Submitted', 'No');
await studentExamManagement.checkStudentExamProperty(studentThree.username, 'Submitted', 'No');

await studentExamManagement.checkStudentExamProperty(studentTwo.username, 'Used working time', '0s');
});
Expand Down Expand Up @@ -115,6 +118,7 @@ test.describe('Test Exam - student exams', () => {
) {
if (!toStart) {
await examParticipation.openExam(student, course, exam);
await examParticipation.almostStartExam();
} else {
await examParticipation.openExam(student, course, exam);
await examParticipation.startExam();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ test.describe('Modeling Exercise Assessment', () => {
// });

test('Tutor can assess a submission', async ({ login, courseManagement, courseAssessment, exerciseAssessment, modelingExerciseAssessment }) => {
await login(tutor, '/course-management');
await courseManagement.openSubmissionsForExerciseAndCourse(course.id!, modelingExercise.id!);
await courseManagement.checkIfStudentSubmissionExists(studentOne.username);
await login(tutor, '/course-management');
await courseManagement.openAssessmentDashboardOfCourse(course.id!);
await courseAssessment.clickExerciseDashboardButton();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ test.describe('Programming Exercise Management', () => {
});

test('Create an exercise team', async ({ login, page, navigationBar, courseManagement, courseManagementExercises, exerciseTeams, programmingExerciseOverview }) => {
await login(instructor, '/');
await login(instructor);
await navigationBar.openCourseManagement();
await courseManagement.openExercisesOfCourse(course.id!);
await courseManagementExercises.openExerciseTeams(exercise.id!);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ export class CourseManagementPage {
await this.page.waitForURL('**/assessment-dashboard**');
}

async openSubmissionsForExerciseAndCourse(courseID: number, exerciseID: number) {
await this.getCourse(courseID).locator('#course-card-open-exercises').click();
await this.page.waitForURL('**/exercises**');
await this.page.click(`[href="/course-management/${courseID}/modeling-exercises/${exerciseID}/scores"]`);
await this.page.waitForURL('**/scores');
}

async checkIfStudentSubmissionExists(studentName: string) {
await expect(this.page.locator('.datatable-body-row', { hasText: studentName })).toBeVisible();
}

/*
* Helper methods to get information about the course
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export class ExamParticipationPage extends ExamParticipationActions {
await this.examStartEnd.startExam(true);
}

async almostStartExam() {
await this.examStartEnd.onlyClickConfirmationCheckmark();
}

async handInEarly() {
await this.examNavigation.handInEarly();
const response = await this.examStartEnd.finishExam();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export class ExamStartEndPage {
}
}

async onlyClickConfirmationCheckmark() {
await this.setConfirmCheckmark();
}

async finishExam(timeout?: number) {
await this.setConfirmCheckmark(timeout);
await this.enterFirstnameLastname();
Expand Down

0 comments on commit 9e04de4

Please sign in to comment.