From afeb7a23ca611c91f5beaad832f995a6566b2261 Mon Sep 17 00:00:00 2001 From: Boris Goldowsky Date: Tue, 9 Jul 2024 13:42:40 -0400 Subject: [PATCH] Implement change and tests --- .../document_tests/exemplar_test_spec.js | 30 ++++++------------- .../stores/exemplar-controller-rules.ts | 21 +++++++------ 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/cypress/e2e/functional/document_tests/exemplar_test_spec.js b/cypress/e2e/functional/document_tests/exemplar_test_spec.js index 7c73df0dad..d887293150 100644 --- a/cypress/e2e/functional/document_tests/exemplar_test_spec.js +++ b/cypress/e2e/functional/document_tests/exemplar_test_spec.js @@ -70,7 +70,7 @@ context('Exemplar Documents', function () { sortWork.getSortWorkItemByTitle(exemplarName).parents('.list-item').should("have.class", "private"); clueCanvas.getStickyNotePopup().should("not.exist"); - cy.log("Create 3 drawing tiles with 3 events"); + cy.log("Create 2 drawing tiles with 3 events"); clueCanvas.addTile("drawing"); drawToolTile.drawRectangle(100, 50); drawToolTile.drawRectangle(200, 50); @@ -81,24 +81,17 @@ context('Exemplar Documents', function () { drawToolTile.drawRectangle(200, 50); drawToolTile.drawRectangle(300, 50); - clueCanvas.addTile("drawing"); - drawToolTile.drawRectangle(100, 50); - drawToolTile.drawRectangle(200, 50); - drawToolTile.drawRectangle(300, 50); - - cy.log("Create 3 text tiles and put 10 words in them"); + cy.log("Create 2 text tiles and put 5 words in them"); clueCanvas.addTile("text"); - textToolTile.enterText("one two three four five six seven eight nine ten"); + textToolTile.enterText("one two three four five"); clueCanvas.addTile("text"); - textToolTile.enterText("one two three four five six seven eight nine ten"); + textToolTile.enterText("one two three four"); - clueCanvas.addTile("text"); - textToolTile.enterText("one two three four five six seven eight nine"); drawToolTile.getDrawTile().eq(0).click(); // text is saved in onBlur // Still private? sortWork.getSortWorkItemByTitle(exemplarName).parents('.list-item').should("have.class", "private"); - textToolTile.enterText(" ten"); + textToolTile.enterText(" five"); drawToolTile.getDrawTile().eq(0).click(); // Now the exemplar should be revealed @@ -116,22 +109,17 @@ context('Exemplar Documents', function () { }); - it('Exemplar revealed by 3 drawings that include labels', function () { + it('Exemplar revealed by 2 drawings that include labels', function () { beforeTest(queryParams1); cy.openTopTab('sort-work'); sortWork.checkDocumentInGroup("No Group", exemplarName); sortWork.getSortWorkItemByTitle(exemplarName).parents('.list-item').should("have.class", "private"); - cy.log("Create 3 drawing tiles with 3 events and a label"); - clueCanvas.addTile("drawing"); - drawToolTile.drawRectangle(100, 50); - drawToolTile.drawRectangle(200, 50); - addText(300, 50, "one two three four five six seven eight nine ten"); - + cy.log("Create 2 drawing tiles with 2 events and a label"); clueCanvas.addTile("drawing"); drawToolTile.drawRectangle(100, 50); drawToolTile.drawRectangle(200, 50); - addText(300, 50, "one two three four five six seven eight nine ten"); + addText(300, 50, "one two three four five"); clueCanvas.addTile("drawing"); drawToolTile.drawRectangle(100, 50); @@ -139,7 +127,7 @@ context('Exemplar Documents', function () { // Still private? sortWork.getSortWorkItemByTitle(exemplarName).parents('.list-item').should("have.class", "private"); - addText(300, 50, "one two three four five six seven eight nine ten"); + addText(300, 50, "one two three four five"); // Now the exemplar should be revealed sortWork.getSortWorkItemByTitle(exemplarInfo).parents('.list-item').should("not.have.class", "private"); clueCanvas.getStickyNotePopup().should("exist").should("be.visible") diff --git a/src/models/stores/exemplar-controller-rules.ts b/src/models/stores/exemplar-controller-rules.ts index 57d14342aa..806599fdfb 100644 --- a/src/models/stores/exemplar-controller-rules.ts +++ b/src/models/stores/exemplar-controller-rules.ts @@ -17,35 +17,38 @@ interface IExemplarControllerRule { reset: (model: BaseExemplarControllerModelType, tiles: string[]) => void; } -// "3 drawings/3 labels" Rule: reveal an exemplar for each: -// 3 drawing tiles, each with at least 3 actions AND -// 3 labels with least 10 words each, where a label can be a text tile or a text object in a drawing. +// "2 drawings/2 labels" Rule: reveal an exemplar for each: +// 2 drawing tiles, each with at least 3 actions AND +// 2 labels with least 5 words each, where a label can be a text tile or a text object in a drawing. const kDrawingMinActivityLevel = 3; -const kLabelMinWords = 10; +const kLabelMinWords = 5; +const kNumDrawings = 2; +const kNumLabels = 2; + const threeDrawingsRule: IExemplarControllerRule = { - name: "3 drawings/3 labels", + name: "2 drawings/2 labels", test: (model: BaseExemplarControllerModelType) => { let foundDrawings = 0, foundLabels = 0; const tileIds: string[] = []; for (const [key, tile] of model.inProgressTiles.entries()) { - if (tile.type === kTextTileType && tile.wordCount >= kLabelMinWords && foundLabels < 3) { + if (tile.type === kTextTileType && tile.wordCount >= kLabelMinWords && foundLabels < kNumLabels) { foundLabels++; tileIds.push(key); } if (tile.type === kDrawingTileType) { - if (tile.activityLevel >= kDrawingMinActivityLevel && foundDrawings < 3) { + if (tile.activityLevel >= kDrawingMinActivityLevel && foundDrawings < kNumDrawings) { foundDrawings++; tileIds.push(key); } - if (tile.wordCount >= kLabelMinWords && foundLabels < 3) { + if (tile.wordCount >= kLabelMinWords && foundLabels < kNumLabels) { foundLabels++; if (!tileIds.includes(key)) tileIds.push(key); } } - if (foundDrawings >= 3 && foundLabels >= 3) { + if (foundDrawings >= kNumDrawings && foundLabels >= kNumLabels) { return tileIds; } }