From 5ce60bd18985b86fea0e8491f9105914af436e93 Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Wed, 11 Sep 2024 10:22:46 -0700 Subject: [PATCH 1/5] added close to statement to allow tolerance for values of selected labels --- .../tile_tests/geometry_tool_spec.js | 98 ++++++++++++------- 1 file changed, 65 insertions(+), 33 deletions(-) diff --git a/cypress/e2e/functional/tile_tests/geometry_tool_spec.js b/cypress/e2e/functional/tile_tests/geometry_tool_spec.js index e231e1650..c09569664 100644 --- a/cypress/e2e/functional/tile_tests/geometry_tool_spec.js +++ b/cypress/e2e/functional/tile_tests/geometry_tool_spec.js @@ -123,7 +123,7 @@ context('Geometry Tool', function () { geometryToolTile.getGraphAxisTickLabels().last().should("have.text", "15"); }); - it('works in all four modes', () => { + it.only('works in all four modes', () => { beforeTest(); clueCanvas.addTile('geometry'); geometryToolTile.getGraph().should("exist"); @@ -417,47 +417,79 @@ context('Geometry Tool', function () { clueCanvas.clickToolbarButton('geometry', 'label'); geometryToolTile.getModalTitle().should('contain.text', 'Length'); geometryToolTile.chooseLabelOption('length'); - geometryToolTile.clickGraphPosition(0, 0); // deselect + geometryToolTile.clickGraphPosition(20, 20); // deselect - // Verify that the two line segments were created - geometryToolTile.getGraphPointLabel().contains('10.0').should('exist'); - geometryToolTile.getGraphPointLabel().contains('5.0').should('exist'); +// Store initial values for the line segments +let originalValue1 = 10.0; +let originalValue2 = 5.0; - // Move the point - clueCanvas.clickToolbarButton('geometry', 'select'); - geometryToolTile.clickGraphPosition(15, 5); // shared point - geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 39 }); // simulate right arrow key press - geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 38 }); // simulate up arrow key press +// Verify that the first point label is close to 10.0 +geometryToolTile.getGraphPointLabel().eq(2).invoke('text').then((text) => { + const value = parseFloat(text); + expect(value).to.be.closeTo(originalValue1, 0.1); // Allow tolerance for value close to 10.0 +}); - // Verify that the point values changed - geometryToolTile.getSelectedGraphPoint().then(($point) => { - const newPx = parseFloat($point.attr('cx')); // 'px' for point x-coordinate - const newPy = parseFloat($point.attr('cy')); // 'py' for point y-coordinate +// Verify that the second point label is close to 5.0 +geometryToolTile.getGraphPointLabel().eq(3).invoke('text').then((text) => { + const value = parseFloat(text); + expect(value).to.be.closeTo(originalValue2, 0.1); // Allow tolerance for value close to 5.0 +}); - expect(newPx).to.be.greaterThan(originalCx); - expect(newPy).to.be.lessThan(originalCy); - }); +// Move the point +clueCanvas.clickToolbarButton('geometry', 'select'); +geometryToolTile.clickGraphPosition(15, 5); // shared point +geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 39 }); // simulate right arrow key press +geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 38 }); // simulate up arrow key press - // Verify that the two line segments have changed - geometryToolTile.getGraphPointLabel().contains('10.1').should('exist'); - geometryToolTile.getGraphPointLabel().contains('4.9').should('exist'); +// Updated expected values after the point move +let updatedValue1 = originalValue1 + 0.1; // 10.1 +let updatedValue2 = originalValue2 - 0.1; // 4.9 - // Move the point back to the original position - geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 37 }); // simulate left arrow key press - geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 40 }); // simulate down arrow key press +// Verify that the point values changed +geometryToolTile.getSelectedGraphPoint().then(($point) => { + const newPx = parseFloat($point.attr('cx')); + const newPy = parseFloat($point.attr('cy')); - // Verify that the point has returned to its original coordinates - geometryToolTile.getSelectedGraphPoint().then(($point) => { - const resetPx = parseFloat($point.attr('cx')); - const resetPy = parseFloat($point.attr('cy')); + expect(newPx).to.be.greaterThan(originalCx); + expect(newPy).to.be.lessThan(originalCy); +}); - expect(resetPx).to.equal(originalCx); - expect(resetPy).to.equal(originalCy); - }); +// Verify that the first line segment has changed to a value close to 10.1 +geometryToolTile.getGraphPointLabel().eq(2).invoke('text').then((text) => { + const value = parseFloat(text); + expect(value).to.be.closeTo(updatedValue1, 0.1); // Tolerance for value close to 10.1 +}); + +// Verify that the second line segment has changed to a value close to 4.9 +geometryToolTile.getGraphPointLabel().eq(3).invoke('text').then((text) => { + const value = parseFloat(text); + expect(value).to.be.closeTo(updatedValue2, 0.1); // Tolerance for value close to 4.9 +}); + +// Move the point back to the original position +geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 37 }); // simulate left arrow key press +geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 40 }); // simulate down arrow key press - // Verify that the two line segments returned to their original values - geometryToolTile.getGraphPointLabel().contains('10.0').should('exist'); - geometryToolTile.getGraphPointLabel().contains('5.0').should('exist'); +// Verify that the point has returned to its original coordinates +geometryToolTile.getSelectedGraphPoint().then(($point) => { + const resetPx = parseFloat($point.attr('cx')); + const resetPy = parseFloat($point.attr('cy')); + + expect(resetPx).to.equal(originalCx); + expect(resetPy).to.equal(originalCy); +}); + +// Verify that the first line segment has returned to a value close to 10.0 +geometryToolTile.getGraphPointLabel().eq(2).invoke('text').then((text) => { + const value = parseFloat(text); + expect(value).to.be.closeTo(originalValue1, 0.1); // Tolerance for value close to 10.0 +}); + +// Verify that the second line segment has returned to a value close to 5.0 +geometryToolTile.getGraphPointLabel().eq(3).invoke('text').then((text) => { + const value = parseFloat(text); + expect(value).to.be.closeTo(originalValue2, 0.1); // Tolerance for value close to 5.0 +}); // Verify the point is still shared geometryToolTile.getGraphPoint().should("have.length", 6); // New point added From 166945b41ea402847c958b071ea4fecb7c598c72 Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Wed, 11 Sep 2024 10:23:39 -0700 Subject: [PATCH 2/5] fixed indenting issues --- .../tile_tests/geometry_tool_spec.js | 118 +++++++++--------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/cypress/e2e/functional/tile_tests/geometry_tool_spec.js b/cypress/e2e/functional/tile_tests/geometry_tool_spec.js index c09569664..6194c6a6f 100644 --- a/cypress/e2e/functional/tile_tests/geometry_tool_spec.js +++ b/cypress/e2e/functional/tile_tests/geometry_tool_spec.js @@ -419,77 +419,77 @@ context('Geometry Tool', function () { geometryToolTile.chooseLabelOption('length'); geometryToolTile.clickGraphPosition(20, 20); // deselect -// Store initial values for the line segments -let originalValue1 = 10.0; -let originalValue2 = 5.0; - -// Verify that the first point label is close to 10.0 -geometryToolTile.getGraphPointLabel().eq(2).invoke('text').then((text) => { - const value = parseFloat(text); - expect(value).to.be.closeTo(originalValue1, 0.1); // Allow tolerance for value close to 10.0 -}); + // Store initial values for the line segments + let originalValue1 = 10.0; + let originalValue2 = 5.0; + + // Verify that the first point label is close to 10.0 + geometryToolTile.getGraphPointLabel().eq(2).invoke('text').then((text) => { + const value = parseFloat(text); + expect(value).to.be.closeTo(originalValue1, 0.1); // Allow tolerance for value close to 10.0 + }); -// Verify that the second point label is close to 5.0 -geometryToolTile.getGraphPointLabel().eq(3).invoke('text').then((text) => { - const value = parseFloat(text); - expect(value).to.be.closeTo(originalValue2, 0.1); // Allow tolerance for value close to 5.0 -}); + // Verify that the second point label is close to 5.0 + geometryToolTile.getGraphPointLabel().eq(3).invoke('text').then((text) => { + const value = parseFloat(text); + expect(value).to.be.closeTo(originalValue2, 0.1); // Allow tolerance for value close to 5.0 + }); -// Move the point -clueCanvas.clickToolbarButton('geometry', 'select'); -geometryToolTile.clickGraphPosition(15, 5); // shared point -geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 39 }); // simulate right arrow key press -geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 38 }); // simulate up arrow key press + // Move the point + clueCanvas.clickToolbarButton('geometry', 'select'); + geometryToolTile.clickGraphPosition(15, 5); // shared point + geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 39 }); // simulate right arrow key press + geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 38 }); // simulate up arrow key press -// Updated expected values after the point move -let updatedValue1 = originalValue1 + 0.1; // 10.1 -let updatedValue2 = originalValue2 - 0.1; // 4.9 + // Updated expected values after the point move + let updatedValue1 = originalValue1 + 0.1; // 10.1 + let updatedValue2 = originalValue2 - 0.1; // 4.9 -// Verify that the point values changed -geometryToolTile.getSelectedGraphPoint().then(($point) => { - const newPx = parseFloat($point.attr('cx')); - const newPy = parseFloat($point.attr('cy')); + // Verify that the point values changed + geometryToolTile.getSelectedGraphPoint().then(($point) => { + const newPx = parseFloat($point.attr('cx')); + const newPy = parseFloat($point.attr('cy')); - expect(newPx).to.be.greaterThan(originalCx); - expect(newPy).to.be.lessThan(originalCy); -}); + expect(newPx).to.be.greaterThan(originalCx); + expect(newPy).to.be.lessThan(originalCy); + }); -// Verify that the first line segment has changed to a value close to 10.1 -geometryToolTile.getGraphPointLabel().eq(2).invoke('text').then((text) => { - const value = parseFloat(text); - expect(value).to.be.closeTo(updatedValue1, 0.1); // Tolerance for value close to 10.1 -}); + // Verify that the first line segment has changed to a value close to 10.1 + geometryToolTile.getGraphPointLabel().eq(2).invoke('text').then((text) => { + const value = parseFloat(text); + expect(value).to.be.closeTo(updatedValue1, 0.1); // Tolerance for value close to 10.1 + }); -// Verify that the second line segment has changed to a value close to 4.9 -geometryToolTile.getGraphPointLabel().eq(3).invoke('text').then((text) => { - const value = parseFloat(text); - expect(value).to.be.closeTo(updatedValue2, 0.1); // Tolerance for value close to 4.9 -}); + // Verify that the second line segment has changed to a value close to 4.9 + geometryToolTile.getGraphPointLabel().eq(3).invoke('text').then((text) => { + const value = parseFloat(text); + expect(value).to.be.closeTo(updatedValue2, 0.1); // Tolerance for value close to 4.9 + }); -// Move the point back to the original position -geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 37 }); // simulate left arrow key press -geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 40 }); // simulate down arrow key press + // Move the point back to the original position + geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 37 }); // simulate left arrow key press + geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 40 }); // simulate down arrow key press -// Verify that the point has returned to its original coordinates -geometryToolTile.getSelectedGraphPoint().then(($point) => { - const resetPx = parseFloat($point.attr('cx')); - const resetPy = parseFloat($point.attr('cy')); + // Verify that the point has returned to its original coordinates + geometryToolTile.getSelectedGraphPoint().then(($point) => { + const resetPx = parseFloat($point.attr('cx')); + const resetPy = parseFloat($point.attr('cy')); - expect(resetPx).to.equal(originalCx); - expect(resetPy).to.equal(originalCy); -}); + expect(resetPx).to.equal(originalCx); + expect(resetPy).to.equal(originalCy); + }); -// Verify that the first line segment has returned to a value close to 10.0 -geometryToolTile.getGraphPointLabel().eq(2).invoke('text').then((text) => { - const value = parseFloat(text); - expect(value).to.be.closeTo(originalValue1, 0.1); // Tolerance for value close to 10.0 -}); + // Verify that the first line segment has returned to a value close to 10.0 + geometryToolTile.getGraphPointLabel().eq(2).invoke('text').then((text) => { + const value = parseFloat(text); + expect(value).to.be.closeTo(originalValue1, 0.1); // Tolerance for value close to 10.0 + }); -// Verify that the second line segment has returned to a value close to 5.0 -geometryToolTile.getGraphPointLabel().eq(3).invoke('text').then((text) => { - const value = parseFloat(text); - expect(value).to.be.closeTo(originalValue2, 0.1); // Tolerance for value close to 5.0 -}); + // Verify that the second line segment has returned to a value close to 5.0 + geometryToolTile.getGraphPointLabel().eq(3).invoke('text').then((text) => { + const value = parseFloat(text); + expect(value).to.be.closeTo(originalValue2, 0.1); // Tolerance for value close to 5.0 + }); // Verify the point is still shared geometryToolTile.getGraphPoint().should("have.length", 6); // New point added From aeead05f2064dd56788a62c8269be231193ff166 Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:23:27 -0700 Subject: [PATCH 3/5] Added tolerance statements for automation of polygon points --- .../tile_tests/geometry_tool_spec.js | 58 ++++++++++++------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/cypress/e2e/functional/tile_tests/geometry_tool_spec.js b/cypress/e2e/functional/tile_tests/geometry_tool_spec.js index 6194c6a6f..32b9e8e0c 100644 --- a/cypress/e2e/functional/tile_tests/geometry_tool_spec.js +++ b/cypress/e2e/functional/tile_tests/geometry_tool_spec.js @@ -123,7 +123,7 @@ context('Geometry Tool', function () { geometryToolTile.getGraphAxisTickLabels().last().should("have.text", "15"); }); - it.only('works in all four modes', () => { + it('works in all four modes', () => { beforeTest(); clueCanvas.addTile('geometry'); geometryToolTile.getGraph().should("exist"); @@ -419,31 +419,38 @@ context('Geometry Tool', function () { geometryToolTile.chooseLabelOption('length'); geometryToolTile.clickGraphPosition(20, 20); // deselect - // Store initial values for the line segments - let originalValue1 = 10.0; - let originalValue2 = 5.0; + let origPointLabel1 = 10.0; + let origPointLabel2 = 5.0; // Verify that the first point label is close to 10.0 geometryToolTile.getGraphPointLabel().eq(2).invoke('text').then((text) => { const value = parseFloat(text); - expect(value).to.be.closeTo(originalValue1, 0.1); // Allow tolerance for value close to 10.0 + expect(value).to.be.closeTo(origPointLabel1, 0.1); // Allow tolerance for value close to 10.0 }); // Verify that the second point label is close to 5.0 geometryToolTile.getGraphPointLabel().eq(3).invoke('text').then((text) => { const value = parseFloat(text); - expect(value).to.be.closeTo(originalValue2, 0.1); // Allow tolerance for value close to 5.0 + expect(value).to.be.closeTo(origPointLabel2, 0.1); // Allow tolerance for value close to 5.0 }); // Move the point clueCanvas.clickToolbarButton('geometry', 'select'); geometryToolTile.clickGraphPosition(15, 5); // shared point - geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 39 }); // simulate right arrow key press - geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 38 }); // simulate up arrow key press + + // Simulate 4 right arrow key presses + for (let i = 0; i < 4; i++) { + geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 39 }); + } + + // Simulate 4 up arrow key presses + for (let i = 0; i < 4; i++) { + geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 38 }); + } // Updated expected values after the point move - let updatedValue1 = originalValue1 + 0.1; // 10.1 - let updatedValue2 = originalValue2 - 0.1; // 4.9 + let updatedValue1 = origPointLabel1 + 0.4; // 10.4 + let updatedValue2 = origPointLabel2 - 0.4; // 4.6 // Verify that the point values changed geometryToolTile.getSelectedGraphPoint().then(($point) => { @@ -454,21 +461,28 @@ context('Geometry Tool', function () { expect(newPy).to.be.lessThan(originalCy); }); - // Verify that the first line segment has changed to a value close to 10.1 + // Verify that the first line segment has changed to a value close to 10.4 geometryToolTile.getGraphPointLabel().eq(2).invoke('text').then((text) => { - const value = parseFloat(text); - expect(value).to.be.closeTo(updatedValue1, 0.1); // Tolerance for value close to 10.1 + const lineSegment1 = parseFloat(text); + expect(lineSegment1).to.be.closeTo(updatedValue1, 0.1); // Tolerance for value close to 10.4 }); - // Verify that the second line segment has changed to a value close to 4.9 + // Verify that the second line segment has changed to a value close to 4.6 geometryToolTile.getGraphPointLabel().eq(3).invoke('text').then((text) => { - const value = parseFloat(text); - expect(value).to.be.closeTo(updatedValue2, 0.1); // Tolerance for value close to 4.9 + const lineSegment2 = parseFloat(text); + expect(lineSegment2).to.be.closeTo(updatedValue2, 0.1); // Tolerance for value close to 4.6 }); // Move the point back to the original position - geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 37 }); // simulate left arrow key press - geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 40 }); // simulate down arrow key press + // Simulate 4 left arrow key presses + for (let i = 0; i < 4; i++) { + geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 37 }); + } + + // Simulate 4 down arrow key presses + for (let i = 0; i < 4; i++) { + geometryToolTile.getSelectedGraphPoint().trigger('keydown', { keyCode: 40 }); + } // Verify that the point has returned to its original coordinates geometryToolTile.getSelectedGraphPoint().then(($point) => { @@ -481,14 +495,14 @@ context('Geometry Tool', function () { // Verify that the first line segment has returned to a value close to 10.0 geometryToolTile.getGraphPointLabel().eq(2).invoke('text').then((text) => { - const value = parseFloat(text); - expect(value).to.be.closeTo(originalValue1, 0.1); // Tolerance for value close to 10.0 + const lineSegment1 = parseFloat(text); + expect(lineSegment1).to.be.closeTo(origPointLabel1, 0.1); // Tolerance for value close to 10.0 }); // Verify that the second line segment has returned to a value close to 5.0 geometryToolTile.getGraphPointLabel().eq(3).invoke('text').then((text) => { - const value = parseFloat(text); - expect(value).to.be.closeTo(originalValue2, 0.1); // Tolerance for value close to 5.0 + const lineSegment2 = parseFloat(text); + expect(lineSegment2).to.be.closeTo(origPointLabel2, 0.1); // Tolerance for value close to 5.0 }); // Verify the point is still shared From 8aa238e60194d4fdc6074ba14aed584176f92116 Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Wed, 11 Sep 2024 16:04:44 -0700 Subject: [PATCH 4/5] fix rebase issues --- cypress/e2e/functional/tile_tests/geometry_tool_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/functional/tile_tests/geometry_tool_spec.js b/cypress/e2e/functional/tile_tests/geometry_tool_spec.js index 32b9e8e0c..0b74277a1 100644 --- a/cypress/e2e/functional/tile_tests/geometry_tool_spec.js +++ b/cypress/e2e/functional/tile_tests/geometry_tool_spec.js @@ -301,7 +301,7 @@ context('Geometry Tool', function () { // Also check that the angle label has changed from its original value geometryToolTile.getAngleAdornment().should(($label) => { const angleText = $label.text(); - expect(angleText).not.to.equal('90'); // 90° was the original value + expect(angleText).not.contains('90°'); // 90° was the original value }); // Move the point back to the original position @@ -385,7 +385,7 @@ context('Geometry Tool', function () { geometryToolTile.getGraphPolygon().should("have.length", 1); // Create a second polygon that shares the same points as the first - cy.log('Create a second polygon that shares the same points as the first'); + cy.log('Create a second polygon that shares a point with the first'); clueCanvas.clickToolbarButton('geometry', 'polygon'); geometryToolTile.clickGraphPosition(15, 10); // new point geometryToolTile.clickGraphPosition(15, 5); // shared point From f002638ad88130ab0bf977fa3e0fb7fdbdfc797b Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Wed, 11 Sep 2024 16:35:19 -0700 Subject: [PATCH 5/5] fix 90 statement --- cypress/e2e/functional/tile_tests/geometry_tool_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/functional/tile_tests/geometry_tool_spec.js b/cypress/e2e/functional/tile_tests/geometry_tool_spec.js index 0b74277a1..37aee96f8 100644 --- a/cypress/e2e/functional/tile_tests/geometry_tool_spec.js +++ b/cypress/e2e/functional/tile_tests/geometry_tool_spec.js @@ -301,7 +301,7 @@ context('Geometry Tool', function () { // Also check that the angle label has changed from its original value geometryToolTile.getAngleAdornment().should(($label) => { const angleText = $label.text(); - expect(angleText).not.contains('90°'); // 90° was the original value + expect(angleText).not.to.equal('90'); // 90° was the original value }); // Move the point back to the original position