From c7f6065430ed94e85f9951cf1a2ddad91fc64637 Mon Sep 17 00:00:00 2001 From: Malte Berg Date: Wed, 29 Nov 2023 15:34:40 +0100 Subject: [PATCH 1/8] add test --- cypress/e2e/course/addCtlToolToCourse.feature | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cypress/e2e/course/addCtlToolToCourse.feature b/cypress/e2e/course/addCtlToolToCourse.feature index 56ef562a..242ddd46 100644 --- a/cypress/e2e/course/addCtlToolToCourse.feature +++ b/cypress/e2e/course/addCtlToolToCourse.feature @@ -22,3 +22,14 @@ Feature: Course - To add a ctl tool to a course Then I can see the tool configuration page title When I click on the tool configuration selection Then I can enter 'Test' as tool name in the selection + + @unstable_test + Scenario: Teacher can't add a tool with the restricted context 'board-lement' + Given I am logged in as a 'teacher1_nbc' at 'nbc' + When I go to rooms overview + When I go to room 'German' + When I click on the tools tab + When I click on the button to add a tool + Then I can see the tool configuration page title + When I click on the tool configuration selection + Then I can not see tool 'CY Test Tool Board-Element Restriction' in the tool selection list From 25063b582ec7509b2e045c5ab0923baf6ca623db Mon Sep 17 00:00:00 2001 From: Malte Berg Date: Wed, 29 Nov 2023 15:42:07 +0100 Subject: [PATCH 2/8] add check --- cypress/support/pages/course/pageCourses.js | 1002 ++++++++++--------- 1 file changed, 504 insertions(+), 498 deletions(-) diff --git a/cypress/support/pages/course/pageCourses.js b/cypress/support/pages/course/pageCourses.js index 9954b1d0..0e9b5301 100644 --- a/cypress/support/pages/course/pageCourses.js +++ b/cypress/support/pages/course/pageCourses.js @@ -1,516 +1,522 @@ 'use strict' class Courses { - static #courseTitle = '[data-testid="coursename"]' - static #nextButton = '[id="nextSection"]' - static #goToCourseOverviewButton = '[data-testid="courses-to-overview-btn"]' - static #deleteButton = '[data-method="DELETE"]' - static #confirmDeletionPopup = '[data-testid="modal_delete_course_button"]' - static #btnSubmit = '[data-testid="modal-edit-course-button"]' - static #courseDescription = '[id="courseDescription"]' - static #courseName = '[name="name"]' - static #createFAB = '[name="fab-icon"]' - static #newTopicFAB = '[data-testid="fab_button_add_lesson"]' - static #searchFieldRoomOverview = '[data-testid="search-field"]' - static #mainContent = '[id="main-content"]' - static #createCourse = '[data-testid="add-course-button"]' - static #createContent = '[data-testid="add-content-button"]' - static #ltiToolsTab = '[data-testid="tools"]' - static #toolsList = '[data-testid="course_tool_list_add_tool"]' - static #courseOverviewNavigationButton = '[data-testid="Course-Overview"]' - static #addNewToolButton = '[data-testid="add_new_tool"]' - static #newTaskFAB = '[data-testid="fab_button_add_task"]' - static #dialogConfirmButton = '[data-testid="dialog-confirm"]' - static #dialogCancelButton = '[data-testid="dialog-cancel"]' - static #deleteButtonInDotMenu = - '[data-testid="content-card-task-menu-remove"]' - static #deleteButtonInDotMenuOfTopic = - '[data-testid="content-card-lesson-menu-remove"]' - static #editButtonInDotMenu = '[data-testid="content-card-task-menu-edit"]' - static #editButtonInDotMenuOfTopic = - '[data-testid="content-card-lesson-menu-edit"]' - static #contentCardContent = '[data-testid="content-card-task-content"]' - static #contentCardTopic = '[data-testid="content-card-lesson-content"]' - static #contentCardTaskActions = '[data-testid="content-card-task-actions"]' - static #dropDownCourse = '[data-testid="title-menu"]' - static #btnCourseEdit = '[data-testid="title-menu-edit-delete"]' - static #pageTitle = '[id="page-title"]' - static #contentCardTaskInfoSubmissionsChip = - '[data-testid="room-detail-task-chip-submitted"]' - static #contentCardTaskInfoGradingsChip = - '[data-testid="room-detail-task-chip-graded"]' - static #addSubstituteTeacher = '[id="substituteTeacher_chosen"]' - static #chosenResults = '.chosen-results li' - static #chosenContainer = '.chosen-container span' - static #roomSearrchBox = '[data-testid="search-field"]' - static #selectRoomColour = '[data-testid="color-picker"]' - static #RoomColourAsRed = '[aria-label="#D50000"]' - static #chosenCourseTeacher = '[id="courseTeacher_chosen"]' - static #chosenSubstituteTeacher = '[id="courseSubstitute_chosen"]' - static #courseStartDatePicker = '[data-testid="date_start"]' - static #courseEndDatePicker = '[data-testid="form-date-input-untilDate"]' - static #courseTimeTableContainer = '[data-timesref="#timesContainer"]' - static #addClassToCourseSelectionBox = '[id="addClassesToCourse_chosen"]' - static #addStudentToCourseSelectionBox = '[id="addStudentsToCourse_chosen"]' - static #nextButtonToCreateCourseOnParticipationDeatilStep = - '[id="nextSection"]' - static #sectionThreeAreaOnCourseCreationPage = - '[data-testid="section-3-area"]' - static #sectionOneAreaOnCourseCreationPage = '[data-testid="section-1-area"]' - static #sectionTwoAreaOnCourseCreationPage = '[data-testid="section-2-area"]' - static #courseDeleteConfirmationModal = '[data-testid="popup-title"]' - static #courseTitleInRoomoverview = '[data-testid="course-title"]' - static #learningContentTab = '[data-testid="learnContent-tab"]' - static #courseDetailPageTitle = '[data-testid="courses-course-title"]' - - static #toolsTab = '[data-testid="tools-tab"]' - static #addToolButton = '[data-testid="add-tool-button"]' - static #toolConfigurationSelect = '[data-testid="configuration-select"]' - static #contextExternalToolConfiguratorPageTitle = '[data-testid="context-external-tool-configurator-title"]' - static #groupSelection = '[id="classId_chosen"]' - static #chosenStudents= '[id="studentsId_chosen"] > .chosen-choices' - seeSectionOneAreaOnCourseCreatePage () { - cy.get(Courses.#sectionOneAreaOnCourseCreationPage).should('exist') - } - - seeSectionTwoAreaOnCourseCreatePage () { - cy.get(Courses.#sectionTwoAreaOnCourseCreationPage).should('exist') - } - - seeSelectedDefaultTeacher (defaultTeacherName) { - cy.get(Courses.#chosenCourseTeacher).contains(defaultTeacherName) - } - - seeSubstituteTeacherSelectionBox () { - cy.get(Courses.#chosenSubstituteTeacher).should('exist') - } - - seeDatePickersForCourseInSchoolYear () { - cy.get(Courses.#courseStartDatePicker).should('exist') - cy.get(Courses.#courseEndDatePicker).should('exist') - } - - seeCreateCourseTimeTableContainer () { - cy.get(Courses.#courseTimeTableContainer).should('exist') - } - - seeSelectionBoxToSelectClass () { - cy.get(Courses.#addClassToCourseSelectionBox).should('exist') - } - - seeSelectioinBoxToSelectStudent () { - cy.get(Courses.#addStudentToCourseSelectionBox).should('exist') - } - - clickOnNextStepButtonOnCourseParticipationDetail () { - cy.get(Courses.#nextButtonToCreateCourseOnParticipationDeatilStep).click() - } - - seeCourseCreationFinishPageSectionThree () { - cy.get(Courses.#sectionThreeAreaOnCourseCreationPage).should('exist') - } - - selectRoomColour () { - cy.get(Courses.#RoomColourAsRed).click() - } - - seeRoomSearchBoxOnRoomOverview () { - cy.get(Courses.#roomSearrchBox).should('be.exist') - } - - courseIsVisiblOnOverviewPage (courseName) { - cy.contains(courseName).should('be.visible').and('contain.text', courseName) - } - - courseIsNotVisiblOnOverviewPage (courseName) { - cy.contains(courseName).should('not.exist') - } - - navigateToRoomsOverview () { - cy.get(Courses.#courseOverviewNavigationButton).click() - } - - navigateToRoomBoard (roomName) { - cy.contains(Courses.#courseTitleInRoomoverview, roomName) - .should('be.visible') - .then(title => { - cy.wrap(title) - .prev() - .click() - .then(() => { - return new Cypress.Promise((resolve, reject) => { - try { - setTimeout(() => { - cy.wait(['@alert_api', '@board_api', '@userPermissions_api']) - .get(Courses.#learningContentTab) - .should('have.attr', 'aria-selected', 'true') - resolve() - return - }, 1000) - } catch (error) { - reject(error) - } + static #courseTitle = '[data-testid="coursename"]' + static #nextButton = '[id="nextSection"]' + static #goToCourseOverviewButton = '[data-testid="courses-to-overview-btn"]' + static #deleteButton = '[data-method="DELETE"]' + static #confirmDeletionPopup = '[data-testid="modal_delete_course_button"]' + static #btnSubmit = '[data-testid="modal-edit-course-button"]' + static #courseDescription = '[id="courseDescription"]' + static #courseName = '[name="name"]' + static #createFAB = '[name="fab-icon"]' + static #newTopicFAB = '[data-testid="fab_button_add_lesson"]' + static #searchFieldRoomOverview = '[data-testid="search-field"]' + static #mainContent = '[id="main-content"]' + static #createCourse = '[data-testid="add-course-button"]' + static #createContent = '[data-testid="add-content-button"]' + static #ltiToolsTab = '[data-testid="tools"]' + static #toolsList = '[data-testid="course_tool_list_add_tool"]' + static #courseOverviewNavigationButton = '[data-testid="Course-Overview"]' + static #addNewToolButton = '[data-testid="add_new_tool"]' + static #newTaskFAB = '[data-testid="fab_button_add_task"]' + static #dialogConfirmButton = '[data-testid="dialog-confirm"]' + static #dialogCancelButton = '[data-testid="dialog-cancel"]' + static #deleteButtonInDotMenu = + '[data-testid="content-card-task-menu-remove"]' + static #deleteButtonInDotMenuOfTopic = + '[data-testid="content-card-lesson-menu-remove"]' + static #editButtonInDotMenu = '[data-testid="content-card-task-menu-edit"]' + static #editButtonInDotMenuOfTopic = + '[data-testid="content-card-lesson-menu-edit"]' + static #contentCardContent = '[data-testid="content-card-task-content"]' + static #contentCardTopic = '[data-testid="content-card-lesson-content"]' + static #contentCardTaskActions = '[data-testid="content-card-task-actions"]' + static #dropDownCourse = '[data-testid="title-menu"]' + static #btnCourseEdit = '[data-testid="title-menu-edit-delete"]' + static #pageTitle = '[id="page-title"]' + static #contentCardTaskInfoSubmissionsChip = + '[data-testid="room-detail-task-chip-submitted"]' + static #contentCardTaskInfoGradingsChip = + '[data-testid="room-detail-task-chip-graded"]' + static #addSubstituteTeacher = '[id="substituteTeacher_chosen"]' + static #chosenResults = '.chosen-results li' + static #chosenContainer = '.chosen-container span' + static #roomSearrchBox = '[data-testid="search-field"]' + static #selectRoomColour = '[data-testid="color-picker"]' + static #RoomColourAsRed = '[aria-label="#D50000"]' + static #chosenCourseTeacher = '[id="courseTeacher_chosen"]' + static #chosenSubstituteTeacher = '[id="courseSubstitute_chosen"]' + static #courseStartDatePicker = '[data-testid="date_start"]' + static #courseEndDatePicker = '[data-testid="form-date-input-untilDate"]' + static #courseTimeTableContainer = '[data-timesref="#timesContainer"]' + static #addClassToCourseSelectionBox = '[id="addClassesToCourse_chosen"]' + static #addStudentToCourseSelectionBox = '[id="addStudentsToCourse_chosen"]' + static #nextButtonToCreateCourseOnParticipationDeatilStep = + '[id="nextSection"]' + static #sectionThreeAreaOnCourseCreationPage = + '[data-testid="section-3-area"]' + static #sectionOneAreaOnCourseCreationPage = '[data-testid="section-1-area"]' + static #sectionTwoAreaOnCourseCreationPage = '[data-testid="section-2-area"]' + static #courseDeleteConfirmationModal = '[data-testid="popup-title"]' + static #courseTitleInRoomoverview = '[data-testid="course-title"]' + static #learningContentTab = '[data-testid="learnContent-tab"]' + static #courseDetailPageTitle = '[data-testid="courses-course-title"]' + + static #toolsTab = '[data-testid="tools-tab"]' + static #addToolButton = '[data-testid="add-tool-button"]' + static #toolConfigurationSelect = '[data-testid="configuration-select"]' + static #contextExternalToolConfiguratorPageTitle = '[data-testid="context-external-tool-configurator-title"]' + static #groupSelection = '[id="classId_chosen"]' + static #chosenStudents = '[id="studentsId_chosen"] > .chosen-choices' + static #toolConfigurationSelectItem = '[data-testId="configuration-select-item"]' + + seeSectionOneAreaOnCourseCreatePage() { + cy.get(Courses.#sectionOneAreaOnCourseCreationPage).should('exist') + } + + seeSectionTwoAreaOnCourseCreatePage () { + cy.get(Courses.#sectionTwoAreaOnCourseCreationPage).should('exist') + } + + seeSelectedDefaultTeacher (defaultTeacherName) { + cy.get(Courses.#chosenCourseTeacher).contains(defaultTeacherName) + } + + seeSubstituteTeacherSelectionBox () { + cy.get(Courses.#chosenSubstituteTeacher).should('exist') + } + + seeDatePickersForCourseInSchoolYear () { + cy.get(Courses.#courseStartDatePicker).should('exist') + cy.get(Courses.#courseEndDatePicker).should('exist') + } + + seeCreateCourseTimeTableContainer () { + cy.get(Courses.#courseTimeTableContainer).should('exist') + } + + seeSelectionBoxToSelectClass () { + cy.get(Courses.#addClassToCourseSelectionBox).should('exist') + } + + seeSelectioinBoxToSelectStudent () { + cy.get(Courses.#addStudentToCourseSelectionBox).should('exist') + } + + clickOnNextStepButtonOnCourseParticipationDetail () { + cy.get(Courses.#nextButtonToCreateCourseOnParticipationDeatilStep).click() + } + + seeCourseCreationFinishPageSectionThree () { + cy.get(Courses.#sectionThreeAreaOnCourseCreationPage).should('exist') + } + + selectRoomColour () { + cy.get(Courses.#RoomColourAsRed).click() + } + + seeRoomSearchBoxOnRoomOverview () { + cy.get(Courses.#roomSearrchBox).should('be.exist') + } + + courseIsVisiblOnOverviewPage (courseName) { + cy.contains(courseName).should('be.visible').and('contain.text', courseName) + } + + courseIsNotVisiblOnOverviewPage (courseName) { + cy.contains(courseName).should('not.exist') + } + + navigateToRoomsOverview () { + cy.get(Courses.#courseOverviewNavigationButton).click() + } + + navigateToRoomBoard (roomName) { + cy.contains(Courses.#courseTitleInRoomoverview, roomName) + .should('be.visible') + .then(title => { + cy.wrap(title) + .prev() + .click() + .then(() => { + return new Cypress.Promise((resolve, reject) => { + try { + setTimeout(() => { + cy.wait(['@alert_api', '@board_api', '@userPermissions_api']) + .get(Courses.#learningContentTab) + .should('have.attr', 'aria-selected', 'true') + resolve() + return + }, 1000) + } catch (error) { + reject(error) + } + }) + }) + }) + } + + showRoomPage (courseName) { + cy.wait('@rooms_api') + cy.get(Courses.#courseDetailPageTitle).should('contain.text', courseName) + } + + navigateToLtiTools () { + cy.get(Courses.#ltiToolsTab).click() + } + + clickOnAddNewLtiToolButton () { + cy.get(Courses.#addNewToolButton).click() + } + + navigateToToolsTab () { + cy.get(Courses.#toolsTab).click() + } + + clickOnAddNewToolFAB () { + cy.get(Courses.#addToolButton).click() + } + + seeAddNewToolFAB () { + cy.get(Courses.#addToolButton).should('exist') + } + + seeNotAddNewToolFAB () { + cy.get(Courses.#addToolButton).should('not.exist') + } + + seeContextExternalToolConfiguratorPageTitle () { + cy.get(Courses.#contextExternalToolConfiguratorPageTitle).should('exist') + } + + clickOnToolConfigurationSelect () { + cy.get(Courses.#toolConfigurationSelect).click() + } + + enterAnToolNameInToolConfigurationSelect (toolName) { + cy.get(Courses.#toolConfigurationSelect).type(toolName) + } + + courseIsVisibleOnOverviewPage (courseName) { + cy.contains(courseName).should('be.visible').and('contain.text', courseName) + } + + courseIsNotVisibleOnOverviewPage (courseName) { + cy.contains(courseName).should('not.exist') + } + + canAddBigBlueButton () { + cy.get(Courses.#toolsList).should('be.visible') + } + + canNotAddBigBlueButton () { + cy.get(Courses.#toolsList).should('not.exist') + } + + clickOnCreateRoomFAB () { + cy.get(Courses.#createCourse).click() + } + + clickOnCreateContentFAB () { + cy.wait('@rooms_api') + cy.get(Courses.#createContent).click() + } + + clickOnNewTaskFAB () { + cy.get(Courses.#newTaskFAB).click() + cy.wait('@homework_api') + } + + contentIsVisibleOnCoursePage (taskTitle) { + // no cy.wait('@rooms_api') here as the reload takes care of this + cy.reload() // Reload is necessary because after deletion of a content element a message window with its title stays hidden in the DOM + .wait([ + '@public_api', + '@me_api', + '@roles_api', + '@schools_api', + '@userPermissions_api' + ]) + .then(interceptions => { + expect(interceptions[0].response.statusCode).to.equal(200) + expect(interceptions[1].state).to.equal('Complete') + expect(interceptions[1].response.statusCode).to.equal(200) + }) + cy.contains(taskTitle).should('be.visible') + } + + contentIsNotVisibleOnCoursePage (contentTitle) { + cy.reload() // Reload is necessary because after deletion of a content element a message window with its title stays hidden in the DOM + .wait(['@board_api', '@runtime_config_api', '@public_api']) + .then(interceptions => { + expect(interceptions[0].response.statusCode).to.equal(200) + expect(interceptions[1].response.statusCode).to.equal(200) + expect(interceptions[1].response.statusCode).to.equal(200) + }) + cy.contains(contentTitle).should('not.exist') + } + + openTask (taskTitle) { + // cy.wait('@rooms_api') dont needed as on vue page already where scenario is given + cy.get(Courses.#contentCardContent).contains(taskTitle).click() + cy.wait('@homework_api') + } +openThreeDotMenuForContent (contentTitle) { + cy.wait('@rooms_api') + cy.get(Courses.#contentCardContent) + .contains(contentTitle) + .parent() + .find('button') + .click() + } + + openThreeDotMenuForTopic (contentTitle) { + cy.wait('@rooms_api') + cy.contains(contentTitle).prev().find('button').click() + } + + openTopic (contentTitle) { + cy.contains(contentTitle).parent().click() + } + + clickDeleteInDotMenu () { + cy.get(Courses.#deleteButtonInDotMenu).click() + } + + clickDeleteInDotMenuOfTopic () { + cy.get(Courses.#deleteButtonInDotMenuOfTopic).click() + } + + clickEditInDotMenu (linkId) { + cy.get(Courses.#editButtonInDotMenu).click() + cy.wait('@homework_api') + } + + clickEditInDotMenuOfTopic () { + cy.get(Courses.#editButtonInDotMenuOfTopic).click() + } + + clickOnCancelInConfirmationWindow () { + cy.get(Courses.#dialogCancelButton).click() + } + + clickDeleteInConfirmationWindow () { + cy.get(Courses.#dialogConfirmButton).click() + } + + openCourseEditPage () { + cy.wait('@rooms_api') + cy.get(Courses.#dropDownCourse).parent().click() + cy.get(Courses.#btnCourseEdit).click() + } + + showCourseEditPage () { + cy.get(Courses.#pageTitle).should('exist') + } + + compareSubmittedTasksInformation (submittedTasks, contentTitle) { + cy.wait('@rooms_api') + cy.get(Courses.#contentCardContent) + .contains(contentTitle) + .parent() + .parent() + .find(Courses.#contentCardTaskInfoSubmissionsChip) + .should('contain', submittedTasks) + } + + compareGradedTasksInformation (gradedTasks, contentTitle) { + cy.get(Courses.#contentCardContent) + .contains(contentTitle) + .parent() + .parent() + .find(Courses.#contentCardTaskInfoGradingsChip) + .should('contain', gradedTasks) + } + + clickOnFinishTask (taskTitle) { + cy.wait('@rooms_api') + cy.get(Courses.#contentCardContent) + .contains(taskTitle) + .parent() + .parent() + .find(Courses.#contentCardTaskActions) + .find('button') + .click() + .wait(['@task_finish_api']) + } + + checkTaskCardDoesNotHaveButtons (taskTitle) { + cy.wait('@rooms_api') + cy.get(Courses.#contentCardContent) + .contains(taskTitle) + .parent() + .parent() + .find(Courses.#contentCardTaskActions) + .find('button') + .should('not.exist') + } + + checkTaskCardDoesHaveButtons (taskTitle) { + cy.wait('@rooms_api') + cy.get(Courses.#contentCardContent) + .contains(taskTitle) + .parent() + .parent() + .find(Courses.#contentCardTaskActions) + .find('button') + .should('be.visible') + } + + fillCourseCreationForm (new_course) { + cy.get(Courses.#courseTitle).type(new_course) + } + + clickOnCreateFAB () { + cy.get(Courses.#createFAB).click() + } + + fillCourseCreationForm (newCourseName) { + cy.get(Courses.#courseTitle).type(newCourseName) + } + + clickOnToCourseOverviewBtn () { + cy.get(Courses.#goToCourseOverviewButton).click() + } + + clickOnNextStepsBtnAfterEnteringRoomDetails () { + cy.get(Courses.#nextButton).click() + } + + clickOnDeleteButtonOnCourseEditPage () { + cy.get(Courses.#deleteButton).click() + } + + seeModalToConfirmCourseDeletion () { + cy.get(Courses.#courseDeleteConfirmationModal).should('exist') + } + + confirmCourseDeletionOnModal () { + cy.get(Courses.#confirmDeletionPopup).click({ multiple: true, force: true }) + } + + submitChangesAfterEditingCourse () { + cy.get(Courses.#btnSubmit).click() + } + + editCourseTitle (editedRoomName) { + cy.get(Courses.#courseName).clear().type(editedRoomName) + } + + editCourseDescription (editedRoomDesccription) { + cy.get(Courses.#courseDescription).clear().type(editedRoomDesccription) + } + + searchForARoom (roomName) { + cy.wait('@rooms_overview_api'); + cy.get(Courses.#searchFieldRoomOverview).type(roomName) + } + + clickOnNewTopicFAB () { + cy.get(Courses.#newTopicFAB) + .click() + .wait(['@alerts_api']) + .then(interceptions => { + expect(interceptions.response.statusCode).to.equal(200) }) - }) - }) - } - - showRoomPage (courseName) { - cy.wait('@rooms_api') - cy.get(Courses.#courseDetailPageTitle).should('contain.text', courseName) - } - - navigateToLtiTools () { - cy.get(Courses.#ltiToolsTab).click() - } - - clickOnAddNewLtiToolButton () { - cy.get(Courses.#addNewToolButton).click() - } - - navigateToToolsTab () { - cy.get(Courses.#toolsTab).click() - } - - clickOnAddNewToolFAB () { - cy.get(Courses.#addToolButton).click() - } - - seeAddNewToolFAB () { - cy.get(Courses.#addToolButton).should('exist') - } - - seeNotAddNewToolFAB () { - cy.get(Courses.#addToolButton).should('not.exist') - } - - seeContextExternalToolConfiguratorPageTitle () { - cy.get(Courses.#contextExternalToolConfiguratorPageTitle).should('exist') - } - - clickOnToolConfigurationSelect () { - cy.get(Courses.#toolConfigurationSelect).click() - } - - enterAnToolNameInToolConfigurationSelect (toolName) { - cy.get(Courses.#toolConfigurationSelect).type(toolName) - } - - courseIsVisibleOnOverviewPage (courseName) { - cy.contains(courseName).should('be.visible').and('contain.text', courseName) - } - - courseIsNotVisibleOnOverviewPage (courseName) { - cy.contains(courseName).should('not.exist') - } - - canAddBigBlueButton () { - cy.get(Courses.#toolsList).should('be.visible') - } - - canNotAddBigBlueButton () { - cy.get(Courses.#toolsList).should('not.exist') - } - - clickOnCreateRoomFAB () { - cy.get(Courses.#createCourse).click() - } - - clickOnCreateContentFAB () { - cy.wait('@rooms_api') - cy.get(Courses.#createContent).click() - } - - clickOnNewTaskFAB () { - cy.get(Courses.#newTaskFAB).click() - cy.wait('@homework_api') - } - - contentIsVisibleOnCoursePage (taskTitle) { - // no cy.wait('@rooms_api') here as the reload takes care of this - cy.reload() // Reload is necessary because after deletion of a content element a message window with its title stays hidden in the DOM - .wait([ - '@public_api', - '@me_api', - '@roles_api', - '@schools_api', - '@userPermissions_api' - ]) - .then(interceptions => { - expect(interceptions[0].response.statusCode).to.equal(200) - expect(interceptions[1].state).to.equal('Complete') - expect(interceptions[1].response.statusCode).to.equal(200) - }) - cy.contains(taskTitle).should('be.visible') - } - - contentIsNotVisibleOnCoursePage (contentTitle) { - cy.reload() // Reload is necessary because after deletion of a content element a message window with its title stays hidden in the DOM - .wait(['@board_api', '@runtime_config_api', '@public_api']) - .then(interceptions => { - expect(interceptions[0].response.statusCode).to.equal(200) - expect(interceptions[1].response.statusCode).to.equal(200) - expect(interceptions[1].response.statusCode).to.equal(200) - }) - cy.contains(contentTitle).should('not.exist') - } - - openTask (taskTitle) { - // cy.wait('@rooms_api') dont needed as on vue page already where scenario is given - cy.get(Courses.#contentCardContent).contains(taskTitle).click() - cy.wait('@homework_api') - } - openThreeDotMenuForContent (contentTitle) { - cy.wait('@rooms_api') - cy.get(Courses.#contentCardContent) - .contains(contentTitle) - .parent() - .find('button') - .click() - } - - openThreeDotMenuForTopic (contentTitle) { - cy.wait('@rooms_api') - cy.contains(contentTitle).prev().find('button').click() - } - - openTopic (contentTitle) { - cy.contains(contentTitle).parent().click() - } - - clickDeleteInDotMenu () { - cy.get(Courses.#deleteButtonInDotMenu).click() - } - - clickDeleteInDotMenuOfTopic () { - cy.get(Courses.#deleteButtonInDotMenuOfTopic).click() - } - - clickEditInDotMenu (linkId) { - cy.get(Courses.#editButtonInDotMenu).click() - cy.wait('@homework_api') - } - - clickEditInDotMenuOfTopic () { - cy.get(Courses.#editButtonInDotMenuOfTopic).click() - } - - clickOnCancelInConfirmationWindow () { - cy.get(Courses.#dialogCancelButton).click() - } - - clickDeleteInConfirmationWindow () { - cy.get(Courses.#dialogConfirmButton).click() - } - - openCourseEditPage () { - cy.wait('@rooms_api') - cy.get(Courses.#dropDownCourse).parent().click() - cy.get(Courses.#btnCourseEdit).click() - } - - showCourseEditPage () { - cy.get(Courses.#pageTitle).should('exist') - } - - compareSubmittedTasksInformation (submittedTasks, contentTitle) { - cy.wait('@rooms_api') - cy.get(Courses.#contentCardContent) - .contains(contentTitle) - .parent() - .parent() - .find(Courses.#contentCardTaskInfoSubmissionsChip) - .should('contain', submittedTasks) - } - - compareGradedTasksInformation (gradedTasks, contentTitle) { - cy.get(Courses.#contentCardContent) - .contains(contentTitle) - .parent() - .parent() - .find(Courses.#contentCardTaskInfoGradingsChip) - .should('contain', gradedTasks) - } - - clickOnFinishTask (taskTitle) { - cy.wait('@rooms_api') - cy.get(Courses.#contentCardContent) - .contains(taskTitle) - .parent() - .parent() - .find(Courses.#contentCardTaskActions) - .find('button') - .click() - .wait(['@task_finish_api']) - } - - checkTaskCardDoesNotHaveButtons (taskTitle) { - cy.wait('@rooms_api') - cy.get(Courses.#contentCardContent) - .contains(taskTitle) - .parent() - .parent() - .find(Courses.#contentCardTaskActions) - .find('button') - .should('not.exist') - } - - checkTaskCardDoesHaveButtons (taskTitle) { - cy.wait('@rooms_api') - cy.get(Courses.#contentCardContent) - .contains(taskTitle) - .parent() - .parent() - .find(Courses.#contentCardTaskActions) - .find('button') - .should('be.visible') - } - - fillCourseCreationForm (new_course) { - cy.get(Courses.#courseTitle).type(new_course) - } - - clickOnCreateFAB () { - cy.get(Courses.#createFAB).click() - } - - fillCourseCreationForm (newCourseName) { - cy.get(Courses.#courseTitle).type(newCourseName) - } - - clickOnToCourseOverviewBtn () { - cy.get(Courses.#goToCourseOverviewButton).click() - } - - clickOnNextStepsBtnAfterEnteringRoomDetails () { - cy.get(Courses.#nextButton).click() - } - - clickOnDeleteButtonOnCourseEditPage () { - cy.get(Courses.#deleteButton).click() - } - - seeModalToConfirmCourseDeletion () { - cy.get(Courses.#courseDeleteConfirmationModal).should('exist') - } - - confirmCourseDeletionOnModal () { - cy.get(Courses.#confirmDeletionPopup).click({ multiple: true, force: true }) - } - - submitChangesAfterEditingCourse () { - cy.get(Courses.#btnSubmit).click() - } - - editCourseTitle (editedRoomName) { - cy.get(Courses.#courseName).clear().type(editedRoomName) - } - - editCourseDescription (editedRoomDesccription) { - cy.get(Courses.#courseDescription).clear().type(editedRoomDesccription) - } - - searchForARoom (roomName) { - cy.wait('@rooms_overview_api'); - cy.get(Courses.#searchFieldRoomOverview).type(roomName) - } - - clickOnNewTopicFAB () { - cy.get(Courses.#newTopicFAB) - .click() - .wait(['@alerts_api']) - .then(interceptions => { - expect(interceptions.response.statusCode).to.equal(200) - }) - } - - clearSubstituteTeacherField () { - cy.get(Courses.#addSubstituteTeacher).click().type('{selectall}{backspace}') - } - - addSubstituteTeacher (username) { - let userFirstName - let userLastName - switch (username) { - case 'teacher1': - userFirstName = Cypress.env('TEACHER_1_BRB_FIRST_NAME') - userLastName = Cypress.env('TEACHER_1_BRB_LAST_NAME') - break - case 'teacher2': - userFirstName = Cypress.env('TEACHER_2_BRB_FIRST_NAME') - userLastName = Cypress.env('TEACHER_2_BRB_LAST_NAME') - break - } - let userFullName = userLastName + ', ' + userFirstName - cy.get(Courses.#chosenResults).contains(userFullName).click() - cy.get(Courses.#chosenContainer).should('contain', userFullName) - } - - deleteAllCoursesMatchingName (roomName) { - cy.get('h1') - .eq(0) - .then($title => { - const htmlTitlePage = $title.text() - if (htmlTitlePage.includes('Kurse')) { - this.deleteCoursesByName('Kurs', roomName) - } else if (htmlTitlePage.includes('courses')) { - this.deleteCoursesByName('Course', roomName) - } else if (htmlTitlePage.includes('Cursos')) { - this.deleteCoursesByName('Curso', roomName) - } else if (htmlTitlePage.includes('Поточні')) { - this.deleteCoursesByName('Курс', roomName) + } + + clearSubstituteTeacherField () { + cy.get(Courses.#addSubstituteTeacher).click().type('{selectall}{backspace}') + } + + addSubstituteTeacher (username) { + let userFirstName + let userLastName + switch (username) { + case 'teacher1': + userFirstName = Cypress.env('TEACHER_1_BRB_FIRST_NAME') + userLastName = Cypress.env('TEACHER_1_BRB_LAST_NAME') + break + case 'teacher2': + userFirstName = Cypress.env('TEACHER_2_BRB_FIRST_NAME') + userLastName = Cypress.env('TEACHER_2_BRB_LAST_NAME') + break } - }) - } - - deleteCoursesByName (courseLabel, roomName) { - cy.get(`[class="rooms-container"]`).then($roomsContainer => { - if ( - $roomsContainer.find(`[aria-label="${courseLabel} ${roomName}"]`).length - ) { - cy.get(`[aria-label="${courseLabel} ${roomName}"]`).then($rooms => { - if ($rooms) { - cy.wrap($rooms).first().click() - this.openCourseEditPage() - cy.get(Courses.#deleteButton).should('exist').click() - cy.get(Courses.#confirmDeletionPopup).click({ - multiple: true, - force: true + let userFullName = userLastName + ', ' + userFirstName + cy.get(Courses.#chosenResults).contains(userFullName).click() + cy.get(Courses.#chosenContainer).should('contain', userFullName) + } + + deleteAllCoursesMatchingName (roomName) { + cy.get('h1') + .eq(0) + .then($title => { + const htmlTitlePage = $title.text() + if (htmlTitlePage.includes('Kurse')) { + this.deleteCoursesByName('Kurs', roomName) + } else if (htmlTitlePage.includes('courses')) { + this.deleteCoursesByName('Course', roomName) + } else if (htmlTitlePage.includes('Cursos')) { + this.deleteCoursesByName('Curso', roomName) + } else if (htmlTitlePage.includes('Поточні')) { + this.deleteCoursesByName('Курс', roomName) + } }) + } - if ($rooms.length > 1) { - this.deleteAllCoursesMatchingName(roomName) + deleteCoursesByName (courseLabel, roomName) { + cy.get(`[class="rooms-container"]`).then($roomsContainer => { + if ( + $roomsContainer.find(`[aria-label="${courseLabel} ${roomName}"]`).length + ) { + cy.get(`[aria-label="${courseLabel} ${roomName}"]`).then($rooms => { + if ($rooms) { + cy.wrap($rooms).first().click() + this.openCourseEditPage() + cy.get(Courses.#deleteButton).should('exist').click() + cy.get(Courses.#confirmDeletionPopup).click({ + multiple: true, + force: true + }) + + if ($rooms.length > 1) { + this.deleteAllCoursesMatchingName(roomName) + } + } + }) } - } }) - } - }) - } + } - checkIfGroupIsVisible (groupName) { - cy.get(Courses.#groupSelection).find('.chosen-choices').contains(groupName).should('be.visible'); - } - checkIfGroupIsNotVisible (groupName) { - cy.get(Courses.#groupSelection).find('.chosen-choices').contains(groupName).should('not.exist'); + checkIfGroupIsVisible (groupName) { + cy.get(Courses.#groupSelection).find('.chosen-choices').contains(groupName).should('be.visible'); + } +checkIfGroupIsNotVisible (groupName) { + cy.get(Courses.#groupSelection).find('.chosen-choices').contains(groupName).should('not.exist'); - } + } - checkIfStudentIsVisible (studentName) { - cy.get(Courses.#chosenStudents).find('.search-choice').children('span').should('contain', studentName); - } + checkIfStudentIsVisible (studentName) { + cy.get(Courses.#chosenStudents).find('.search-choice').children('span').should('contain', studentName); + } - checkIfStudentIsNotVisible (studentName) { - cy.get(Courses.#chosenStudents).should('not.contain', studentName); - } + checkIfStudentIsNotVisible (studentName) { + cy.get(Courses.#chosenStudents).should('not.contain', studentName); + } - addGroup (groupName) { - cy.get(Courses.#groupSelection).find('.chosen-choices').click(); - cy.get(Courses.#groupSelection).find('.chosen-results').contains(groupName).click(); - } + addGroup (groupName) { + cy.get(Courses.#groupSelection).find('.chosen-choices').click(); + cy.get(Courses.#groupSelection).find('.chosen-results').contains(groupName).click(); + } + + removeGroup (groupName) { + cy.get(Courses.#groupSelection).find('.chosen-choices').contains(groupName).siblings('a').click(); + } - removeGroup (groupName) { - cy.get(Courses.#groupSelection).find('.chosen-choices').contains(groupName).siblings('a').click(); - } + checkIfToolIsVisible(toolName) { + cy.get(Courses.#toolConfigurationSelectItem).should('not.contain', toolName); + } } export default Courses From 5ad4b98c63c5b992e768830467633e148239bd4f Mon Sep 17 00:00:00 2001 From: Malte Berg Date: Wed, 29 Nov 2023 15:42:30 +0100 Subject: [PATCH 3/8] add test --- .../course/toolCourseSteps.spec.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cypress/support/step_definition/course/toolCourseSteps.spec.js b/cypress/support/step_definition/course/toolCourseSteps.spec.js index 9ac8a73b..9a03f0e3 100644 --- a/cypress/support/step_definition/course/toolCourseSteps.spec.js +++ b/cypress/support/step_definition/course/toolCourseSteps.spec.js @@ -4,32 +4,36 @@ import Courses from '../../pages/course/pageCourses' const courses = new Courses() When('I click on the tools tab', () => { - courses.navigateToToolsTab() + courses.navigateToToolsTab() }) Then('I can see the button to add a tool', () => { - courses.seeAddNewToolFAB() + courses.seeAddNewToolFAB() }) Then('I cant see the button to add a tool', () => { - courses.seeNotAddNewToolFAB() + courses.seeNotAddNewToolFAB() }) When('I click on the button to add a tool', () => { - courses.clickOnAddNewToolFAB() + courses.clickOnAddNewToolFAB() }) Then('I can see the tool configuration page title', () => { - courses.seeContextExternalToolConfiguratorPageTitle() + courses.seeContextExternalToolConfiguratorPageTitle() }) When('I click on the tool configuration selection', () => { - courses.clickOnToolConfigurationSelect() + courses.clickOnToolConfigurationSelect() }) Then('I can enter {string} as tool name in the selection', toolName => { - courses.enterAnToolNameInToolConfigurationSelect(toolName) + courses.enterAnToolNameInToolConfigurationSelect(toolName) +}) + +Then('I can not see tool {string} in the tool selection list', toolName => { + courses.checkIfToolIsVisible(toolName) }) From 94294deeb563522bbee623ab4f7e6cdad753b39d Mon Sep 17 00:00:00 2001 From: Malte Berg Date: Fri, 1 Dec 2023 09:27:55 +0100 Subject: [PATCH 4/8] fix --- .../course/toolCourseSteps.spec.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cypress/support/step_definition/course/toolCourseSteps.spec.js b/cypress/support/step_definition/course/toolCourseSteps.spec.js index 9a03f0e3..c8c8f23f 100644 --- a/cypress/support/step_definition/course/toolCourseSteps.spec.js +++ b/cypress/support/step_definition/course/toolCourseSteps.spec.js @@ -4,36 +4,36 @@ import Courses from '../../pages/course/pageCourses' const courses = new Courses() When('I click on the tools tab', () => { - courses.navigateToToolsTab() + courses.navigateToToolsTab() }) Then('I can see the button to add a tool', () => { - courses.seeAddNewToolFAB() + courses.seeAddNewToolFAB() }) Then('I cant see the button to add a tool', () => { - courses.seeNotAddNewToolFAB() + courses.seeNotAddNewToolFAB() }) When('I click on the button to add a tool', () => { - courses.clickOnAddNewToolFAB() + courses.clickOnAddNewToolFAB() }) Then('I can see the tool configuration page title', () => { - courses.seeContextExternalToolConfiguratorPageTitle() + courses.seeContextExternalToolConfiguratorPageTitle() }) When('I click on the tool configuration selection', () => { - courses.clickOnToolConfigurationSelect() + courses.clickOnToolConfigurationSelect() }) Then('I can enter {string} as tool name in the selection', toolName => { - courses.enterAnToolNameInToolConfigurationSelect(toolName) + courses.enterAnToolNameInToolConfigurationSelect(toolName) }) Then('I can not see tool {string} in the tool selection list', toolName => { - courses.checkIfToolIsVisible(toolName) + courses.checkIfToolIsVisible(toolName) }) From 93105e47b80e6f0cb361c622961f998aa0d5ef65 Mon Sep 17 00:00:00 2001 From: Malte Berg Date: Fri, 1 Dec 2023 09:32:45 +0100 Subject: [PATCH 5/8] fix --- .../course/toolCourseSteps.spec.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cypress/support/step_definition/course/toolCourseSteps.spec.js b/cypress/support/step_definition/course/toolCourseSteps.spec.js index c8c8f23f..9a03f0e3 100644 --- a/cypress/support/step_definition/course/toolCourseSteps.spec.js +++ b/cypress/support/step_definition/course/toolCourseSteps.spec.js @@ -4,36 +4,36 @@ import Courses from '../../pages/course/pageCourses' const courses = new Courses() When('I click on the tools tab', () => { - courses.navigateToToolsTab() + courses.navigateToToolsTab() }) Then('I can see the button to add a tool', () => { - courses.seeAddNewToolFAB() + courses.seeAddNewToolFAB() }) Then('I cant see the button to add a tool', () => { - courses.seeNotAddNewToolFAB() + courses.seeNotAddNewToolFAB() }) When('I click on the button to add a tool', () => { - courses.clickOnAddNewToolFAB() + courses.clickOnAddNewToolFAB() }) Then('I can see the tool configuration page title', () => { - courses.seeContextExternalToolConfiguratorPageTitle() + courses.seeContextExternalToolConfiguratorPageTitle() }) When('I click on the tool configuration selection', () => { - courses.clickOnToolConfigurationSelect() + courses.clickOnToolConfigurationSelect() }) Then('I can enter {string} as tool name in the selection', toolName => { - courses.enterAnToolNameInToolConfigurationSelect(toolName) + courses.enterAnToolNameInToolConfigurationSelect(toolName) }) Then('I can not see tool {string} in the tool selection list', toolName => { - courses.checkIfToolIsVisible(toolName) + courses.checkIfToolIsVisible(toolName) }) From 9cdda17752a7b50d381474752c6998f2a4a5d5d3 Mon Sep 17 00:00:00 2001 From: MBergCap <111343628+MBergCap@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:37:27 +0100 Subject: [PATCH 6/8] fix indents --- .../course/toolCourseSteps.spec.js | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/cypress/support/step_definition/course/toolCourseSteps.spec.js b/cypress/support/step_definition/course/toolCourseSteps.spec.js index 9a03f0e3..6ee4d627 100644 --- a/cypress/support/step_definition/course/toolCourseSteps.spec.js +++ b/cypress/support/step_definition/course/toolCourseSteps.spec.js @@ -4,36 +4,40 @@ import Courses from '../../pages/course/pageCourses' const courses = new Courses() When('I click on the tools tab', () => { - courses.navigateToToolsTab() + courses.navigateToToolsTab() }) Then('I can see the button to add a tool', () => { - courses.seeAddNewToolFAB() + courses.seeAddNewToolFAB() }) Then('I cant see the button to add a tool', () => { - courses.seeNotAddNewToolFAB() + courses.seeNotAddNewToolFAB() }) When('I click on the button to add a tool', () => { - courses.clickOnAddNewToolFAB() + courses.clickOnAddNewToolFAB() }) Then('I can see the tool configuration page title', () => { - courses.seeContextExternalToolConfiguratorPageTitle() + courses.seeContextExternalToolConfiguratorPageTitle() }) When('I click on the tool configuration selection', () => { - courses.clickOnToolConfigurationSelect() + courses.clickOnToolConfigurationSelect() }) Then('I can enter {string} as tool name in the selection', toolName => { - courses.enterAnToolNameInToolConfigurationSelect(toolName) + courses.enterAnToolNameInToolConfigurationSelect(toolName) +}) + +Then('I can enter {string} as tool name in the selection', toolName => { + courses.enterAnToolNameInToolConfigurationSelect(toolName) }) Then('I can not see tool {string} in the tool selection list', toolName => { - courses.checkIfToolIsVisible(toolName) + courses.checkIfToolIsVisible(toolName) }) From 87e2facbdc10221c7c04a14cb9644902664c9cb8 Mon Sep 17 00:00:00 2001 From: MBergCap <111343628+MBergCap@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:41:15 +0100 Subject: [PATCH 7/8] fix indents --- cypress/support/pages/course/pageCourses.js | 1006 +++++++++---------- 1 file changed, 503 insertions(+), 503 deletions(-) diff --git a/cypress/support/pages/course/pageCourses.js b/cypress/support/pages/course/pageCourses.js index 0e9b5301..614f984f 100644 --- a/cypress/support/pages/course/pageCourses.js +++ b/cypress/support/pages/course/pageCourses.js @@ -1,522 +1,522 @@ 'use strict' class Courses { - static #courseTitle = '[data-testid="coursename"]' - static #nextButton = '[id="nextSection"]' - static #goToCourseOverviewButton = '[data-testid="courses-to-overview-btn"]' - static #deleteButton = '[data-method="DELETE"]' - static #confirmDeletionPopup = '[data-testid="modal_delete_course_button"]' - static #btnSubmit = '[data-testid="modal-edit-course-button"]' - static #courseDescription = '[id="courseDescription"]' - static #courseName = '[name="name"]' - static #createFAB = '[name="fab-icon"]' - static #newTopicFAB = '[data-testid="fab_button_add_lesson"]' - static #searchFieldRoomOverview = '[data-testid="search-field"]' - static #mainContent = '[id="main-content"]' - static #createCourse = '[data-testid="add-course-button"]' - static #createContent = '[data-testid="add-content-button"]' - static #ltiToolsTab = '[data-testid="tools"]' - static #toolsList = '[data-testid="course_tool_list_add_tool"]' - static #courseOverviewNavigationButton = '[data-testid="Course-Overview"]' - static #addNewToolButton = '[data-testid="add_new_tool"]' - static #newTaskFAB = '[data-testid="fab_button_add_task"]' - static #dialogConfirmButton = '[data-testid="dialog-confirm"]' - static #dialogCancelButton = '[data-testid="dialog-cancel"]' - static #deleteButtonInDotMenu = - '[data-testid="content-card-task-menu-remove"]' - static #deleteButtonInDotMenuOfTopic = - '[data-testid="content-card-lesson-menu-remove"]' - static #editButtonInDotMenu = '[data-testid="content-card-task-menu-edit"]' - static #editButtonInDotMenuOfTopic = - '[data-testid="content-card-lesson-menu-edit"]' - static #contentCardContent = '[data-testid="content-card-task-content"]' - static #contentCardTopic = '[data-testid="content-card-lesson-content"]' - static #contentCardTaskActions = '[data-testid="content-card-task-actions"]' - static #dropDownCourse = '[data-testid="title-menu"]' - static #btnCourseEdit = '[data-testid="title-menu-edit-delete"]' - static #pageTitle = '[id="page-title"]' - static #contentCardTaskInfoSubmissionsChip = - '[data-testid="room-detail-task-chip-submitted"]' - static #contentCardTaskInfoGradingsChip = - '[data-testid="room-detail-task-chip-graded"]' - static #addSubstituteTeacher = '[id="substituteTeacher_chosen"]' - static #chosenResults = '.chosen-results li' - static #chosenContainer = '.chosen-container span' - static #roomSearrchBox = '[data-testid="search-field"]' - static #selectRoomColour = '[data-testid="color-picker"]' - static #RoomColourAsRed = '[aria-label="#D50000"]' - static #chosenCourseTeacher = '[id="courseTeacher_chosen"]' - static #chosenSubstituteTeacher = '[id="courseSubstitute_chosen"]' - static #courseStartDatePicker = '[data-testid="date_start"]' - static #courseEndDatePicker = '[data-testid="form-date-input-untilDate"]' - static #courseTimeTableContainer = '[data-timesref="#timesContainer"]' - static #addClassToCourseSelectionBox = '[id="addClassesToCourse_chosen"]' - static #addStudentToCourseSelectionBox = '[id="addStudentsToCourse_chosen"]' - static #nextButtonToCreateCourseOnParticipationDeatilStep = - '[id="nextSection"]' - static #sectionThreeAreaOnCourseCreationPage = - '[data-testid="section-3-area"]' - static #sectionOneAreaOnCourseCreationPage = '[data-testid="section-1-area"]' - static #sectionTwoAreaOnCourseCreationPage = '[data-testid="section-2-area"]' - static #courseDeleteConfirmationModal = '[data-testid="popup-title"]' - static #courseTitleInRoomoverview = '[data-testid="course-title"]' - static #learningContentTab = '[data-testid="learnContent-tab"]' - static #courseDetailPageTitle = '[data-testid="courses-course-title"]' - - static #toolsTab = '[data-testid="tools-tab"]' - static #addToolButton = '[data-testid="add-tool-button"]' - static #toolConfigurationSelect = '[data-testid="configuration-select"]' - static #contextExternalToolConfiguratorPageTitle = '[data-testid="context-external-tool-configurator-title"]' - static #groupSelection = '[id="classId_chosen"]' - static #chosenStudents = '[id="studentsId_chosen"] > .chosen-choices' - static #toolConfigurationSelectItem = '[data-testId="configuration-select-item"]' - - seeSectionOneAreaOnCourseCreatePage() { - cy.get(Courses.#sectionOneAreaOnCourseCreationPage).should('exist') - } - - seeSectionTwoAreaOnCourseCreatePage () { - cy.get(Courses.#sectionTwoAreaOnCourseCreationPage).should('exist') - } - - seeSelectedDefaultTeacher (defaultTeacherName) { - cy.get(Courses.#chosenCourseTeacher).contains(defaultTeacherName) - } - - seeSubstituteTeacherSelectionBox () { - cy.get(Courses.#chosenSubstituteTeacher).should('exist') - } - - seeDatePickersForCourseInSchoolYear () { - cy.get(Courses.#courseStartDatePicker).should('exist') - cy.get(Courses.#courseEndDatePicker).should('exist') - } - - seeCreateCourseTimeTableContainer () { - cy.get(Courses.#courseTimeTableContainer).should('exist') - } - - seeSelectionBoxToSelectClass () { - cy.get(Courses.#addClassToCourseSelectionBox).should('exist') - } - - seeSelectioinBoxToSelectStudent () { - cy.get(Courses.#addStudentToCourseSelectionBox).should('exist') - } - - clickOnNextStepButtonOnCourseParticipationDetail () { - cy.get(Courses.#nextButtonToCreateCourseOnParticipationDeatilStep).click() - } - - seeCourseCreationFinishPageSectionThree () { - cy.get(Courses.#sectionThreeAreaOnCourseCreationPage).should('exist') - } - - selectRoomColour () { - cy.get(Courses.#RoomColourAsRed).click() - } - - seeRoomSearchBoxOnRoomOverview () { - cy.get(Courses.#roomSearrchBox).should('be.exist') - } - - courseIsVisiblOnOverviewPage (courseName) { - cy.contains(courseName).should('be.visible').and('contain.text', courseName) - } - - courseIsNotVisiblOnOverviewPage (courseName) { - cy.contains(courseName).should('not.exist') - } - - navigateToRoomsOverview () { - cy.get(Courses.#courseOverviewNavigationButton).click() - } - - navigateToRoomBoard (roomName) { - cy.contains(Courses.#courseTitleInRoomoverview, roomName) - .should('be.visible') - .then(title => { - cy.wrap(title) - .prev() - .click() - .then(() => { - return new Cypress.Promise((resolve, reject) => { - try { - setTimeout(() => { - cy.wait(['@alert_api', '@board_api', '@userPermissions_api']) - .get(Courses.#learningContentTab) - .should('have.attr', 'aria-selected', 'true') - resolve() - return - }, 1000) - } catch (error) { - reject(error) - } - }) - }) + static #courseTitle = '[data-testid="coursename"]' + static #nextButton = '[id="nextSection"]' + static #goToCourseOverviewButton = '[data-testid="courses-to-overview-btn"]' + static #deleteButton = '[data-method="DELETE"]' + static #confirmDeletionPopup = '[data-testid="modal_delete_course_button"]' + static #btnSubmit = '[data-testid="modal-edit-course-button"]' + static #courseDescription = '[id="courseDescription"]' + static #courseName = '[name="name"]' + static #createFAB = '[name="fab-icon"]' + static #newTopicFAB = '[data-testid="fab_button_add_lesson"]' + static #searchFieldRoomOverview = '[data-testid="search-field"]' + static #mainContent = '[id="main-content"]' + static #createCourse = '[data-testid="add-course-button"]' + static #createContent = '[data-testid="add-content-button"]' + static #ltiToolsTab = '[data-testid="tools"]' + static #toolsList = '[data-testid="course_tool_list_add_tool"]' + static #courseOverviewNavigationButton = '[data-testid="Course-Overview"]' + static #addNewToolButton = '[data-testid="add_new_tool"]' + static #newTaskFAB = '[data-testid="fab_button_add_task"]' + static #dialogConfirmButton = '[data-testid="dialog-confirm"]' + static #dialogCancelButton = '[data-testid="dialog-cancel"]' + static #deleteButtonInDotMenu = + '[data-testid="content-card-task-menu-remove"]' + static #deleteButtonInDotMenuOfTopic = + '[data-testid="content-card-lesson-menu-remove"]' + static #editButtonInDotMenu = '[data-testid="content-card-task-menu-edit"]' + static #editButtonInDotMenuOfTopic = + '[data-testid="content-card-lesson-menu-edit"]' + static #contentCardContent = '[data-testid="content-card-task-content"]' + static #contentCardTopic = '[data-testid="content-card-lesson-content"]' + static #contentCardTaskActions = '[data-testid="content-card-task-actions"]' + static #dropDownCourse = '[data-testid="title-menu"]' + static #btnCourseEdit = '[data-testid="title-menu-edit-delete"]' + static #pageTitle = '[id="page-title"]' + static #contentCardTaskInfoSubmissionsChip = + '[data-testid="room-detail-task-chip-submitted"]' + static #contentCardTaskInfoGradingsChip = + '[data-testid="room-detail-task-chip-graded"]' + static #addSubstituteTeacher = '[id="substituteTeacher_chosen"]' + static #chosenResults = '.chosen-results li' + static #chosenContainer = '.chosen-container span' + static #roomSearrchBox = '[data-testid="search-field"]' + static #selectRoomColour = '[data-testid="color-picker"]' + static #RoomColourAsRed = '[aria-label="#D50000"]' + static #chosenCourseTeacher = '[id="courseTeacher_chosen"]' + static #chosenSubstituteTeacher = '[id="courseSubstitute_chosen"]' + static #courseStartDatePicker = '[data-testid="date_start"]' + static #courseEndDatePicker = '[data-testid="form-date-input-untilDate"]' + static #courseTimeTableContainer = '[data-timesref="#timesContainer"]' + static #addClassToCourseSelectionBox = '[id="addClassesToCourse_chosen"]' + static #addStudentToCourseSelectionBox = '[id="addStudentsToCourse_chosen"]' + static #nextButtonToCreateCourseOnParticipationDeatilStep = + '[id="nextSection"]' + static #sectionThreeAreaOnCourseCreationPage = + '[data-testid="section-3-area"]' + static #sectionOneAreaOnCourseCreationPage = '[data-testid="section-1-area"]' + static #sectionTwoAreaOnCourseCreationPage = '[data-testid="section-2-area"]' + static #courseDeleteConfirmationModal = '[data-testid="popup-title"]' + static #courseTitleInRoomoverview = '[data-testid="course-title"]' + static #learningContentTab = '[data-testid="learnContent-tab"]' + static #courseDetailPageTitle = '[data-testid="courses-course-title"]' + + static #toolsTab = '[data-testid="tools-tab"]' + static #addToolButton = '[data-testid="add-tool-button"]' + static #toolConfigurationSelect = '[data-testid="configuration-select"]' + static #contextExternalToolConfiguratorPageTitle = '[data-testid="context-external-tool-configurator-title"]' + static #groupSelection = '[id="classId_chosen"]' + static #chosenStudents= '[id="studentsId_chosen"] > .chosen-choices' + static #toolConfigurationSelectItem = '[data-testId="configuration-select-item"]' + + seeSectionOneAreaOnCourseCreatePage () { + cy.get(Courses.#sectionOneAreaOnCourseCreationPage).should('exist') + } + + seeSectionTwoAreaOnCourseCreatePage () { + cy.get(Courses.#sectionTwoAreaOnCourseCreationPage).should('exist') + } + + seeSelectedDefaultTeacher (defaultTeacherName) { + cy.get(Courses.#chosenCourseTeacher).contains(defaultTeacherName) + } + + seeSubstituteTeacherSelectionBox () { + cy.get(Courses.#chosenSubstituteTeacher).should('exist') + } + + seeDatePickersForCourseInSchoolYear () { + cy.get(Courses.#courseStartDatePicker).should('exist') + cy.get(Courses.#courseEndDatePicker).should('exist') + } + + seeCreateCourseTimeTableContainer () { + cy.get(Courses.#courseTimeTableContainer).should('exist') + } + + seeSelectionBoxToSelectClass () { + cy.get(Courses.#addClassToCourseSelectionBox).should('exist') + } + + seeSelectioinBoxToSelectStudent () { + cy.get(Courses.#addStudentToCourseSelectionBox).should('exist') + } + + clickOnNextStepButtonOnCourseParticipationDetail () { + cy.get(Courses.#nextButtonToCreateCourseOnParticipationDeatilStep).click() + } + + seeCourseCreationFinishPageSectionThree () { + cy.get(Courses.#sectionThreeAreaOnCourseCreationPage).should('exist') + } + + selectRoomColour () { + cy.get(Courses.#RoomColourAsRed).click() + } + + seeRoomSearchBoxOnRoomOverview () { + cy.get(Courses.#roomSearrchBox).should('be.exist') + } + + courseIsVisiblOnOverviewPage (courseName) { + cy.contains(courseName).should('be.visible').and('contain.text', courseName) + } + + courseIsNotVisiblOnOverviewPage (courseName) { + cy.contains(courseName).should('not.exist') + } + + navigateToRoomsOverview () { + cy.get(Courses.#courseOverviewNavigationButton).click() + } + + navigateToRoomBoard (roomName) { + cy.contains(Courses.#courseTitleInRoomoverview, roomName) + .should('be.visible') + .then(title => { + cy.wrap(title) + .prev() + .click() + .then(() => { + return new Cypress.Promise((resolve, reject) => { + try { + setTimeout(() => { + cy.wait(['@alert_api', '@board_api', '@userPermissions_api']) + .get(Courses.#learningContentTab) + .should('have.attr', 'aria-selected', 'true') + resolve() + return + }, 1000) + } catch (error) { + reject(error) + } }) - } - - showRoomPage (courseName) { - cy.wait('@rooms_api') - cy.get(Courses.#courseDetailPageTitle).should('contain.text', courseName) - } - - navigateToLtiTools () { - cy.get(Courses.#ltiToolsTab).click() - } - - clickOnAddNewLtiToolButton () { - cy.get(Courses.#addNewToolButton).click() - } - - navigateToToolsTab () { - cy.get(Courses.#toolsTab).click() - } - - clickOnAddNewToolFAB () { - cy.get(Courses.#addToolButton).click() - } - - seeAddNewToolFAB () { - cy.get(Courses.#addToolButton).should('exist') - } - - seeNotAddNewToolFAB () { - cy.get(Courses.#addToolButton).should('not.exist') - } - - seeContextExternalToolConfiguratorPageTitle () { - cy.get(Courses.#contextExternalToolConfiguratorPageTitle).should('exist') - } - - clickOnToolConfigurationSelect () { - cy.get(Courses.#toolConfigurationSelect).click() - } - - enterAnToolNameInToolConfigurationSelect (toolName) { - cy.get(Courses.#toolConfigurationSelect).type(toolName) - } - - courseIsVisibleOnOverviewPage (courseName) { - cy.contains(courseName).should('be.visible').and('contain.text', courseName) - } - - courseIsNotVisibleOnOverviewPage (courseName) { - cy.contains(courseName).should('not.exist') - } - - canAddBigBlueButton () { - cy.get(Courses.#toolsList).should('be.visible') - } - - canNotAddBigBlueButton () { - cy.get(Courses.#toolsList).should('not.exist') - } - - clickOnCreateRoomFAB () { - cy.get(Courses.#createCourse).click() - } - - clickOnCreateContentFAB () { - cy.wait('@rooms_api') - cy.get(Courses.#createContent).click() - } - - clickOnNewTaskFAB () { - cy.get(Courses.#newTaskFAB).click() - cy.wait('@homework_api') - } - - contentIsVisibleOnCoursePage (taskTitle) { - // no cy.wait('@rooms_api') here as the reload takes care of this - cy.reload() // Reload is necessary because after deletion of a content element a message window with its title stays hidden in the DOM - .wait([ - '@public_api', - '@me_api', - '@roles_api', - '@schools_api', - '@userPermissions_api' - ]) - .then(interceptions => { - expect(interceptions[0].response.statusCode).to.equal(200) - expect(interceptions[1].state).to.equal('Complete') - expect(interceptions[1].response.statusCode).to.equal(200) - }) - cy.contains(taskTitle).should('be.visible') - } - - contentIsNotVisibleOnCoursePage (contentTitle) { - cy.reload() // Reload is necessary because after deletion of a content element a message window with its title stays hidden in the DOM - .wait(['@board_api', '@runtime_config_api', '@public_api']) - .then(interceptions => { - expect(interceptions[0].response.statusCode).to.equal(200) - expect(interceptions[1].response.statusCode).to.equal(200) - expect(interceptions[1].response.statusCode).to.equal(200) - }) - cy.contains(contentTitle).should('not.exist') - } - - openTask (taskTitle) { - // cy.wait('@rooms_api') dont needed as on vue page already where scenario is given - cy.get(Courses.#contentCardContent).contains(taskTitle).click() - cy.wait('@homework_api') - } -openThreeDotMenuForContent (contentTitle) { - cy.wait('@rooms_api') - cy.get(Courses.#contentCardContent) - .contains(contentTitle) - .parent() - .find('button') - .click() - } - - openThreeDotMenuForTopic (contentTitle) { - cy.wait('@rooms_api') - cy.contains(contentTitle).prev().find('button').click() - } - - openTopic (contentTitle) { - cy.contains(contentTitle).parent().click() - } - - clickDeleteInDotMenu () { - cy.get(Courses.#deleteButtonInDotMenu).click() - } - - clickDeleteInDotMenuOfTopic () { - cy.get(Courses.#deleteButtonInDotMenuOfTopic).click() - } - - clickEditInDotMenu (linkId) { - cy.get(Courses.#editButtonInDotMenu).click() - cy.wait('@homework_api') - } - - clickEditInDotMenuOfTopic () { - cy.get(Courses.#editButtonInDotMenuOfTopic).click() - } - - clickOnCancelInConfirmationWindow () { - cy.get(Courses.#dialogCancelButton).click() - } - - clickDeleteInConfirmationWindow () { - cy.get(Courses.#dialogConfirmButton).click() - } - - openCourseEditPage () { - cy.wait('@rooms_api') - cy.get(Courses.#dropDownCourse).parent().click() - cy.get(Courses.#btnCourseEdit).click() - } - - showCourseEditPage () { - cy.get(Courses.#pageTitle).should('exist') - } - - compareSubmittedTasksInformation (submittedTasks, contentTitle) { - cy.wait('@rooms_api') - cy.get(Courses.#contentCardContent) - .contains(contentTitle) - .parent() - .parent() - .find(Courses.#contentCardTaskInfoSubmissionsChip) - .should('contain', submittedTasks) - } - - compareGradedTasksInformation (gradedTasks, contentTitle) { - cy.get(Courses.#contentCardContent) - .contains(contentTitle) - .parent() - .parent() - .find(Courses.#contentCardTaskInfoGradingsChip) - .should('contain', gradedTasks) - } - - clickOnFinishTask (taskTitle) { - cy.wait('@rooms_api') - cy.get(Courses.#contentCardContent) - .contains(taskTitle) - .parent() - .parent() - .find(Courses.#contentCardTaskActions) - .find('button') - .click() - .wait(['@task_finish_api']) - } - - checkTaskCardDoesNotHaveButtons (taskTitle) { - cy.wait('@rooms_api') - cy.get(Courses.#contentCardContent) - .contains(taskTitle) - .parent() - .parent() - .find(Courses.#contentCardTaskActions) - .find('button') - .should('not.exist') - } - - checkTaskCardDoesHaveButtons (taskTitle) { - cy.wait('@rooms_api') - cy.get(Courses.#contentCardContent) - .contains(taskTitle) - .parent() - .parent() - .find(Courses.#contentCardTaskActions) - .find('button') - .should('be.visible') - } - - fillCourseCreationForm (new_course) { - cy.get(Courses.#courseTitle).type(new_course) - } - - clickOnCreateFAB () { - cy.get(Courses.#createFAB).click() - } - - fillCourseCreationForm (newCourseName) { - cy.get(Courses.#courseTitle).type(newCourseName) - } - - clickOnToCourseOverviewBtn () { - cy.get(Courses.#goToCourseOverviewButton).click() - } - - clickOnNextStepsBtnAfterEnteringRoomDetails () { - cy.get(Courses.#nextButton).click() - } - - clickOnDeleteButtonOnCourseEditPage () { - cy.get(Courses.#deleteButton).click() - } - - seeModalToConfirmCourseDeletion () { - cy.get(Courses.#courseDeleteConfirmationModal).should('exist') - } - - confirmCourseDeletionOnModal () { - cy.get(Courses.#confirmDeletionPopup).click({ multiple: true, force: true }) - } - - submitChangesAfterEditingCourse () { - cy.get(Courses.#btnSubmit).click() - } - - editCourseTitle (editedRoomName) { - cy.get(Courses.#courseName).clear().type(editedRoomName) - } - - editCourseDescription (editedRoomDesccription) { - cy.get(Courses.#courseDescription).clear().type(editedRoomDesccription) - } - - searchForARoom (roomName) { - cy.wait('@rooms_overview_api'); - cy.get(Courses.#searchFieldRoomOverview).type(roomName) - } - - clickOnNewTopicFAB () { - cy.get(Courses.#newTopicFAB) - .click() - .wait(['@alerts_api']) - .then(interceptions => { - expect(interceptions.response.statusCode).to.equal(200) - }) - } - - clearSubstituteTeacherField () { - cy.get(Courses.#addSubstituteTeacher).click().type('{selectall}{backspace}') - } - - addSubstituteTeacher (username) { - let userFirstName - let userLastName - switch (username) { - case 'teacher1': - userFirstName = Cypress.env('TEACHER_1_BRB_FIRST_NAME') - userLastName = Cypress.env('TEACHER_1_BRB_LAST_NAME') - break - case 'teacher2': - userFirstName = Cypress.env('TEACHER_2_BRB_FIRST_NAME') - userLastName = Cypress.env('TEACHER_2_BRB_LAST_NAME') - break + }) + }) + } + + showRoomPage (courseName) { + cy.wait('@rooms_api') + cy.get(Courses.#courseDetailPageTitle).should('contain.text', courseName) + } + + navigateToLtiTools () { + cy.get(Courses.#ltiToolsTab).click() + } + + clickOnAddNewLtiToolButton () { + cy.get(Courses.#addNewToolButton).click() + } + + navigateToToolsTab () { + cy.get(Courses.#toolsTab).click() + } + + clickOnAddNewToolFAB () { + cy.get(Courses.#addToolButton).click() + } + + seeAddNewToolFAB () { + cy.get(Courses.#addToolButton).should('exist') + } + + seeNotAddNewToolFAB () { + cy.get(Courses.#addToolButton).should('not.exist') + } + + seeContextExternalToolConfiguratorPageTitle () { + cy.get(Courses.#contextExternalToolConfiguratorPageTitle).should('exist') + } + + clickOnToolConfigurationSelect () { + cy.get(Courses.#toolConfigurationSelect).click() + } + + enterAnToolNameInToolConfigurationSelect (toolName) { + cy.get(Courses.#toolConfigurationSelect).type(toolName) + } + + courseIsVisibleOnOverviewPage (courseName) { + cy.contains(courseName).should('be.visible').and('contain.text', courseName) + } + + courseIsNotVisibleOnOverviewPage (courseName) { + cy.contains(courseName).should('not.exist') + } + + canAddBigBlueButton () { + cy.get(Courses.#toolsList).should('be.visible') + } + + canNotAddBigBlueButton () { + cy.get(Courses.#toolsList).should('not.exist') + } + + clickOnCreateRoomFAB () { + cy.get(Courses.#createCourse).click() + } + + clickOnCreateContentFAB () { + cy.wait('@rooms_api') + cy.get(Courses.#createContent).click() + } + + clickOnNewTaskFAB () { + cy.get(Courses.#newTaskFAB).click() + cy.wait('@homework_api') + } + + contentIsVisibleOnCoursePage (taskTitle) { + // no cy.wait('@rooms_api') here as the reload takes care of this + cy.reload() // Reload is necessary because after deletion of a content element a message window with its title stays hidden in the DOM + .wait([ + '@public_api', + '@me_api', + '@roles_api', + '@schools_api', + '@userPermissions_api' + ]) + .then(interceptions => { + expect(interceptions[0].response.statusCode).to.equal(200) + expect(interceptions[1].state).to.equal('Complete') + expect(interceptions[1].response.statusCode).to.equal(200) + }) + cy.contains(taskTitle).should('be.visible') + } + + contentIsNotVisibleOnCoursePage (contentTitle) { + cy.reload() // Reload is necessary because after deletion of a content element a message window with its title stays hidden in the DOM + .wait(['@board_api', '@runtime_config_api', '@public_api']) + .then(interceptions => { + expect(interceptions[0].response.statusCode).to.equal(200) + expect(interceptions[1].response.statusCode).to.equal(200) + expect(interceptions[1].response.statusCode).to.equal(200) + }) + cy.contains(contentTitle).should('not.exist') + } + + openTask (taskTitle) { + // cy.wait('@rooms_api') dont needed as on vue page already where scenario is given + cy.get(Courses.#contentCardContent).contains(taskTitle).click() + cy.wait('@homework_api') + } + openThreeDotMenuForContent (contentTitle) { + cy.wait('@rooms_api') + cy.get(Courses.#contentCardContent) + .contains(contentTitle) + .parent() + .find('button') + .click() + } + + openThreeDotMenuForTopic (contentTitle) { + cy.wait('@rooms_api') + cy.contains(contentTitle).prev().find('button').click() + } + + openTopic (contentTitle) { + cy.contains(contentTitle).parent().click() + } + + clickDeleteInDotMenu () { + cy.get(Courses.#deleteButtonInDotMenu).click() + } + + clickDeleteInDotMenuOfTopic () { + cy.get(Courses.#deleteButtonInDotMenuOfTopic).click() + } + + clickEditInDotMenu (linkId) { + cy.get(Courses.#editButtonInDotMenu).click() + cy.wait('@homework_api') + } + + clickEditInDotMenuOfTopic () { + cy.get(Courses.#editButtonInDotMenuOfTopic).click() + } + + clickOnCancelInConfirmationWindow () { + cy.get(Courses.#dialogCancelButton).click() + } + + clickDeleteInConfirmationWindow () { + cy.get(Courses.#dialogConfirmButton).click() + } + + openCourseEditPage () { + cy.wait('@rooms_api') + cy.get(Courses.#dropDownCourse).parent().click() + cy.get(Courses.#btnCourseEdit).click() + } + + showCourseEditPage () { + cy.get(Courses.#pageTitle).should('exist') + } + + compareSubmittedTasksInformation (submittedTasks, contentTitle) { + cy.wait('@rooms_api') + cy.get(Courses.#contentCardContent) + .contains(contentTitle) + .parent() + .parent() + .find(Courses.#contentCardTaskInfoSubmissionsChip) + .should('contain', submittedTasks) + } + + compareGradedTasksInformation (gradedTasks, contentTitle) { + cy.get(Courses.#contentCardContent) + .contains(contentTitle) + .parent() + .parent() + .find(Courses.#contentCardTaskInfoGradingsChip) + .should('contain', gradedTasks) + } + + clickOnFinishTask (taskTitle) { + cy.wait('@rooms_api') + cy.get(Courses.#contentCardContent) + .contains(taskTitle) + .parent() + .parent() + .find(Courses.#contentCardTaskActions) + .find('button') + .click() + .wait(['@task_finish_api']) + } + + checkTaskCardDoesNotHaveButtons (taskTitle) { + cy.wait('@rooms_api') + cy.get(Courses.#contentCardContent) + .contains(taskTitle) + .parent() + .parent() + .find(Courses.#contentCardTaskActions) + .find('button') + .should('not.exist') + } + + checkTaskCardDoesHaveButtons (taskTitle) { + cy.wait('@rooms_api') + cy.get(Courses.#contentCardContent) + .contains(taskTitle) + .parent() + .parent() + .find(Courses.#contentCardTaskActions) + .find('button') + .should('be.visible') + } + + fillCourseCreationForm (new_course) { + cy.get(Courses.#courseTitle).type(new_course) + } + + clickOnCreateFAB () { + cy.get(Courses.#createFAB).click() + } + + fillCourseCreationForm (newCourseName) { + cy.get(Courses.#courseTitle).type(newCourseName) + } + + clickOnToCourseOverviewBtn () { + cy.get(Courses.#goToCourseOverviewButton).click() + } + + clickOnNextStepsBtnAfterEnteringRoomDetails () { + cy.get(Courses.#nextButton).click() + } + + clickOnDeleteButtonOnCourseEditPage () { + cy.get(Courses.#deleteButton).click() + } + + seeModalToConfirmCourseDeletion () { + cy.get(Courses.#courseDeleteConfirmationModal).should('exist') + } + + confirmCourseDeletionOnModal () { + cy.get(Courses.#confirmDeletionPopup).click({ multiple: true, force: true }) + } + + submitChangesAfterEditingCourse () { + cy.get(Courses.#btnSubmit).click() + } + + editCourseTitle (editedRoomName) { + cy.get(Courses.#courseName).clear().type(editedRoomName) + } + + editCourseDescription (editedRoomDesccription) { + cy.get(Courses.#courseDescription).clear().type(editedRoomDesccription) + } + + searchForARoom (roomName) { + cy.wait('@rooms_overview_api'); + cy.get(Courses.#searchFieldRoomOverview).type(roomName) + } + + clickOnNewTopicFAB () { + cy.get(Courses.#newTopicFAB) + .click() + .wait(['@alerts_api']) + .then(interceptions => { + expect(interceptions.response.statusCode).to.equal(200) + }) + } + + clearSubstituteTeacherField () { + cy.get(Courses.#addSubstituteTeacher).click().type('{selectall}{backspace}') + } + + addSubstituteTeacher (username) { + let userFirstName + let userLastName + switch (username) { + case 'teacher1': + userFirstName = Cypress.env('TEACHER_1_BRB_FIRST_NAME') + userLastName = Cypress.env('TEACHER_1_BRB_LAST_NAME') + break + case 'teacher2': + userFirstName = Cypress.env('TEACHER_2_BRB_FIRST_NAME') + userLastName = Cypress.env('TEACHER_2_BRB_LAST_NAME') + break + } + let userFullName = userLastName + ', ' + userFirstName + cy.get(Courses.#chosenResults).contains(userFullName).click() + cy.get(Courses.#chosenContainer).should('contain', userFullName) + } + + deleteAllCoursesMatchingName (roomName) { + cy.get('h1') + .eq(0) + .then($title => { + const htmlTitlePage = $title.text() + if (htmlTitlePage.includes('Kurse')) { + this.deleteCoursesByName('Kurs', roomName) + } else if (htmlTitlePage.includes('courses')) { + this.deleteCoursesByName('Course', roomName) + } else if (htmlTitlePage.includes('Cursos')) { + this.deleteCoursesByName('Curso', roomName) + } else if (htmlTitlePage.includes('Поточні')) { + this.deleteCoursesByName('Курс', roomName) } - let userFullName = userLastName + ', ' + userFirstName - cy.get(Courses.#chosenResults).contains(userFullName).click() - cy.get(Courses.#chosenContainer).should('contain', userFullName) - } - - deleteAllCoursesMatchingName (roomName) { - cy.get('h1') - .eq(0) - .then($title => { - const htmlTitlePage = $title.text() - if (htmlTitlePage.includes('Kurse')) { - this.deleteCoursesByName('Kurs', roomName) - } else if (htmlTitlePage.includes('courses')) { - this.deleteCoursesByName('Course', roomName) - } else if (htmlTitlePage.includes('Cursos')) { - this.deleteCoursesByName('Curso', roomName) - } else if (htmlTitlePage.includes('Поточні')) { - this.deleteCoursesByName('Курс', roomName) - } + }) + } + + deleteCoursesByName (courseLabel, roomName) { + cy.get(`[class="rooms-container"]`).then($roomsContainer => { + if ( + $roomsContainer.find(`[aria-label="${courseLabel} ${roomName}"]`).length + ) { + cy.get(`[aria-label="${courseLabel} ${roomName}"]`).then($rooms => { + if ($rooms) { + cy.wrap($rooms).first().click() + this.openCourseEditPage() + cy.get(Courses.#deleteButton).should('exist').click() + cy.get(Courses.#confirmDeletionPopup).click({ + multiple: true, + force: true }) - } - deleteCoursesByName (courseLabel, roomName) { - cy.get(`[class="rooms-container"]`).then($roomsContainer => { - if ( - $roomsContainer.find(`[aria-label="${courseLabel} ${roomName}"]`).length - ) { - cy.get(`[aria-label="${courseLabel} ${roomName}"]`).then($rooms => { - if ($rooms) { - cy.wrap($rooms).first().click() - this.openCourseEditPage() - cy.get(Courses.#deleteButton).should('exist').click() - cy.get(Courses.#confirmDeletionPopup).click({ - multiple: true, - force: true - }) - - if ($rooms.length > 1) { - this.deleteAllCoursesMatchingName(roomName) - } - } - }) + if ($rooms.length > 1) { + this.deleteAllCoursesMatchingName(roomName) } + } }) - } + } + }) + } - checkIfGroupIsVisible (groupName) { - cy.get(Courses.#groupSelection).find('.chosen-choices').contains(groupName).should('be.visible'); - } -checkIfGroupIsNotVisible (groupName) { - cy.get(Courses.#groupSelection).find('.chosen-choices').contains(groupName).should('not.exist'); + checkIfGroupIsVisible (groupName) { + cy.get(Courses.#groupSelection).find('.chosen-choices').contains(groupName).should('be.visible'); + } + checkIfGroupIsNotVisible (groupName) { + cy.get(Courses.#groupSelection).find('.chosen-choices').contains(groupName).should('not.exist'); - } + } - checkIfStudentIsVisible (studentName) { - cy.get(Courses.#chosenStudents).find('.search-choice').children('span').should('contain', studentName); - } + checkIfStudentIsVisible (studentName) { + cy.get(Courses.#chosenStudents).find('.search-choice').children('span').should('contain', studentName); + } - checkIfStudentIsNotVisible (studentName) { - cy.get(Courses.#chosenStudents).should('not.contain', studentName); - } + checkIfStudentIsNotVisible (studentName) { + cy.get(Courses.#chosenStudents).should('not.contain', studentName); + } - addGroup (groupName) { - cy.get(Courses.#groupSelection).find('.chosen-choices').click(); - cy.get(Courses.#groupSelection).find('.chosen-results').contains(groupName).click(); - } + addGroup (groupName) { + cy.get(Courses.#groupSelection).find('.chosen-choices').click(); + cy.get(Courses.#groupSelection).find('.chosen-results').contains(groupName).click(); + } - removeGroup (groupName) { - cy.get(Courses.#groupSelection).find('.chosen-choices').contains(groupName).siblings('a').click(); - } + removeGroup (groupName) { + cy.get(Courses.#groupSelection).find('.chosen-choices').contains(groupName).siblings('a').click(); + } - checkIfToolIsVisible(toolName) { - cy.get(Courses.#toolConfigurationSelectItem).should('not.contain', toolName); - } + checkIfToolIsVisible(toolName) { + cy.get(Courses.#toolConfigurationSelectItem).should('not.contain', toolName); + } } export default Courses From a29383c2977bfc7fff7d6174a97c4fdeddc47ba5 Mon Sep 17 00:00:00 2001 From: MBergCap <111343628+MBergCap@users.noreply.github.com> Date: Mon, 4 Dec 2023 11:03:45 +0100 Subject: [PATCH 8/8] remove duplicate --- .../support/step_definition/course/toolCourseSteps.spec.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cypress/support/step_definition/course/toolCourseSteps.spec.js b/cypress/support/step_definition/course/toolCourseSteps.spec.js index 6ee4d627..87c5536c 100644 --- a/cypress/support/step_definition/course/toolCourseSteps.spec.js +++ b/cypress/support/step_definition/course/toolCourseSteps.spec.js @@ -32,12 +32,8 @@ Then('I can enter {string} as tool name in the selection', toolName => { courses.enterAnToolNameInToolConfigurationSelect(toolName) }) -Then('I can enter {string} as tool name in the selection', toolName => { - courses.enterAnToolNameInToolConfigurationSelect(toolName) -}) - Then('I can not see tool {string} in the tool selection list', toolName => { - courses.checkIfToolIsVisible(toolName) + courses.checkIfToolIsVisible(toolName) })