Skip to content

Commit

Permalink
Implement change and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bgoldowsky committed Jul 9, 2024
1 parent 69c7860 commit afeb7a2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 30 deletions.
30 changes: 9 additions & 21 deletions cypress/e2e/functional/document_tests/exemplar_test_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -116,30 +109,25 @@ 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);
drawToolTile.drawRectangle(200, 50);

// 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")
Expand Down
21 changes: 12 additions & 9 deletions src/models/stores/exemplar-controller-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit afeb7a2

Please sign in to comment.