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

[FIX, TESTING] Fixes failing teacher test #4797

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
import {loginForTeacher, logout} from "../../tools/login/login.js"
import { goToProfilePage } from "../../tools/navigation/nav";
import { createClass } from "../../tools/classes/class";

const secondTeachers = ["teacher2", "teacher3"]
const invitesTable = body => body.find("#invites-block table")

describe("Second teachers: invitations", () => {
it(`Invites ${secondTeachers.length} second teachers: by username`, () => {

before(() => {
loginForTeacher();
createClass()
});

cy.wait(500);

it(`Invites ${secondTeachers.length} second teachers: by username`, () => {
loginForTeacher();
cy.get(".view_class").first().click();
cy.get('body').then($b => $b.find("#survey")).then($s => $s.length && $s.hide())

for (const teacher of secondTeachers) {
cy.wait(500);

cy.get("#add-second-teacher").click();

// cy.get("#invite-student").click();
// cy.wait(2000)
cy.get("#modal-prompt-input").type(teacher);
cy.get("#modal-ok-button").click();

cy.wait(500);

cy.get("body").then(invitesTable).then(table => {
if (table.length) {
table = cy.get("#invites-block table")
Expand All @@ -37,24 +32,15 @@ describe("Second teachers: invitations", () => {
}
})
}
//logout:
// logout();
})

it(`Tries duplicating ${secondTeachers[0]}'s invitation`, () => {

loginForTeacher()

loginForTeacher();
cy.get(".view_class").first().click();
cy.wait(500);
cy.get('body').then($b => $b.find("#survey")).then($s => $s.length && $s.hide())

cy.wait(500);

cy.get("#add-second-teacher").click();
cy.get("#modal-prompt-input").type(secondTeachers[0]);
cy.get("#modal-ok-button").click();
cy.wait(500);

cy.get("#modal_alert_container")
.should('be.visible')
Expand All @@ -66,44 +52,32 @@ describe("Second teachers: invitations", () => {
goToProfilePage()
cy.get("#messages").should("exist")
cy.get("#messages #join").click()
logout();
})

it("Reads all second teachers", () => {
loginForTeacher()
cy.get(".view_class").first().click();
cy.wait(500);
cy.get('body').then($b => $b.find("#survey")).then($s => $s.length && $s.hide())
cy.get(".view_class").first().click();
cy.get("#second_teachers_container .username_cell").should("include.text", secondTeachers[0])
logout()
})

it(`Deletes ${secondTeachers[1]}'s invitation`, () => {

loginForTeacher();
cy.wait(500);
cy.get(".view_class").first().click();
cy.wait(500);
cy.get('body').then($b => $b.find("#survey")).then($s => $s.length && $s.hide())

cy.get("body").then(invitesTable).then(table => {
// if not, then no invitation.
if (table.length) {
table = cy.get("#invites-block table")
console.log(table)
table.should("exist")
table.get(".remove_user_invitation").first().click()
cy.wait(500);
cy.get("#modal-yes-button").click();
} else {
cy.log("Second teacher not deleted.")
}
})

cy.wait(500);
cy.get('body').then(invitesTable).then(table =>
table.length && cy.get("#invites-block table").should("not.contain", secondTeachers[0]))
logout();
})

})
Loading