From bba4a9cf688a4e26920cce498bfcde232487d1a9 Mon Sep 17 00:00:00 2001 From: Sumedha Pramod Date: Thu, 3 Jan 2019 14:20:02 -0500 Subject: [PATCH] Fix: Functional tests (#320) - Add test to ensure highlighting works even after interacting w/ drawing/point modes --- functional-tests/helpers/actions.js | 24 ++++++++++++----- functional-tests/helpers/validation.js | 2 +- functional-tests/tests/draw.js | 3 --- functional-tests/tests/plain_highlight.js | 32 ++++++++++++++++++++--- 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/functional-tests/helpers/actions.js b/functional-tests/helpers/actions.js index 91579c5cb..d91e3cdc2 100644 --- a/functional-tests/helpers/actions.js +++ b/functional-tests/helpers/actions.js @@ -1,8 +1,6 @@ /* eslint-disable prefer-arrow-callback, no-var, func-names */ const { SELECTOR_ANNOTATION_POPOVER, - SELECTOR_ANNOTATION_BUTTON_POST, - SELECTOR_ANNOTATION_BUTTON_CANCEL, SELECTOR_ANNOTATION_COMMENT, SELECTOR_DELETE_COMMENT_BTN, SELECTOR_DRAFTEDITOR_CONTENT, @@ -10,7 +8,6 @@ const { SELECTOR_INPUT_SUBMIT_BTN, SELECTOR_INPUT_CANCEL_BTN, SELECTOR_ANNOTATION_POINT_MARKER, - SELECTOR_ANNOTATION_TEXTAREA, SELECTOR_ANNNOTATION_MODE_BACKGROUND, SELECTOR_ANNOTATION_BUTTON_POINT, SELECTOR_ANNOTATION_BUTTON_POINT_EXIT, @@ -85,6 +82,21 @@ function enterPointMode(I) { I.waitForVisible(SELECTOR_ANNOTATION_BUTTON_POINT_EXIT); } +/** + * Exit point annotation mode + * + * @param {Object} I - the codeceptjs I + * + * @return {void} + */ +function exitPointMode(I) { + I.say('Exit point annotation mode'); + I.click(SELECTOR_ANNOTATION_BUTTON_POINT_EXIT); + I.waitForVisible(SELECTOR_ANNOTATION_BUTTON_POINT); + I.dontSeeElement(SELECTOR_ANNNOTATION_MODE_BACKGROUND); + I.dontSeeElement(SELECTOR_POINT_MODE_HEADER); + I.dontSeeElement(SELECTOR_ANNOTATION_BUTTON_POINT_EXIT); +} /** * Cancel a point annotation * @@ -131,14 +143,12 @@ function createReplyDeletePoint(I) { deleteAnnotation(I, 1); I.waitForDetached(SELECTOR_ANNOTATION_POINT_MARKER, 1); - I.say('Exit point annotation mode'); - I.click(SELECTOR_ANNOTATION_BUTTON_POINT_EXIT); - I.dontSeeElement(SELECTOR_ANNNOTATION_MODE_BACKGROUND); - I.waitForVisible(SELECTOR_ANNOTATION_BUTTON_POINT); + exitPointMode(I); } exports.replyToThread = replyToThread; exports.deleteAnnotation = deleteAnnotation; exports.enterPointMode = enterPointMode; +exports.exitPointMode = exitPointMode; exports.cancelPointAnnotation = cancelPointAnnotation; exports.createReplyDeletePoint = createReplyDeletePoint; \ No newline at end of file diff --git a/functional-tests/helpers/validation.js b/functional-tests/helpers/validation.js index 0e7ed95c1..f6679c493 100644 --- a/functional-tests/helpers/validation.js +++ b/functional-tests/helpers/validation.js @@ -25,7 +25,7 @@ const { */ async function validateIconColor(I, selector, color) { I.waitForElement(selector); - const clr = await I.grabCssPropertyFrom(`${selector} svg`, 'fill'); + const clr = await I.grabCssPropertyFrom(selector, 'fill'); expect(clr).to.equal(color); } diff --git a/functional-tests/tests/draw.js b/functional-tests/tests/draw.js index afdefbd54..70c8983e5 100644 --- a/functional-tests/tests/draw.js +++ b/functional-tests/tests/draw.js @@ -11,7 +11,6 @@ const { SELECTOR_ANNOTATION_BUTTON_DRAW_CANCEL, SELECTOR_ANNOTATION_LAYER_DRAW_IN_PROGRESS, SELECTOR_DRAW_CONTROLS, - SELECTOR_ADD_DRAWING_BTN, SELECTOR_ANNOTATION_DRAWING_LABEL, SELECTOR_DRAWING_DELETE_BTN, SELECTOR_HIGHLIGHT_CONTROLS @@ -94,7 +93,6 @@ Scenario('Create/Delete drawing @desktop @doc', function(I) { I.say('Save drawing'); I.click(SELECTOR_DRAWING_SAVE_BTN); - I.waitForInvisible(SELECTOR_DRAW_CONTROLS); // Unselect newly created drawing I.click(SELECTOR_TEXT_LAYER); @@ -121,7 +119,6 @@ Scenario('Create/Delete drawing @desktop @doc', function(I) { I.say('Save drawing'); I.click(SELECTOR_DRAWING_SAVE_BTN); - I.waitForInvisible(SELECTOR_DRAW_CONTROLS); // Unselect newly created drawing I.click(SELECTOR_TEXT_LAYER); diff --git a/functional-tests/tests/plain_highlight.js b/functional-tests/tests/plain_highlight.js index be4586d74..ba5f7044b 100644 --- a/functional-tests/tests/plain_highlight.js +++ b/functional-tests/tests/plain_highlight.js @@ -5,10 +5,14 @@ const { SELECTOR_HIGHLIGHT_CONTROLS, SELECTOR_ANNOTATION_POPOVER, SELECTOR_HIGHLIGHT_BTN, - SELECTOR_ANNOTATOR_LABEL + SELECTOR_SAVED_HIGHLIGHT, + SELECTOR_ANNOTATOR_LABEL, + SELECTOR_ANNOTATION_BUTTON_DRAW, + SELECTOR_ANNOTATION_BUTTON_DRAW_CANCEL } = require('../helpers/constants'); -const { selectText } = require('../helpers/mouseEvents'); +const { selectText, clickAtLocation } = require('../helpers/mouseEvents'); +const { enterPointMode, exitPointMode } = require('../helpers/actions'); const { validateIconColor } = require('../helpers/validation'); const { cleanupAnnotations } = require('../helpers/cleanup'); @@ -25,6 +29,28 @@ After(function() { Scenario('Create/Delete a new plain highlight annotation @desktop @doc', function(I) { I.waitForVisible(SELECTOR_ANNOTATIONS_LOADED); + /** Highlighting should still work after drawing on the file */ + I.say('Enter draw annotation mode'); + I.click(SELECTOR_ANNOTATION_BUTTON_DRAW); + I.waitForVisible(SELECTOR_ANNOTATION_BUTTON_DRAW_CANCEL); + + I.say('Exit draw annotations mode'); + I.click(SELECTOR_ANNOTATION_BUTTON_DRAW_CANCEL); + I.waitForVisible(SELECTOR_ANNOTATION_BUTTON_DRAW); + + selectText(I, SELECTOR_TEXT_LAYER); + I.waitForVisible(SELECTOR_HIGHLIGHT_CONTROLS); + + /** Highlighting should still work after entering/exiting point mode */ + I.say('Enter point mode'); + enterPointMode(I); + + I.say('Starting creating point annotation'); + clickAtLocation(I, SELECTOR_TEXT_LAYER); + + I.say('Exit point mode'); + exitPointMode(I); + /* * Create plain highlight annotation */ @@ -40,7 +66,7 @@ Scenario('Create/Delete a new plain highlight annotation @desktop @doc', functio I.waitForText('Kanye West highlighted', 9, SELECTOR_ANNOTATOR_LABEL); I.waitForEnabled(SELECTOR_HIGHLIGHT_BTN); - validateIconColor(I, `${SELECTOR_HIGHLIGHT_BTN}`, 'rgb(255, 201, 0)'); + validateIconColor(I, SELECTOR_SAVED_HIGHLIGHT, 'rgb(254, 217, 78)'); /* * Delete plain highlight annotation