Skip to content

Commit

Permalink
Merge pull request #2223 from concord-consortium/187185137-exemplar-a…
Browse files Browse the repository at this point in the history
…uthored-tag

187185137 exemplar authored tag
  • Loading branch information
scytacki authored Mar 25, 2024
2 parents 38ce4db + 325e499 commit f99e8bd
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import SortedWork from "../../../support/elements/common/SortedWork";
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";

let sortWork = new SortedWork;
let resourcesPanel = new ResourcesPanel;
let dashboard = new TeacherDashboard;
let header = new ClueHeader;
let chatPanel = new ChatPanel;

const canvas = new Canvas;
const title = "1.1 Unit Toolbar Configuration";
const copyTitle = "Personal Workspace";
Expand Down Expand Up @@ -45,13 +48,13 @@ describe('SortWorkView Tests', () => {
sortWork.getSortByMenu().click(); // Open the sort menu
cy.wait(1000);

sortWork.getListItemByName().click(); //Select 'Name' sort type
sortWork.getSortByNameOption().click(); //Select 'Name' sort type
cy.wait(1000);

sortWork.getSortByMenu().click(); // Open the sort menu again
cy.wait(1000);

sortWork.getListItemByGroup().click(); // Select 'Group' sort type
sortWork.getSortByGroupOption().click(); // Select 'Group' sort type
cy.wait(1000);

cy.log('verify opening and closing a document from the sort work view');
Expand Down Expand Up @@ -147,13 +150,49 @@ describe('SortWorkView Tests', () => {
cy.log("check that problem and exemplar documents can be sorted by name");
sortWork.getSortByMenu().click();
cy.wait(1000);
sortWork.getListItemByName().click();
sortWork.getSortByNameOption().click();
sortWork.checkSectionHeaderLabelsExist([
"1, Student", "1, Teacher", "2, Student", "3, Student", "4, Student", "Idea, Ivan"
]);
sortWork.checkDocumentInGroup("Idea, Ivan", exemplarDocs[0]);
sortWork.checkDocumentInGroup("1, Student", studentProblemDocs[0]);

cy.log("check that exemplar document is displayed in strategy tag sourced from CMS");
sortWork.getSortByMenu().click();
cy.wait(1000);
sortWork.getSortByTagOption().click();
sortWork.checkDocumentInGroup("Unit Rate", exemplarDocs[0]);

cy.log("check that exemplar document can also be assigned tag by teacher");
sortWork.getSortWorkItem().contains(exemplarDocs[0]).click();
chatPanel.getChatPanelToggle().click();
chatPanel.addCommentTagAndVerify("Diverging Designs");

cy.log("check that exemplar document is displayed in new tag");
chatPanel.getChatCloseButton().click();
cy.openTopTab('sort-work');
// at the moment this is required to refresh the sort
sortWork.getSortByMenu().click();
sortWork.getSortByNameOption().click();
sortWork.getSortByMenu().click();
sortWork.getSortByTagOption().click();
sortWork.checkDocumentInGroup("Diverging Designs", exemplarDocs[0]);

cy.log("remove the teacher added tag and reload");
sortWork.getSortWorkItem().contains(exemplarDocs[0]).click();
chatPanel.getChatPanelToggle().click();
chatPanel.deleteTeacherComments();
cy.wait(1000);
cy.visit(queryParams2);
cy.waitForLoad();
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");
sortWork.getSortByMenu().click();
sortWork.getSortByTagOption().click();
sortWork.checkDocumentInGroup("Unit Rate", exemplarDocs[0]);
sortWork.checkGroupIsEmpty("Diverging Designs");

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

Expand Down
10 changes: 5 additions & 5 deletions cypress/support/elements/common/ChatPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ChatPanel{
this.getChatPanelToggle().click();
cy.wait(10000);
}
})
});
}
getChatPanel() {
return cy.get('.chat-panel');
Expand Down Expand Up @@ -202,9 +202,9 @@ class ChatPanel{
cy.wait(1000);
}
})
)
);
} else {
cy.log("No Comments to Delete");
cy.log("No Comments to Delete");
}
});
}
Expand All @@ -219,7 +219,7 @@ class ChatPanel{
this.getCommentedDocumentList().find('.document-box').then(((value) => {
totalCount = Cypress.$(value).length;
expect(value).to.have.length(totalCount);
for(i=0; i < totalCount; i++) {
for(i=0; i < totalCount; i++) {
this.getCommentedDocumentList().find('.document-box').eq(i).click({ force: true });
cy.wait(3000);
this.addDocumentCommentAndVerify("This is " + (i+1) + " document list comment");
Expand All @@ -229,7 +229,7 @@ class ChatPanel{
cy.wait(3000);
}
})
)
);
}
}
export default ChatPanel;
11 changes: 9 additions & 2 deletions cypress/support/elements/common/SortedWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ class SortedWork {
getSortByMenu() {
return cy.get('.custom-select.sort-work-sort-menu');
}
getListItemByName() {
getSortByNameOption() {
return cy.get('[data-test="list-item-name"]');
}
getListItemByGroup() {
getSortByGroupOption() {
return cy.get('[data-test="list-item-group"]');
}
getSortByTagOption(){
return cy.get('[data-test="list-item-identify-design approach"]');
}
getSortWorkItem() {
return cy.get(".sort-work-view .sorted-sections .list-item .footer .info");
}
Expand All @@ -17,6 +20,10 @@ class SortedWork {
checkDocumentNotInGroup(groupName, doc) {
cy.get(".sort-work-view .sorted-sections .section-header-label").contains(groupName).parent().parent().find(".list .list-item .footer .info").should("not.contain", doc);
}
checkGroupIsEmpty(groupName){
cy.get(".sort-work-view .sorted-sections .section-header-label")
.contains(groupName).parent().parent().find(".list").should('be.empty');
}
checkGroupDoesNotExist(group) {
cy.get(".sort-work-view .sorted-sections .section-header-label").should("not.contain", group);
}
Expand Down
5 changes: 4 additions & 1 deletion src/models/stores/create-exemplar-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ function createExemplarDocs(
type: ExemplarDocument,
visibility: "public",
content: exemplarData.content,
key: exemplarDocId
key: exemplarDocId,
properties: {
authoredCommentTag: exemplarData.tag
}
};
const newDoc = createDocumentModelWithEnv(appConfig, newDocParams);
documents.add(newDoc);
Expand Down
30 changes: 21 additions & 9 deletions src/models/stores/sorted-documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface IMatchPropertiesOptions {
}
export class SortedDocuments {
stores: ISortedDocumentsStores;
tempTagDocumentMap = new Map<string, Set<string>>();
firestoreTagDocumentMap = new Map<string, Set<string>>();

constructor(stores: ISortedDocumentsStores) {
makeAutoObservable(this);
Expand Down Expand Up @@ -156,21 +156,33 @@ export class SortedDocuments {

// Find all unique document keys in tagsWithDocs. Compare this with all sortable documents
// in store to find "Documents with no comments" then place those doc keys to "Not Tagged"
const uniqueDocKeysWithComments = new Set<string>();
const uniqueDocKeysWithTags = new Set<string>();

this.tempTagDocumentMap.forEach((docKeysSet, tag) => {
docKeysSet.forEach((docKey: string) =>{
uniqueDocKeysWithComments.add(docKey);
});
// grouping documents based on firestore comment tags
this.firestoreTagDocumentMap.forEach((docKeysSet, tag) => {
const docKeysArray = Array.from(docKeysSet); // Convert the Set to an array
if (tagsWithDocs[tag]) {
docKeysSet.forEach((docKey: string) =>{
uniqueDocKeysWithTags.add(docKey);
});
tagsWithDocs[tag].docKeysFoundWithTag = docKeysArray;
}
});

// adding in (exemplar) documents with authored tags
const allSortableDocKeys = this.filteredDocsByType;
allSortableDocKeys.forEach(doc => {
if (!uniqueDocKeysWithComments.has(doc.key)) {
const foundTagKey = doc.getProperty("authoredCommentTag");
if (foundTagKey !== undefined && foundTagKey !== "") {
if (tagsWithDocs[foundTagKey]) {
tagsWithDocs[foundTagKey].docKeysFoundWithTag.push(doc.key);
uniqueDocKeysWithTags.add(doc.key);
}
}
});

allSortableDocKeys.forEach(doc => {
if (!uniqueDocKeysWithTags.has(doc.key)) {
// This document has no comments
if (tagsWithDocs[""]) {
tagsWithDocs[""].docKeysFoundWithTag.push(doc.key);
Expand Down Expand Up @@ -205,10 +217,10 @@ export class SortedDocuments {
const commentData = commentDoc.data();
if (commentData?.tags) {
commentData.tags.forEach((tag: string) => {
let docKeysSet = this.tempTagDocumentMap.get(tag);
let docKeysSet = this.firestoreTagDocumentMap.get(tag);
if (!docKeysSet) {
docKeysSet = new ObservableSet<string>();
this.tempTagDocumentMap.set(tag, docKeysSet);
this.firestoreTagDocumentMap.set(tag, docKeysSet);
}
docKeysSet.add(doc.key);
});
Expand Down
3 changes: 2 additions & 1 deletion src/public/demo/units/qa-config-subtabs/content.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"materials": "Varies Material/Surface",
"physical": "Varies Physical Factors",
"user": "Varies Human Factors",
"system": "Varies System Factors"
"system": "Varies System Factors",
"unit-rate": "Unit Rate"
},
"tagPrompt": "Identify Design Approach",
"tools": ["Simulator"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "First Exemplar",
"tag": "building-up",
"tag": "unit-rate",
"content": {
"tiles": [
{
Expand Down

0 comments on commit f99e8bd

Please sign in to comment.