Skip to content

Commit

Permalink
Merge branch 'main' into update-test-db
Browse files Browse the repository at this point in the history
  • Loading branch information
hasan-sh committed Jun 3, 2024
2 parents 2914892 + 4163290 commit 931d079
Show file tree
Hide file tree
Showing 40 changed files with 330 additions and 316 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ it('should return to admin page button', () => {
loginForAdmin();
goToAdminAchievementsPage();

cy.get('[data-cy="return_to_admin_page_button"]')
cy.getDataCy('return_to_admin_page_button')
.should('be.visible')
.should('be.not.disabled')
.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ it('should return to admin page button', () => {
loginForAdmin();
goToAdminAdventuresPage();

cy.get('[data-cy="return_to_admin_page_button"]')
cy.getDataCy('return_to_admin_page_button')
.should('be.visible')
.should('be.not.disabled')
.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { goToAdminUsersPage } from '../../tools/navigation/nav.js';

it('should return to admin page', () => {
goToAdminUsersPage();
cy.get('[data-cy="return_button"]').should('be.not.disabled').should('be.visible').click();
cy.getDataCy('return_button').should('be.not.disabled').should('be.visible').click();

cy.location().should((loc) => {
expect(loc.pathname).equal(Cypress.env('admin_page'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { goToAdminUsersPage } from '../../tools/navigation/nav.js';
it('should view all users', () => {
goToAdminUsersPage();

cy.get('[data-cy="view_all_button"]').should('be.not.disabled').should('be.visible').click();
cy.getDataCy('view_all_button').should('be.not.disabled').should('be.visible').click();

cy.location().should((loc) => {
console.log(loc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ it('When selecting a program as Hedys choice, it should be shown', ()=>{
loginForAdmin();
goToExploreProgramsPage();
// Get the id of the first program in the db
cy.get('[data-cy="explore_page_programs"]')
cy.getDataCy('explore_page_programs')
.children()
.first()
.invoke('attr', 'data-cy')
Expand All @@ -14,7 +14,7 @@ it('When selecting a program as Hedys choice, it should be shown', ()=>{
cy.get('@program_id').then(program_id => {
// mark the program as Hedys choice
cy.get(`#${program_id}`).click();
cy.get('[data-cy="modal_yes_button"]').click();
cy.getDataCy('modal_yes_button').click();
// reload the page to see the changes
cy.reload();
cy.get(`[data-cy="explore_favourite_programs"] > [data-cy=${program_id}]`).should('be.visible');
Expand Down
22 changes: 11 additions & 11 deletions tests/cypress/e2e/feedback/feedback_modal.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ describe("Test the feedback feature", () => {
})
it("should be able to open the modal", () => {
goToHedyPage();
cy.get('[data-cy="feedback_button"]')
cy.getDataCy('feedback_button')
.should("be.visible")
.click()

cy.get('[data-cy="modal-feedback"]')
cy.getDataCy('modal-feedback')
.should("be.visible")
});

it("should not submit if the message or category is empty/not selected", () => {
goToTeachersPage();

cy.get('[data-cy="feedback_button"]')
cy.getDataCy('feedback_button')
.should("be.visible")
.click()

cy.get('[data-cy="modal-feedback-input"]')
cy.getDataCy('modal-feedback-input')
.type("should not work without a category")


cy.get('[data-cy="modal-feedback-input"]')
cy.getDataCy('modal-feedback-input')
.should("be.visible")

cy.get('[data-cy="modal-feedback-cancel"]')
cy.getDataCy('modal-feedback-cancel')
.click()

cy.get('[data-cy="modal-feedback-input"]')
cy.getDataCy('modal-feedback-input')
.should("not.be.visible")
});

Expand All @@ -45,20 +45,20 @@ describe("Test the feedback feature", () => {

goToProfilePage();

cy.get('[data-cy="feedback_button"]')
cy.getDataCy('feedback_button')
.should("be.visible")
.click()

cy.get('[data-cy="modal-feedback-input"]')
cy.getDataCy('modal-feedback-input')
.type("This feature is wonderful! Thanks a lot for making it happen ;)")

cy.get("#feedback")
.click()

cy.get('[data-cy="modal-feedback-submit"]')
cy.getDataCy('modal-feedback-submit')
.click()

cy.get('[data-cy="modal-feedback-input"]')
cy.getDataCy('modal-feedback-input')
.should("not.be.visible")

cy.wait("@postFeedback").should('have.nested.property', 'response.statusCode', 200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ it('Is able to see copy link to add student to class', () => {
loginForTeacher();
cy.wait(500);

cy.get('[data-cy="view_class_link"]').then($viewClass => {
cy.getDataCy('view_class_link').then($viewClass => {
if (!$viewClass.is(':visible')) {
cy.get('[data-cy="view_classes"]').click();
cy.getDataCy('view_classes').click();
}
});
cy.get('[data-cy="view_class_link"]').first().click();
cy.getDataCy('view_class_link').first().click();
cy.get('body').then($b => $b.find('[data-cy="survey"]')).then($s => $s.length && $s.hide())
cy.get('[data-cy="add_student"]').click();
cy.get('[data-cy="copy_join_link"]').should('be.visible').should('be.enabled').click();
cy.getDataCy('add_student').click();
cy.getDataCy('copy_join_link').should('be.visible').should('be.enabled').click();
})
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,47 @@ it('Is able to add student by name', () => {
loginForTeacher();
let student = 'student5'

cy.get('[data-cy="view_class_link"]').then($viewClass => {
cy.getDataCy('view_class_link').then($viewClass => {
if (!$viewClass.is(':visible')) {
cy.get('[data-cy="view_classes"]').click();
cy.getDataCy('view_classes').click();
}
});
cy.get('[data-cy="view_class_link"]').first().click();
cy.getDataCy('view_class_link').first().click();
cy.get('body').then($b => $b.find('[data-cy="survey"]')).then($s => $s.length && $s.hide())

// delete student if in class
cy.get('[data-cy="class_user_table"]').then(($div) => {
cy.getDataCy('class_user_table').then(($div) => {
if ($div.text().includes(student)){
cy.get('[data-cy="remove_student"]').first().click();
cy.get('[data-cy="modal_yes_button"]').click();
cy.getDataCy('remove_student').first().click();
cy.getDataCy('modal_yes_button').click();
}
})

cy.wait(500);

cy.get('[data-cy="add_student"]').click();
cy.getDataCy('add_student').click();

cy.get('[data-cy="invite_student"]').click();
cy.get('[data-cy="modal_prompt_input"]').type(student);
cy.get('[data-cy="modal_ok_button"]').click();
cy.getDataCy('invite_student').click();
cy.getDataCy('modal_prompt_input').type(student);
cy.getDataCy('modal_ok_button').click();

login(student, "123456");

cy.get('[data-cy="user_dropdown"]').click();
cy.get('[data-cy="my_account_button"]').click();
cy.get('[data-cy="join_link"]').click();
cy.getDataCy('user_dropdown').click();
cy.getDataCy('my_account_button').click();
cy.getDataCy('join_link').click();

logout();
loginForTeacher();

cy.get('[data-cy="view_class_link"]').then($viewClass => {
cy.getDataCy('view_class_link').then($viewClass => {
if (!$viewClass.is(':visible')) {
cy.get('[data-cy="view_classes"]').click();
cy.getDataCy('view_classes').click();
}
});
cy.get('[data-cy="view_class_link"]').first().click();
cy.getDataCy('view_class_link').first().click();

cy.get('[data-cy="student_username_cell"]').should(($div) => {
cy.getDataCy('student_username_cell').should(($div) => {
const text = $div.text()
expect(text).include('student5');
})
Expand Down
28 changes: 14 additions & 14 deletions tests/cypress/e2e/for-teacher_page/class_page/class-survey.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@ let className = "CLASS1"
beforeEach(() => {
loginForTeacher("teacher4");
goToTeachersPage();
cy.get('[data-cy="view_class_link"]').then($viewClass => {
cy.getDataCy('view_class_link').then($viewClass => {
if (!$viewClass.is(':visible')) {
cy.get('[data-cy="view_classes"]').click();
cy.getDataCy('view_classes').click();
}
});
cy.get('[data-cy="view_class_link"]').contains(new RegExp(`^${className}$`)).click();
cy.get('[data-cy="survey_status_button"]').click();
cy.getDataCy('view_class_link').contains(new RegExp(`^${className}$`)).click();
cy.getDataCy('survey_status_button').click();
})

describe('Class Survey View', () => {
it("Can be cancelled", () => {
cy.get('[data-cy="survey"]').should("be.visible");
cy.get('[data-cy="cancel_survey"]').click();
cy.get('[data-cy="survey"]').should("not.be.visible");
cy.getDataCy('survey').should("be.visible");
cy.getDataCy('cancel_survey').click();
cy.getDataCy('survey').should("not.be.visible");
})

it('Can first respond to 1 question, then to last 3 questions', () => {
cy.get('[data-cy="survey"]').should("be.visible");
cy.get('[data-cy="input_1"]').type("test");
cy.get('[data-cy="submit"]').click();
cy.get('[data-cy="survey_status_button"]').click();
cy.getDataCy('survey').should("be.visible");
cy.getDataCy('input_1').type("test");
cy.getDataCy('submit').click();
cy.getDataCy('survey_status_button').click();
const surveyInputs = Array.from({length:3},(v, k)=> k+1)
cy.wrap(surveyInputs).each((index) => {
cy.getBySel("input_" + index)
cy.getDataCy("input_" + index)
.type("test")
.invoke("val").then((text) => {
expect("test").to.equal(text);
});
});
cy.get('[data-cy="submit"]').click();
cy.get('[data-cy="survey_status_button"]').contains("complete");
cy.getDataCy('submit').click();
cy.getDataCy('survey_status_button').contains("complete");
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ beforeEach(() => {
describe('Testing a teacher account', () => {
it('Is able to add rows to create more accounts', () => {
({classname, students} = createClassAndAddStudents());
cy.get('[data-cy="add_multiple_rows"]').click();
cy.getDataCy('add_multiple_rows').click();
cy.get(':nth-child(6) > [data-cy="username"]').should('have.value', '');
})

it('Is able to create new accounts for class', () => {
navigateToClass(classname);
cy.get('[data-cy="student_username_cell"]').should(($div) => {
cy.getDataCy('student_username_cell').should(($div) => {
const text = $div.text();
expect(text).include(students[0]);
})
Expand All @@ -30,9 +30,9 @@ describe('Testing a teacher account', () => {

it('Is able to generate passwords', () => {
navigateToClass(classname);
cy.get('[data-cy="add_student"]').click();
cy.get('[data-cy="create_accounts"]').click();
cy.get('[data-cy="toggle_circle"]').click(); //switches the toggle on so that passwords are generated
cy.getDataCy('add_student').click();
cy.getDataCy('create_accounts').click();
cy.getDataCy('toggle_circle').click(); //switches the toggle on so that passwords are generated
cy.wait(1000);
cy.get(':nth-child(2) > [data-cy="password"]').should('have.length.greaterThan', 0);
})
Expand All @@ -42,9 +42,9 @@ describe('Testing a teacher account', () => {
navigateToClass(classname);
cy.url().then(url => {
currentUrl = url;
cy.get('[data-cy="add_student"]').click();
cy.get('[data-cy="create_accounts"]').click();
cy.get('[data-cy="go_back_button"]').click();
cy.getDataCy('add_student').click();
cy.getDataCy('create_accounts').click();
cy.getDataCy('go_back_button').click();
cy.wait(1000);
let statsUrl = Cypress.env('class_page') + currentUrl.substring(currentUrl.indexOf('class/')+6);
cy.url().should('include', statsUrl);
Expand All @@ -53,8 +53,8 @@ describe('Testing a teacher account', () => {

it('Is able to remove row', () => {
navigateToClass(classname);
cy.get('[data-cy="add_student"]').click();
cy.get('[data-cy="create_accounts"]').click();
cy.getDataCy('add_student').click();
cy.getDataCy('create_accounts').click();
//fills in first row
cy.get(':nth-child(2) > [data-cy="username"]').type("student10");
cy.get(':nth-child(2) > [data-cy="password"]').type("123456");
Expand All @@ -70,13 +70,13 @@ describe('Testing a teacher account', () => {

it('Is able to use the reset button', () => {
navigateToClass(classname);
cy.get('[data-cy="add_student"]').click();
cy.get('[data-cy="create_accounts"]').click();
cy.getDataCy('add_student').click();
cy.getDataCy('create_accounts').click();
cy.get(':nth-child(2) > [data-cy="username"]').type("student10");
cy.get(':nth-child(2) > [data-cy="password"]').type("123456");
cy.wait(1000);
cy.get(':nth-child(2) > [data-cy="username"]').should('have.value', 'student10');
cy.get('[data-cy="reset_button"]').click();
cy.getDataCy('reset_button').click();
cy.wait(1000);
cy.get(':nth-child(2) > [data-cy="username"]').should('have.value', '');
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ before(() => {
describe('Testing second teacher accounts', () => {
it('Is able to create new accounts for class', () => {
navigateToClass(classname);
cy.get('[data-cy="student_username_cell"]').should(($div) => {
cy.getDataCy('student_username_cell').should(($div) => {
const text = $div.text();
expect(text).include(students[0]);
})
Expand All @@ -29,9 +29,9 @@ describe('Testing second teacher accounts', () => {

it('Is able to generate passwords', () => {
navigateToClass(classname);
cy.get('[data-cy="add_student"]').click();
cy.get('[data-cy="create_accounts"]').click();
cy.get('[data-cy="toggle_circle"]').click(); //switches the toggle on so that passwords are generated
cy.getDataCy('add_student').click();
cy.getDataCy('create_accounts').click();
cy.getDataCy('toggle_circle').click(); //switches the toggle on so that passwords are generated
cy.wait(1000);
cy.get(':nth-child(2) > [data-cy="password"]').should('have.length.greaterThan', 0);
})
Expand All @@ -41,9 +41,9 @@ describe('Testing second teacher accounts', () => {
navigateToClass(classname);
cy.url().then(url => {
currentUrl = url;
cy.get('[data-cy="add_student"]').click();
cy.get('[data-cy="create_accounts"]').click();
cy.get('[data-cy="go_back_button"]').click();
cy.getDataCy('add_student').click();
cy.getDataCy('create_accounts').click();
cy.getDataCy('go_back_button').click();
cy.wait(1000);
let statsUrl = Cypress.env('class_page') + currentUrl.substring(currentUrl.indexOf('class/')+6);
cy.url().should('include', statsUrl);
Expand All @@ -52,8 +52,8 @@ describe('Testing second teacher accounts', () => {

it('Is able to remove row', () => {
navigateToClass(classname);
cy.get('[data-cy="add_student"]').click();
cy.get('[data-cy="create_accounts"]').click();
cy.getDataCy('add_student').click();
cy.getDataCy('create_accounts').click();
//fills in first row
cy.get(':nth-child(2) > [data-cy="username"]').type("student10");
cy.get(':nth-child(2) > [data-cy="password"]').type("123456");
Expand All @@ -69,13 +69,13 @@ describe('Testing second teacher accounts', () => {

it('Is able to use the reset button', () => {
navigateToClass(classname);
cy.get('[data-cy="add_student"]').click();
cy.get('[data-cy="create_accounts"]').click();
cy.getDataCy('add_student').click();
cy.getDataCy('create_accounts').click();
cy.get(':nth-child(2) > [data-cy="username"]').type("student10");
cy.get(':nth-child(2) > [data-cy="password"]').type("123456");
cy.wait(1000);
cy.get(':nth-child(2) > [data-cy="username"]').should('have.value', 'student10');
cy.get('[data-cy="reset_button"]').click();
cy.getDataCy('reset_button').click();
cy.wait(1000);
cy.get(':nth-child(2) > [data-cy="username"]').should('have.value', '');
})
Expand Down
Loading

0 comments on commit 931d079

Please sign in to comment.