Skip to content

Commit

Permalink
Development: Fix and re-enable exam mode e2e tests (#8946)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonEntholzer authored Jul 2, 2024
1 parent 940db78 commit 62f0910
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 122 deletions.
4 changes: 2 additions & 2 deletions src/test/playwright/e2e/exam/ExamAssessment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ test.describe('Exam statistics', () => {
test.beforeEach('Participate in exam', async ({ examParticipation, examNavigation }) => {
for (const student of students) {
await examParticipation.startParticipation(student, course, exam);
await examNavigation.openExerciseAtIndex(0);
await examNavigation.openOrSaveExerciseByTitle(exercise.title!);
await examParticipation.makeSubmission(exercise.id!, exercise.type!, exercise.additionalData);
await examParticipation.handInEarly();
}
Expand Down Expand Up @@ -364,7 +364,7 @@ async function makeExamSubmission(
examStartEnd: ExamStartEndPage,
) {
await examParticipation.startParticipation(studentOne, course, exam);
await examNavigation.openExerciseAtIndex(0);
await examNavigation.openOrSaveExerciseByTitle(exercise.title!);
await examParticipation.makeSubmission(exercise.id!, exercise.type!, exercise.additionalData);
await page.waitForTimeout(2000);
await examNavigation.handInEarly();
Expand Down
39 changes: 17 additions & 22 deletions src/test/playwright/e2e/exam/ExamDateVerification.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ test.describe('Exam date verification', () => {
await login(studentOne);
await page.goto(`/courses/${course.id}`);
await courseOverview.openExamsTab();
await courseOverview.openExam(exam.id!);
await page.waitForURL(`**/exams/${exam.id}**`);
await page.waitForURL(`**/exams/${exam.id}`);
});

test('Student can start after start Date', async ({
Expand Down Expand Up @@ -76,28 +75,23 @@ test.describe('Exam date verification', () => {
await examAPIRequests.prepareExerciseStartForExam(exam);
await login(studentOne);
await page.goto(`/courses/${course.id}/exams`);
await courseOverview.openExam(exam.id!);
await page.waitForURL(`**/exams/${exam.id}**`);
await courseOverview.openExamsTab();
await courseOverview.openExam(exam.title!);
await page.waitForURL(`**/exams/${exam.id}`);
await expect(page.getByText(exam.title!).first()).toBeVisible();
await examStartEnd.startExam();
await examNavigation.openExerciseAtIndex(0);
await expect(page.locator('span[ng-reflect-ngb-tooltip="Exercise not started"]')).toBeVisible();
await examNavigation.openOrSaveExerciseByTitle(exercise.title!);
const submission = await Fixtures.get('loremIpsum-short.txt');
await textExerciseEditor.typeSubmission(exercise.id!, submission!);
await examNavigation.clickSave();
await expect(page.locator('span[ng-reflect-ngb-tooltip="Exercise not saved"]')).toBeVisible();
await examNavigation.openOrSaveExerciseByTitle(exercise.title!);
await expect(page.locator('span[ng-reflect-ngb-tooltip="Exercise saved"]')).toBeVisible();
await examNavigation.openOrSaveExerciseByTitle(exercise.title!);
});

test('Exam ends after end time', async ({
page,
login,
examAPIRequests,
exerciseAPIRequests,
courseOverview,
examStartEnd,
examNavigation,
textExerciseEditor,
examParticipation,
}) => {
const examEnd = dayjs().add(30, 'seconds');
test('Exam ends after end time', async ({ page, login, examAPIRequests, exerciseAPIRequests, examStartEnd, examNavigation, textExerciseEditor, examParticipation }) => {
const examEnd = dayjs().add(10, 'seconds');
const examConfig = {
course,
title: examTitle,
Expand All @@ -112,14 +106,15 @@ test.describe('Exam date verification', () => {
await examAPIRequests.generateMissingIndividualExams(exam);
await examAPIRequests.prepareExerciseStartForExam(exam);
await login(studentOne);
await page.goto(`/courses/${course.id}/exams`);
await courseOverview.openExam(exam.id!);
await page.goto(`/courses/${course.id}/exams/${exam.id}`);
await page.waitForURL(`**/exams/${exam.id}`);
await expect(page.getByText(exam.title!).first()).toBeVisible();
await examStartEnd.startExam();
await examNavigation.openExerciseAtIndex(0);

await examNavigation.openOrSaveExerciseByTitle(exercise.title!);
const submissionText = await Fixtures.get('loremIpsum-short.txt');
await textExerciseEditor.typeSubmission(exercise.id!, submissionText!);
await examNavigation.clickSave();
await examNavigation.openOrSaveExerciseByTitle(exercise.title!);
if (examEnd.isAfter(dayjs())) {
await page.waitForTimeout(examEnd.diff(dayjs()));
}
Expand Down
53 changes: 24 additions & 29 deletions src/test/playwright/e2e/exam/ExamParticipation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ test.describe('Exam participation', () => {
await examParticipation.startParticipation(studentTwo, course, exam);
for (let j = 0; j < exerciseArray.length; j++) {
const exercise = exerciseArray[j];
await examNavigation.openExerciseAtIndex(j);
await examNavigation.openOrSaveExerciseByTitle(exercise.title!);
await examParticipation.makeSubmission(exercise.id!, exercise.type!, exercise.additionalData);
}
await examParticipation.handInEarly();
Expand All @@ -85,18 +85,16 @@ test.describe('Exam participation', () => {
await examManagement.verifySubmitted(course.id!, exam.id!, studentTwoName);
});

test('Using save and continue to navigate within exam', async ({ login, examParticipation, examNavigation, examManagement }) => {
test('Using navigation sidebar to navigate within exam', async ({ login, examParticipation, examNavigation, examManagement }) => {
await examParticipation.startParticipation(studentThree, course, exam);
await examNavigation.openExerciseAtIndex(0);
for (let j = 0; j < exerciseArray.length; j++) {
const exercise = exerciseArray[j];
await examNavigation.openOrSaveExerciseByTitle(exercise.title!);
// Skip programming exercise this time to save execution time
// (we also need to use the navigation bar here, since programming exercises do not have a "Save and continue" button)
if (exercise.type == ExerciseType.PROGRAMMING) {
await examNavigation.openExerciseAtIndex(j + 1);
} else {
if (exercise.type !== ExerciseType.PROGRAMMING) {
await examParticipation.makeSubmission(exercise.id!, exercise.type!, exercise.additionalData);
await examParticipation.clickSaveAndContinue();
await examNavigation.openOrSaveExerciseByTitle(exercise.title!);
}
}
await examParticipation.handInEarly();
Expand All @@ -109,13 +107,9 @@ test.describe('Exam participation', () => {
await examParticipation.startParticipation(studentFour, course, exam);
for (let j = 0; j < exerciseArray.length; j++) {
const exercise = exerciseArray[j];
// Skip programming exercise this time to save execution time
// (we also need to use the navigation bar here, since programming exercises do not have a "Save and continue" button)
if (exercise.type != ExerciseType.PROGRAMMING) {
await examNavigation.openExerciseOverview();
await examParticipation.selectExerciseOnOverview(j + 1);
await examParticipation.makeSubmission(exercise.id!, exercise.type!, exercise.additionalData);
}
// await
await examNavigation.openFromOverviewByTitle(exercise.title!);
await examNavigation.openOverview();
}
await examParticipation.handInEarly();

Expand Down Expand Up @@ -155,16 +149,16 @@ test.describe('Exam participation', () => {
await examParticipation.startParticipation(studentTwo, course, exam);
const textExerciseIndex = 0;
const textExercise = exerciseArray[textExerciseIndex];
await examNavigation.openExerciseAtIndex(textExerciseIndex);
await examNavigation.openOrSaveExerciseByTitle(textExercise.title!);
await examParticipation.makeTextExerciseSubmission(textExercise.id!, textExercise.additionalData!.textFixture!);
await examParticipation.clickSaveAndContinue();
await examNavigation.openOrSaveExerciseByTitle(textExercise.title!);
await examNavigation.handInEarly();

await examStartEnd.clickContinue();
await examNavigation.openExerciseAtIndex(textExerciseIndex);
await examNavigation.openOrSaveExerciseByTitle(textExercise.title!);
await textExerciseEditor.clearSubmission(textExercise.id!);
await examParticipation.makeTextExerciseSubmission(textExercise.id!, textFixtureShort);
await examParticipation.clickSaveAndContinue();
await examNavigation.openOrSaveExerciseByTitle(textExercise.title!);

await examParticipation.handInEarly();
await examStartEnd.pressShowSummary();
Expand All @@ -187,15 +181,16 @@ test.describe('Exam participation', () => {
await examParticipation.startParticipation(studentThree, course, exam);
const textExerciseIndex = 0;
const textExercise = exerciseArray[textExerciseIndex];
await examNavigation.openExerciseAtIndex(textExerciseIndex);
await examNavigation.openOrSaveExerciseByTitle(textExercise.title!);
await examParticipation.makeTextExerciseSubmission(textExercise.id!, textExercise.additionalData!.textFixture!);
await examParticipation.clickSaveAndContinue();
await examNavigation.openOrSaveExerciseByTitle(textExercise.title!);

await page.reload();
await examParticipation.startParticipation(studentThree, course, exam);
await examNavigation.openExerciseAtIndex(textExerciseIndex);
await textExerciseEditor.checkCurrentContent(textExercise.id!, textExercise.additionalData!.textFixture!);
await examParticipation.clickSaveAndContinue();
await page.goto(`/courses/${course.id}/exams/${exam.id}`);
await examParticipation.startExam();
await examNavigation.openOrSaveExerciseByTitle(textExercise.title!);
await textExerciseEditor.checkCurrentContent(textExercise.additionalData!.textFixture!);
await examNavigation.openOrSaveExerciseByTitle(textExercise.title!);
await examParticipation.handInEarly();
await examStartEnd.pressShowSummary();
await examParticipation.verifyTextExerciseOnFinalPage(textExercise.id!, textExercise.additionalData!.textFixture!);
Expand All @@ -209,9 +204,9 @@ test.describe('Exam participation', () => {
await examParticipation.startParticipation(studentFour, course, exam);
const textExerciseIndex = 0;
const textExercise = exerciseArray[textExerciseIndex];
await examNavigation.openExerciseAtIndex(textExerciseIndex);
await examNavigation.openOrSaveExerciseByTitle(textExercise.title!);
await examParticipation.makeTextExerciseSubmission(textExercise.id!, textExercise.additionalData!.textFixture!);
await examParticipation.clickSaveAndContinue();
await examNavigation.openOrSaveExerciseByTitle(textExercise.title!);
await examParticipation.handInEarly();
await examStartEnd.pressShowSummary();
await examParticipation.verifyTextExerciseOnFinalPage(textExercise.id!, textExercise.additionalData!.textFixture!);
Expand Down Expand Up @@ -248,9 +243,9 @@ test.describe('Exam participation', () => {
await examParticipation.startParticipation(studentFour, course, exam);
const textExerciseIndex = 0;
const textExercise = exerciseArray[textExerciseIndex];
await examNavigation.openExerciseAtIndex(textExerciseIndex);
await examNavigation.openOrSaveExerciseByTitle(textExercise.title!);
await examParticipation.makeSubmission(textExercise.id!, textExercise.type!, textExercise.additionalData);
await examParticipation.clickSaveAndContinue();
await examNavigation.openOrSaveExerciseByTitle(textExercise.title!);
await examParticipation.checkExamFullnameInputExists();
await examParticipation.checkYourFullname(studentFourName);
const response = await examStartEnd.finishExam();
Expand Down Expand Up @@ -350,7 +345,7 @@ test.describe('Exam participation', () => {
await modalDialog.checkDialogMessage(timeChangeMessage);
await modalDialog.checkDialogAuthor(instructor.username);
await modalDialog.closeDialog();
await examParticipationActions.checkExamTimeLeft('29min');
await examParticipationActions.checkExamTimeLeft('29');
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/test/playwright/e2e/exam/ExamResults.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ test.describe('Exam Results', () => {
test.beforeEach('Participate in exam', async ({ login, examParticipation, examNavigation, examStartEnd }) => {
await login(admin);
await examParticipation.startParticipation(studentOne, course, exam);
await examNavigation.openExerciseAtIndex(0);
await examNavigation.openOrSaveExerciseByTitle(exercise.title!);
await examParticipation.makeSubmission(exercise.id!, exercise.type!, exercise.additionalData);
await examParticipation.handInEarly();
await examStartEnd.pressShowSummary();
Expand Down
5 changes: 1 addition & 4 deletions src/test/playwright/e2e/exam/ExamTestRun.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,13 @@ test.describe('Exam test run', () => {

for (let j = 0; j < exerciseArray.length; j++) {
const exercise = exerciseArray[j];
await examNavigation.openExerciseAtIndex(j);
await examNavigation.openOrSaveExerciseByTitle(exercise.title!);
await examParticipation.makeSubmission(exercise.id!, exercise.type!, exercise.additionalData);
}
await examParticipation.handInEarly();
for (let j = 0; j < exerciseArray.length; j++) {
const exercise = exerciseArray[j];
await examParticipation.verifyExerciseTitleOnFinalPage(exercise.id!, exercise.exerciseGroup!.title!);
if (exercise.type === ExerciseType.TEXT) {
await examParticipation.verifyTextExerciseOnFinalPage(exercise.id!, exercise.additionalData!.textFixture!);
}
}
await examParticipation.checkExamTitle(examTitle);
await examTestRun.openTestRunPage(course, exam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ test.describe('Test Exam management', () => {
await page.goto(`/course-management/${course.id}/exams`);
await examManagement.openExerciseGroups(exam.id!);
await examExerciseGroups.shouldHaveTitle(exerciseGroup.id!, exerciseGroup.title!);
await examExerciseGroups.clickEditGroup(exerciseGroup.id!);
await examExerciseGroups.clickEditGroupForTestExam();
const newGroupName = 'Group 3';
await examExerciseGroupCreation.typeTitle(newGroupName);
await examExerciseGroupCreation.update();
Expand Down
Loading

0 comments on commit 62f0910

Please sign in to comment.