Skip to content

Commit

Permalink
fix student test, and enable sort filter persistence
Browse files Browse the repository at this point in the history
- both tests were using a demo space for testing
- also added a new helper visitQaSubtabsUnit to improve readability
  • Loading branch information
scytacki committed Sep 23, 2024
1 parent 7cb4693 commit 1858c8b
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 42 deletions.
77 changes: 66 additions & 11 deletions cypress/e2e/functional/document_tests/student_test_spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import Header from '../../../support/elements/common/Header';
import ClueHeader from '../../../support/elements/common/cHeader';
import SortedWork from "../../../support/elements/common/SortedWork";
import Canvas from '../../../support/elements/common/Canvas';
import ClueCanvas from '../../../support/elements/common/cCanvas';
import { visitQaSubtabsUnit } from "../../../support/visit_params";


const header = new Header;
const clueHeader = new ClueHeader;
const sortWork = new SortedWork;
const canvas = new Canvas;
const clueCanvas = new ClueCanvas;

const copyTitle = "Personal Workspace";

let student = '5',
classroom = '5',
Expand All @@ -16,6 +23,14 @@ function beforeTest(queryParams) {
cy.waitForLoad();
}

function openAllGroupSections() {
cy.get('.section-header-label').should("contain", "Group 1");
cy.get('.section-header-label').should("contain", "Group 2");
cy.get('.section-header-label').should("contain", "Group 3");
cy.get('.section-header-label').should("contain", "No Group");
cy.get(".section-header-arrow").click({multiple: true});
}

context('Check header area for correctness', function () {
it('verify header area', function () {
beforeTest(`${Cypress.config("qaUnitStudent5")}`);
Expand Down Expand Up @@ -45,23 +60,63 @@ context('Check header area for correctness', function () {

context("check public/private document access", function() {
it("marks private documents as private and only shows public documents as accessible", function() {
const queryParams = (`${Cypress.config("clueTestNoUnitStudent5")}`);
beforeTest(queryParams);
[1,2,3].forEach(studentId => {
// Put each student in their own group
visitQaSubtabsUnit({student: studentId, group: studentId});
if (studentId === 2) {
// Share the student 2 problem document
cy.wait(500); // CLUE needs time to create the metadata doc
clueCanvas.shareCanvas();
}
canvas.copyDocument(copyTitle);
canvas.getPersonalDocTitle().find('span').text().should('contain', copyTitle);
if (studentId === 2) {
// Share the student 2 personal document
cy.wait(500); // CLUE needs time to create the metadata doc
clueCanvas.shareCanvas();

// Share the student 3 learning log
canvas.openDocumentWithTitleWithoutTabs("Learning Log");
cy.wait(500); // CLUE needs time to create the metadata doc
clueCanvas.shareCanvas();

// Give CLUE time to update the shared property in the metadata
cy.wait(500);
}
});

// Go back to student 1
visitQaSubtabsUnit({student: 1, group: 1});

cy.openTopTab("sort-work");
cy.get(".section-header-arrow").click({multiple: true}); // Open all sections
cy.log("will verify if private documents are marked as private and are not accessible");
sortWork.checkGroupDocumentVisibility("No Group", true, true);
cy.log("will verify if user's own documents are not marked as private and are accessible");

cy.log("verify user's own documents are not marked as private and are accessible");
openAllGroupSections();
sortWork.checkGroupDocumentVisibility("Group 1", false, true);

cy.log("verify other user's shared documents are not marked as private and are accessible");
openAllGroupSections();
sortWork.checkGroupDocumentVisibility("Group 2", false, true);

// Check the above for a view that contains compact document items
cy.log("verify private documents are marked as private and are not accessible");
openAllGroupSections();
sortWork.checkGroupDocumentVisibility("Group 3", true, true);

// Check the same conditions in a view that contains compact document items
sortWork.getShowForMenu().click();
sortWork.getShowForInvestigationOption().click();
cy.get(".section-header-arrow").click({multiple: true}); // Open all sections
cy.log("will verify if private documents are marked as private and are not accessible in the compact view");
sortWork.checkGroupDocumentVisibility("No Group", true);
cy.log("will verify if user's own documents are not marked as private and are accessible in the compact view");

cy.log("verify user's own documents are not marked as private and are accessible in the compact view");
// In this case the sections are still open from before
// openAllGroupSections();
sortWork.checkGroupDocumentVisibility("Group 1", false);

cy.log("verify other user's shared documents are not marked as private and are accessible in the compact view");
openAllGroupSections();
sortWork.checkGroupDocumentVisibility("Group 2", false);

cy.log("verify private documents are marked as private and are not accessible in the compact view");
openAllGroupSections();
sortWork.checkGroupDocumentVisibility("Group 3", true);
});
});
48 changes: 17 additions & 31 deletions cypress/e2e/functional/teacher_tests/teacher_sort_work_view_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ResourcesPanel from "../../../support/elements/common/ResourcesPanel";
import Canvas from '../../../support/elements/common/Canvas';
import ClueHeader from '../../../support/elements/common/cHeader';
import ChatPanel from "../../../support/elements/common/ChatPanel";
import { visitQaSubtabsUnit } from "../../../support/visit_params";

let sortWork = new SortedWork;
let resourcesPanel = new ResourcesPanel;
Expand All @@ -15,8 +16,6 @@ const canvas = new Canvas;
const title = "1.1 Unit Toolbar Configuration";
const copyTitle = "Personal Workspace";
const queryParams1 = `${Cypress.config("clueTestqaConfigSubtabsUnitTeacher6")}`;
const queryParams2 = `${Cypress.config("qaConfigSubtabsUnitTeacher1")}`;
const queryParams3 = `${Cypress.config("qaConfigSubtabsUnitStudent5")}`;

function beforeTest(params) {
cy.visit(params);
Expand All @@ -27,11 +26,6 @@ function beforeTest(params) {
cy.wait(1000);
}

function runClueAsStudent(student, group = 5) {
cy.visit(queryParams3.replace("student:5", student).replace("qaGroup=5", `qaGroup=${group}`));
cy.waitForLoad();
}

//TODO: For QA (1/24)
// Write a test that confirms correct behavior for "Sort by Tools"
// • Create a network URL (or clear all documents from existing one from the previous test) that has no documents in Sort Work view (doesn't matter which filter we sort by)
Expand Down Expand Up @@ -201,7 +195,7 @@ describe('SortWorkView Tests', () => {
});

it("should open Sort Work tab and test sorting by group", () => {
const students = ["student:1", "student:2", "student:3"];
const students = [1,2,3];
const studentProblemDocs = [
`Student 1: ${title}`,
`Student 2: ${title}`,
Expand All @@ -218,7 +212,7 @@ describe('SortWorkView Tests', () => {

cy.log("run CLUE for various students creating their problem and personal documents");
students.forEach(student => {
runClueAsStudent(student);
visitQaSubtabsUnit({student, group: 5});
canvas.copyDocument(copyTitle);
canvas.getPersonalDocTitle().find('span').text().should('contain', copyTitle);
// Check that exemplar is not visible to student
Expand All @@ -228,8 +222,7 @@ describe('SortWorkView Tests', () => {
});

cy.log("run CLUE as teacher and check student problem, personal, and exemplar docs show in Sort Work");
cy.visit(queryParams2);
cy.waitForLoad();
visitQaSubtabsUnit({teacher: 1});
cy.openTopTab('sort-work');
cy.get('.section-header-label').should("contain", "Group 5");
cy.get('.section-header-arrow').click({multiple: true}); // Open the sections
Expand Down Expand Up @@ -277,16 +270,15 @@ describe('SortWorkView Tests', () => {
});

cy.log("run CLUE as student 1; they should now have access to exemplar");
runClueAsStudent(students[0]);
visitQaSubtabsUnit({student: 1, group: 5});
cy.get('.section-header-arrow').click({multiple: true}); // Open the sections
sortWork.getSortWorkItemByTitle(exemplarDocs[0]).parents('.list-item').should("not.have.class", "private");

cy.log("have student 1 leave the group");
header.leaveGroup();

cy.log("check student:1 problem, exemplar, and personal docs show in No Group");
cy.visit(queryParams2);
cy.waitForLoad();
visitQaSubtabsUnit({teacher: 1});
cy.openTopTab('sort-work');
cy.wait(1000);
cy.get('.section-header-arrow').click({multiple: true}); // Open the sections
Expand Down Expand Up @@ -339,8 +331,7 @@ describe('SortWorkView Tests', () => {
chatPanel.getChatPanelToggle().click();
chatPanel.deleteTeacherComments();
cy.wait(1000);
cy.visit(queryParams2);
cy.waitForLoad();
visitQaSubtabsUnit({teacher: 1});
cy.openTopTab('sort-work');

cy.log("check that exemplar document is still displayed in strategy tag sourced from CMS but not in teacher added tag");
Expand All @@ -356,11 +347,10 @@ describe('SortWorkView Tests', () => {
sortWork.checkDocumentInGroup("Diverging Designs", exemplarDocs[0]);

cy.log("run CLUE as a student:1 and join group 6");
runClueAsStudent(students[0], 6);
visitQaSubtabsUnit({student: 1, group: 6});

cy.log("check student:1 problem and personal docs show in Group 6");
cy.visit(queryParams2);
cy.waitForLoad();
visitQaSubtabsUnit({teacher: 1});
cy.openTopTab('sort-work');
cy.wait(500);
sortWork.getPrimarySortByMenu().click();
Expand All @@ -374,12 +364,11 @@ describe('SortWorkView Tests', () => {
sortWork.checkDocumentNotInGroup("Group 6", studentPersonalDocs[1]);

cy.log("run CLUE as a student:1 and leave the group");
runClueAsStudent(students[0], 6);
visitQaSubtabsUnit({student: 1, group: 6});
header.leaveGroup();

cy.log("check Group 6 no longer exists in Sort Work");
cy.visit(queryParams2);
cy.waitForLoad();
visitQaSubtabsUnit({teacher: 1});
cy.openTopTab('sort-work');
cy.wait(500);
cy.get('.section-header-arrow').click({multiple: true}); // Open the sections
Expand All @@ -388,29 +377,26 @@ describe('SortWorkView Tests', () => {
sortWork.checkGroupDoesNotExist("Group 6");
});

// The test below fails because the sort selections aren't persisting across page reloads for some
// unknown reason. Sort selection persistence occurs in other tests, though, and appears to work
// fine when tested manually in a web browser.
it.skip("should open Sort Work tab and test that sort selections persist", () => {
beforeTest(queryParams1);
it("should open Sort Work tab and test that sort selections persist", () => {
visitQaSubtabsUnit({teacher: 1});
cy.openTopTab('sort-work');

cy.log("check initial state of primary and secondary sort selections and modify both");
sortWork.getPrimarySortByMenu().click();
sortWork.getPrimarySortByGroupOption().should("have.class", "selected");
sortWork.getPrimarySortByNameOption().click();
cy.wait(1000);
sortWork.getPrimarySortByNameOption().should("have.class", "selected");
sortWork.getSecondarySortByMenu().click();
sortWork.getSecondarySortByNoneOption().should("have.class", "selected");
sortWork.getSecondarySortByGroupOption().click();
cy.wait(1000);
sortWork.getSecondarySortByGroupOption().should("have.class", "selected");
// Give CLUE some time to save the changes
cy.wait(500);

cy.log("reload page and check that modified sort selections persist");
cy.visit(queryParams1);
visitQaSubtabsUnit({teacher: 1});
cy.waitForLoad();
cy.openTopTab("sort-work");
cy.wait(1000);
sortWork.getPrimarySortByNameOption().should("have.class", "selected");
sortWork.getSecondarySortByGroupOption().should("have.class", "selected");
});
Expand Down
27 changes: 27 additions & 0 deletions cypress/support/visit_params.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Visit qaConfigSubtabsUnit as a teacher or student.
* If visiting as a student you can also specify the group the student should be in.
* After visiting the unit, it will wait for CLUE to load.
*
* @param {*} params {student?: id, teacher?: id, group?: id}
*/
export function visitQaSubtabsUnit(params) {
const teacherQueryParams = `${Cypress.config("qaConfigSubtabsUnitTeacher1")}`;
const studentQueryParams = `${Cypress.config("qaConfigSubtabsUnitStudent5")}`;
let queryParams;
if ("student" in params) {
queryParams = studentQueryParams.replace("student:5", `student:${params.student}`);
if ("group" in params) {
queryParams = queryParams.replace("qaGroup=5", `qaGroup=${params.group}`);
}
} else if ("teacher" in params) {
if ("group" in params) {
throw new Error(`teachers aren't in groups: ${params.group}`);
}
queryParams = teacherQueryParams.replace("teacher:1", `teacher:${params.teacher}`);
} else {
throw new Error(`unknown params ${JSON.stringify(params)}`);
}
cy.visit(queryParams);
cy.waitForLoad();
}

0 comments on commit 1858c8b

Please sign in to comment.