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

isolate dashboard tests #117

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
cleanup methods
wiaderwek committed Apr 17, 2023
commit f384f626c65f595ac40f8e1d2c579d688eb44845
2 changes: 1 addition & 1 deletion cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -31,4 +31,4 @@ module.exports = (on, config) => {
fs.writeFile("cypress/.run/results.json", JSON.stringify(results));
}
})
}
}
74 changes: 73 additions & 1 deletion cypress/support/pages/course/pageCourses.js
Original file line number Diff line number Diff line change
@@ -220,6 +220,7 @@ class Courses {
.then(interceptions => {
expect(interceptions.response.statusCode).to.equal(200)
})
.wait(['@course_api'])
}

showCourseEditPage () {
@@ -318,7 +319,8 @@ class Courses {
'@roles_api',
'@schools_api',
'@alert_api',
'@dashboard_api'
'@dashboard_api',
'@rooms_overview_api'
],
{ timeout: 80000 }
)
@@ -398,6 +400,76 @@ class Courses {
cy.get(Courses.#chosenContainer).should('contain', userFullName)
}

deleteAllCoursesMatchingName (roomName) {
cy.get('h1')
.eq(0)
.then($title => {
const htmlTitlePage = $title.text()
if (htmlTitlePage.includes('Kurse')) {
cy.get(`[class="rooms-container"]`).then($roomsContainer => {
if ($roomsContainer.find(`[aria-label="Kurs ${roomName}"]`).length) {
cy.get(`[aria-label="Kurs ${roomName}"]`).then(($rooms) => {
if ($rooms) {
cy.wrap($rooms).first().click()
cy.wait(['@board_api', '@userPermissions_api', '@rooms_api']);
this.openCourseEditPage();
cy.get(Courses.#deleteButton).should('exist').click()
cy.get(Courses.#confirmDeletionPopup)
.click({
multiple: true,
force: true
})
.wait(
[
'@runtime_config_api',
'@public_api',
'@me_api',
'@roles_api',
'@schools_api',
'@alert_api',
'@dashboard_api',
'@rooms_overview_api'
],
{timeout: 80000}
)

if ($rooms.length > 1) {
this.deleteAllCoursesMatchingName(roomName)
}
}
})
}
})
} else if (htmlTitlePage.includes('courses')) {
cy.get(`[aria-label="Course ${roomName}"]`)
.should('exist')
.each(($el, index, $list) => {
cy.wrap($el).click();
cy.wait(['@board_api', '@userPermissions_api']);
this.openCourseEditPage();
this.performRoomDeletion();
})
} else if (htmlTitlePage.includes('Cursos')) {
cy.get(`[aria-label="Curso ${roomName}"]`)
.should('exist')
.each(($course) => {
cy.wrap($course).click();
cy.wait(['@board_api', '@userPermissions_api']);
this.openCourseEditPage();
this.performRoomDeletion();
})
} else if (htmlTitlePage.includes('Поточні')) {
cy.get(`[aria-label="Курс ${roomName}"]`)
.should('exist')
.each(($el, index, $list) => {
cy.wrap($el).click();
cy.wait(['@board_api', '@userPermissions_api']);
this.openCourseEditPage();
this.performRoomDeletion();
})
}
})
}


}
9 changes: 9 additions & 0 deletions cypress/support/pages/tasks/pageTasks.js
Original file line number Diff line number Diff line change
@@ -606,5 +606,14 @@ class Tasks {
clickLowerTaskSectionIcon () {
cy.get(Tasks.#lowerTaskSectionIcon).click()
}

taskExists (taskTitle) {
cy.get(Tasks.#taskCardTitle)
.then($tasks => {
return $tasks.find(taskTitle).length
})

return false
}
}
export default Tasks
Original file line number Diff line number Diff line change
@@ -25,6 +25,8 @@ Before(() => {
cy.intercept('**/rooms/**').as('rooms_api')
cy.intercept('**/delete/**').as('delete_api')
cy.intercept('**/teams**').as('teams_api')
cy.intercept('**/courses/**').as('course_api')
cy.intercept('**/rooms-overview**').as('rooms_overview_api')
})

Given('I am logged in as a {string} at {string}', (username, environment) => {
32 changes: 31 additions & 1 deletion cypress/support/step_definition/course/commonCourseSteps.spec.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,36 @@ import Courses from '../../pages/course/pageCourses'

const courses = new Courses()

before(() => {
cy.intercept('**/public').as('public_api');
cy.intercept('**/me').as('me_api');
cy.intercept('**/user/**').as('roles_api');
cy.intercept('**/schools/**').as('schools_api');
cy.intercept('**/dashboard').as('dashboard_api');
cy.intercept('**/userPermissions?**').as('userPermissions_api');
cy.intercept('**/classes?**').as('classes_api');
cy.intercept('**/students?**').as('students_api');
cy.intercept('**/locales/**').as('locales_api');
cy.intercept('**/alerts').as('alerts_api');
cy.intercept('**/alert').as('alert_api');
cy.intercept('**/tasks**').as('tasks_api');
cy.intercept('**/runtime.config.json').as('runtime_config_api');
cy.intercept('**/board').as('board_api');
cy.intercept('**/courses?**').as('courses_api');
cy.intercept('**/courses/**').as('course_api');
cy.intercept('**/homework/**').as('homework_api');
cy.intercept('**/rooms/**').as('rooms_api');
cy.intercept('**/delete/**').as('delete_api');
cy.intercept('**/teams**').as('teams_api');
cy.intercept('**/rooms-overview**').as('rooms_overview_api');
cy.login('teacher', 'brb');
courses.navigateToRoomsOverview();
['Cypress Test Creation and Deletion', 'Cypress Testkurs Edit'].forEach((courseName => {
courses.deleteAllCoursesMatchingName(courseName);
courses.courseIsNotVisiblOnOverviewPage(courseName);
}))
})

When('I go to rooms overview', () => {
courses.navigateToRoomsOverview()
})
@@ -145,4 +175,4 @@ And('I clear substitute teacher field', () => {

And('I add substitute teacher {string}', username => {
courses.addSubstituteTeacher(username)
})
})
42 changes: 42 additions & 0 deletions cypress/support/step_definition/tasks/commonTaskSteps.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,49 @@
import Tasks from '../../pages/tasks/pageTasks'
import Courses from "../../pages/course/pageCourses";
import Dashboard from "../../pages/dashboard/pageDashboard";

const tasks = new Tasks()

before(() => {
cy.intercept('**/public').as('public_api');
cy.intercept('**/me').as('me_api');
cy.intercept('**/user/**').as('roles_api');
cy.intercept('**/schools/**').as('schools_api');
cy.intercept('**/dashboard').as('dashboard_api');
cy.intercept('**/userPermissions?**').as('userPermissions_api');
cy.intercept('**/classes?**').as('classes_api');
cy.intercept('**/students?**').as('students_api');
cy.intercept('**/locales/**').as('locales_api');
cy.intercept('**/alerts').as('alerts_api');
cy.intercept('**/alert').as('alert_api');
cy.intercept('**/tasks**').as('tasks_api');
cy.intercept('**/runtime.config.json').as('runtime_config_api');
cy.intercept('**/board').as('board_api');
cy.intercept('**/courses?**').as('courses_api');
cy.intercept('**/courses/**').as('course_api');
cy.intercept('**/homework/**').as('homework_api');
cy.intercept('**/rooms/**').as('rooms_api');
cy.intercept('**/delete/**').as('delete_api');
cy.intercept('**/teams**').as('teams_api');
cy.intercept('**/rooms-overview**').as('rooms_overview_api');
cy.login('teacher', 'brb');
const courses = new Courses();
const dashboard = new Dashboard();
tasks.navigateToTasksOverview();
tasks.clickOnTabDraftTasks();
['Cy Task Creating from Task Overview Test', 'Cy Task to be delete on task page'].forEach((taskName => {
if (tasks.taskExists(taskName)) {
tasks.openThreeDotMenuForTask(taskName);
tasks.clickDeleteTaskInDotMenu();
courses.clickDeleteInConfirmationWindow();
dashboard.arriveOnDashboard();
tasks.navigateToTasksOverview();
tasks.clickOnTabDraftTasks();
tasks.taskIsNotVisibleOnTasksOverviewPage(taskName);
}
}))
})

When('I go to tasks overview', () => {
tasks.navigateToTasksOverview()
})