Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Fix failing cypress tests that use sidebar #8348

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/test/cypress/e2e/course/CourseExercise.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ describe('Course Exercise', () => {

it('should filter exercises based on title', () => {
cy.visit(`/courses/${course.id}/exercises`);
courseOverview.getExercise(exercise1.id!).should('be.visible');
courseOverview.getExercise(exercise2.id!).should('be.visible');
courseOverview.getExercise(exercise3.id!).should('be.visible');
courseOverview.getExercise(exercise1.title!).should('be.visible');
courseOverview.getExercise(exercise2.title!).should('be.visible');
courseOverview.getExercise(exercise3.title!).should('be.visible');
courseOverview.search('Course Exercise Quiz');
courseOverview.getExercise(exercise1.id!).should('be.visible');
courseOverview.getExercise(exercise2.id!).should('be.visible');
courseOverview.getExercise(exercise3.id!).should('not.exist');
courseOverview.getExercise(exercise1.title!).should('be.visible');
courseOverview.getExercise(exercise2.title!).should('be.visible');
courseOverview.getExercise(exercise3.title!).should('not.exist');
});

after('Delete Exercises', () => {
Expand Down
4 changes: 4 additions & 0 deletions src/test/cypress/e2e/exercises/ExerciseImport.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ describe('Import exercises', { scrollBehavior: 'center' }, () => {
textExerciseCreation.import().then((request: Interception) => {
const exercise = request.response!.body;
cy.login(studentOne, `/courses/${secondCourse.id}`);
courseOverview.openExerciseOverview(exercise.title!);
courseOverview.startExercise(exercise.id!);
courseOverview.openRunningExercise(exercise.id!);
cy.fixture('loremIpsum-short.txt').then((submission) => {
Expand Down Expand Up @@ -112,6 +113,7 @@ describe('Import exercises', { scrollBehavior: 'center' }, () => {
const exercise = request.response!.body;
courseManagementExercises.startQuiz(exercise.id!);
cy.login(studentOne, `/courses/${secondCourse.id}`);
courseOverview.openExerciseOverview(exercise.title!);
courseOverview.startExercise(exercise.id!);
quizExerciseMultipleChoice.tickAnswerOption(exercise.id!, 0);
quizExerciseMultipleChoice.tickAnswerOption(exercise.id!, 2);
Expand All @@ -137,6 +139,7 @@ describe('Import exercises', { scrollBehavior: 'center' }, () => {
modelingExerciseCreation.import().then((request: Interception) => {
const exercise = request.response!.body;
cy.login(studentOne, `/courses/${secondCourse.id}`);
courseOverview.openExerciseOverview(exercise.title!);
courseOverview.startExercise(exercise.id!);
courseOverview.openRunningExercise(exercise.id!);
modelingExerciseEditor.addComponentToModel(exercise.id!, 1);
Expand All @@ -163,6 +166,7 @@ describe('Import exercises', { scrollBehavior: 'center' }, () => {
programmingExerciseCreation.import().then((request: Interception) => {
const exercise = request.response!.body;
cy.login(studentOne, `/courses/${secondCourse.id}`);
courseOverview.openExerciseOverview(exercise.title!);
courseOverview.startExercise(exercise.id!);
courseOverview.openRunningExercise(exercise.id!);
programmingExerciseEditor.makeSubmissionAndVerifyResults(exercise.id!, javaPartiallySuccessfulSubmission, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
courseManagement,
courseManagementAPIRequest,
courseManagementExercises,
courseOverview,
exerciseAPIRequest,
modelingExerciseAssessment,
modelingExerciseCreation,
Expand Down Expand Up @@ -135,7 +136,7 @@ describe('Modeling Exercise Management', () => {
});
cy.login(studentOne, '/courses');
cy.contains(course.title!).click({ force: true });
cy.contains('No exercises available for the course.').should('be.visible');
courseOverview.getExercises().should('have.length', 0);
});

it('Student can see released Modeling Exercise', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Quiz Exercise Participation', () => {

it('Student cannot see hidden quiz', () => {
cy.login(studentOne, '/courses/' + course.id);
cy.contains('No exercises available for the course.').should('be.visible');
courseOverview.getExercises().should('have.length', 0);
});

it('Student can see a visible quiz', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class CourseCommunicationPage {
}

searchForMessage(search: string) {
cy.get('#search').type(search);
cy.get('input[name="searchText"]').type(search);
cy.get('#search-submit').click();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export class CourseOverviewPage {
readonly participationRequestId = 'participateInExerciseQuery';

search(term: string): void {
cy.get('#exercise-search-input').type(term);
cy.get('#exercise-search-button').click();
cy.get('input[formcontrolname="searchFilter"]').type(term);
}

startExercise(exerciseId: number) {
Expand All @@ -21,8 +20,16 @@ export class CourseOverviewPage {
cy.get('#open-exercise-' + exerciseId).click();
}

getExercise(exerciseID: number) {
return cy.get(`#exercise-card-${exerciseID}`);
getExercise(exerciseTitle: string) {
return cy.contains('#test-sidebar-card', exerciseTitle);
}

openExerciseOverview(exerciseTitle: string) {
this.getExercise(exerciseTitle).click();
}

getExercises() {
return cy.get('#test-sidebar-card');
}

openRunningProgrammingExercise(exerciseID: number) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ExerciseResultPage {

shouldShowScore(percentage: number) {
cy.reloadUntilFound('#submission-result-graded');
cy.contains(`${percentage}%`).should('be.visible');
cy.contains('.tab-bar-exercise-details', `${percentage}%`).should('be.visible');
}

clickOpenExercise(exerciseId: number) {
Expand Down
Loading