Skip to content

Commit

Permalink
Fix: Functional tests (#320)
Browse files Browse the repository at this point in the history
- Add test to ensure highlighting works even after interacting w/ drawing/point modes
  • Loading branch information
pramodsum committed Jan 3, 2019
1 parent 538fbd2 commit bba4a9c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 14 deletions.
24 changes: 17 additions & 7 deletions functional-tests/helpers/actions.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
/* 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,
SELECTOR_ACTION_CONTROLS,
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,
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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;
2 changes: 1 addition & 1 deletion functional-tests/helpers/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 0 additions & 3 deletions functional-tests/tests/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
32 changes: 29 additions & 3 deletions functional-tests/tests/plain_highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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
*/
Expand All @@ -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
Expand Down

0 comments on commit bba4a9c

Please sign in to comment.