From b24804243f898e53637f40f42ac0083914ca6094 Mon Sep 17 00:00:00 2001 From: Scott Cytacki Date: Tue, 17 Sep 2024 22:21:36 -0400 Subject: [PATCH] fix issue with commenting on exemplar docs --- .../teacher_tests/teacher_sort_work_view_spec.js | 6 +----- src/models/stores/sorted-documents.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/functional/teacher_tests/teacher_sort_work_view_spec.js b/cypress/e2e/functional/teacher_tests/teacher_sort_work_view_spec.js index 1637bf6e0..c8b74f7f2 100644 --- a/cypress/e2e/functional/teacher_tests/teacher_sort_work_view_spec.js +++ b/cypress/e2e/functional/teacher_tests/teacher_sort_work_view_spec.js @@ -209,6 +209,7 @@ describe('SortWorkView Tests', () => { cy.visit(queryParams2); cy.waitForLoad(); cy.openTopTab('sort-work'); + cy.get('.section-header-label').should("contain", "Group 5"); cy.get('.section-header-arrow').click({multiple: true}); // Open the sections cy.wait(1000); studentProblemDocs.forEach(doc => { @@ -307,11 +308,6 @@ describe('SortWorkView Tests', () => { 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.getShowForMenu().click(); - sortWork.getShowForInvestigationOption().click(); - sortWork.getShowForMenu().click(); - sortWork.getShowForProblemOption().click(); cy.get('.section-header-arrow').click({multiple: true}); // Open the sections sortWork.checkDocumentInGroup("Diverging Designs", exemplarDocs[0]); diff --git a/src/models/stores/sorted-documents.ts b/src/models/stores/sorted-documents.ts index 948c20608..05675ef9b 100644 --- a/src/models/stores/sorted-documents.ts +++ b/src/models/stores/sorted-documents.ts @@ -201,10 +201,18 @@ export class SortedDocuments { typecheck(DocumentMetadataModel, data); const exemplarMetadata = this.exemplarMetadataDocs.get(data.key); if (exemplarMetadata) { + // If this metadata doc in Firestore is an exemplar in the same unit then the exemplar + // metadata will be found. This will happen when a teacher comments on a exemplar. + // So in this case we need to merge the strategies from the exemplar with the strategies from + // the teacher's comments. const authoredStrategies = exemplarMetadata.strategies || []; const userStrategies = data.strategies || []; data.strategies = union(authoredStrategies, userStrategies); - data.tools = exemplarMetadata.tools; + // We also update the tools incase the author has changed the exemplar content after + // the teacher commented on the document. + // We need a copy of the tools so the same array isn't attached to two MST trees at + // the same time. + data.tools = [...exemplarMetadata.tools]; } }); return mstSnapshot;