Skip to content

Commit

Permalink
New: UI tests to create/delete annotation replies
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsum committed Apr 24, 2018
1 parent db73de0 commit 3639df4
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 17 deletions.
7 changes: 5 additions & 2 deletions functional-tests/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ const CLASS_TEXTAREA = 'ba-textarea';
exports.SELECTOR_TEXTAREA = `.${CLASS_TEXTAREA}`;
const CLASS_ANNOTATION_TEXTAREA = 'annotation-textarea';
exports.SELECTOR_ANNOTATION_TEXTAREA = `.${CLASS_ANNOTATION_TEXTAREA}`;
const CLASS_REPLY_TEXTAREA = 'reply-textarea';
exports.SELECTOR_REPLY_TEXTAREA = `.${CLASS_REPLY_TEXTAREA}`;
const CLASS_INVALID_INPUT = 'ba-invalid-input';
exports.SELECTOR_INVALID_INPUT = `.${CLASS_INVALID_INPUT}`;

Expand Down Expand Up @@ -93,6 +91,11 @@ exports.SELECTOR_USER_NAME = `.${CLASS_USER_NAME}`;
const CLASS_COMMENT_DATE = 'comment-date';
exports.SELECTOR_COMMENT_DATE = `.${CLASS_COMMENT_DATE}`;

const CLASS_REPLY_CONTAINER = 'reply-container';
exports.SELECTOR_REPLY_CONTAINER = `.${CLASS_REPLY_CONTAINER}`;
const CLASS_REPLY_TEXTAREA = 'reply-textarea';
exports.SELECTOR_REPLY_TEXTAREA = `.${CLASS_REPLY_TEXTAREA}`;

const CLASS_CREATE_COMMENT = 'ba-create-comment';
exports.SELECTOR_CREATE_COMMENT = `.${CLASS_CREATE_COMMENT}`;

Expand Down
39 changes: 34 additions & 5 deletions functional-tests/tests/highlight_comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const {
SELECTOR_CANCEL_DELETE_BTN,
SELECTOR_CONFIRM_DELETE_BTN,
SELECTOR_ANNOTATION_COMMENT,
SELECTOR_REPLY_TEXTAREA
SELECTOR_REPLY_TEXTAREA,
SELECTOR_REPLY_CONTAINER
} = require('../helpers/constants');
const { expect } = require('chai');

Expand Down Expand Up @@ -65,7 +66,7 @@ Scenario('Cancel a new highlight comment annotation @desktop', function*(I) {
I.waitForVisible(SELECTOR_ADD_HIGHLIGHT_COMMENT_BTN);
});

Scenario('Create a new highlight comment annotation @desktop', function*(I) {
Scenario('Create/reply to a new highlight comment annotation @desktop', function*(I) {
I.waitForVisible(SELECTOR_ANNOTATIONS_LOADED);

I.say('Highlight dialog should appear after selecting text');
Expand Down Expand Up @@ -93,18 +94,35 @@ Scenario('Create a new highlight comment annotation @desktop', function*(I) {
I.waitForText('Kanye West', 10, SELECTOR_USER_NAME);

I.waitForVisible(`${SELECTOR_REPLY_TEXTAREA}${SELECTOR_ACTIVE}`);
const placeHolder = yield I.grabAttributeFrom(SELECTOR_REPLY_TEXTAREA, 'placeholder');
expect(placeHolder).to.equal('Post a reply...');
expect(yield I.grabAttributeFrom(SELECTOR_REPLY_TEXTAREA, 'placeholder')).to.equal('Post a reply...');
I.waitForVisible(SELECTOR_ANNOTATION_BUTTON_CANCEL);
I.waitForVisible(SELECTOR_ANNOTATION_BUTTON_POST);

I.say('Reply to highlight comment annotation');
I.fillField(SELECTOR_REPLY_TEXTAREA, 'Sample reply');
I.click(`${SELECTOR_REPLY_CONTAINER} ${SELECTOR_ANNOTATION_BUTTON_POST}`);

I.say('Reply should be added to dialog');
I.waitForVisible(SELECTOR_ANNOTATION_DIALOG);
I.waitForVisible(SELECTOR_ANNOTATION_CONTAINER);
I.waitNumberOfVisibleElements(SELECTOR_ANNOTATION_COMMENT, 2);
I.waitForEnabled(SELECTOR_DELETE_COMMENT_BTN);
I.waitForVisible(SELECTOR_PROFILE_IMG_CONTAINER);
I.waitForText('Kanye West', 10, SELECTOR_USER_NAME);

I.waitForVisible(`${SELECTOR_REPLY_CONTAINER} ${SELECTOR_REPLY_TEXTAREA}${SELECTOR_ACTIVE}`);
expect(yield I.grabAttributeFrom(`${SELECTOR_REPLY_CONTAINER} ${SELECTOR_REPLY_TEXTAREA}`, 'placeholder')).to.equal('Post a reply...');
I.waitForVisible(`${SELECTOR_REPLY_CONTAINER} ${SELECTOR_ANNOTATION_BUTTON_CANCEL}`);
I.waitForVisible(`${SELECTOR_REPLY_CONTAINER} ${SELECTOR_ANNOTATION_BUTTON_POST}`);
});

Scenario('Delete the highlight comment annotation @desktop', function(I) {
Scenario('Delete the highlight comment annotation and reply @desktop', function(I) {
I.waitForVisible(SELECTOR_ANNOTATIONS_LOADED);

I.say('Highlight dialog should appear on click');
I.click(`${SELECTOR_TEXT_LAYER} div`);
I.waitForVisible(SELECTOR_ANNOTATION_DIALOG);
I.waitNumberOfVisibleElements(SELECTOR_ANNOTATION_COMMENT, 2);
I.waitForEnabled(SELECTOR_DELETE_COMMENT_BTN);

I.say('Delete the highlight annotation');
Expand All @@ -126,6 +144,17 @@ Scenario('Delete the highlight comment annotation @desktop', function(I) {
I.waitForVisible(SELECTOR_CONFIRM_DELETE_BTN);
I.click(SELECTOR_CONFIRM_DELETE_BTN);

I.say('Highlight reply should be deleted');
I.waitForVisible(SELECTOR_ANNOTATION_DIALOG);
I.waitNumberOfVisibleElements(SELECTOR_ANNOTATION_COMMENT, 1);

I.say('Delete the highlight annotation');
I.click(SELECTOR_DELETE_COMMENT_BTN);

I.say('Delete confirmation should appear');
I.waitForVisible(SELECTOR_CONFIRM_DELETE_BTN);
I.click(SELECTOR_CONFIRM_DELETE_BTN);

I.say('Highlight should be deleted');
I.waitForDetached(SELECTOR_ANNOTATION_DIALOG, 5);
});
37 changes: 33 additions & 4 deletions functional-tests/tests/point.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const {
SELECTOR_REPLY_TEXTAREA,
SELECTOR_DELETE_CONFIRM_MESSAGE,
SELECTOR_CONFIRM_DELETE_BTN,
SELECTOR_CANCEL_DELETE_BTN
SELECTOR_CANCEL_DELETE_BTN,
SELECTOR_REPLY_CONTAINER
} = require('../helpers/constants');
const { expect } = require('chai');

Expand Down Expand Up @@ -80,7 +81,7 @@ Scenario('Cancel a new point annotation @desktop', function(I) {
I.waitForInvisible(SELECTOR_ANNOTATION_POINT_MARKER, 1);
});

Scenario('Create a new highlight comment annotation @desktop', function*(I) {
Scenario('Create/reply to a new point annotation @desktop', function*(I) {
I.waitForVisible(SELECTOR_ANNOTATIONS_LOADED);
I.waitForVisible(SELECTOR_ANNOTATION_BUTTON_POINT);

Expand All @@ -106,17 +107,34 @@ Scenario('Create a new highlight comment annotation @desktop', function*(I) {
I.waitForText('Kanye West', 10, SELECTOR_USER_NAME);

I.waitForVisible(`${SELECTOR_REPLY_TEXTAREA}${SELECTOR_ACTIVE}`);
const placeHolder = yield I.grabAttributeFrom(SELECTOR_REPLY_TEXTAREA, 'placeholder');
expect(placeHolder).to.equal('Post a reply...');
expect(yield I.grabAttributeFrom(SELECTOR_REPLY_TEXTAREA, 'placeholder')).to.equal('Post a reply...');
I.waitForVisible(SELECTOR_ANNOTATION_BUTTON_CANCEL);
I.waitForVisible(SELECTOR_ANNOTATION_BUTTON_POST);

I.say('Reply to point annotation');
I.fillField(SELECTOR_REPLY_TEXTAREA, 'Sample reply');
I.click(`${SELECTOR_REPLY_CONTAINER} ${SELECTOR_ANNOTATION_BUTTON_POST}`);

I.say('Reply should be added to dialog');
I.waitForVisible(SELECTOR_ANNOTATION_DIALOG);
I.waitForVisible(SELECTOR_ANNOTATION_CONTAINER);
I.waitNumberOfVisibleElements(SELECTOR_ANNOTATION_COMMENT, 2);
I.waitForEnabled(SELECTOR_DELETE_COMMENT_BTN);
I.waitForVisible(SELECTOR_PROFILE_IMG_CONTAINER);
I.waitForText('Kanye West', 10, SELECTOR_USER_NAME);

I.waitForVisible(`${SELECTOR_REPLY_CONTAINER} ${SELECTOR_REPLY_TEXTAREA}${SELECTOR_ACTIVE}`);
expect(yield I.grabAttributeFrom(`${SELECTOR_REPLY_CONTAINER} ${SELECTOR_REPLY_TEXTAREA}`, 'placeholder')).to.equal('Post a reply...');
I.waitForVisible(`${SELECTOR_REPLY_CONTAINER} ${SELECTOR_ANNOTATION_BUTTON_CANCEL}`);
I.waitForVisible(`${SELECTOR_REPLY_CONTAINER} ${SELECTOR_ANNOTATION_BUTTON_POST}`);
});

Scenario('Delete the point annotation @desktop', function(I) {
I.waitForVisible(SELECTOR_ANNOTATIONS_LOADED);

I.say('Point dialog should appear on click');
I.click(SELECTOR_ANNOTATION_POINT_MARKER);
I.waitNumberOfVisibleElements(SELECTOR_ANNOTATION_COMMENT, 2);
I.waitForVisible(SELECTOR_ANNOTATION_DIALOG);
I.waitForEnabled(SELECTOR_DELETE_COMMENT_BTN);

Expand All @@ -139,6 +157,17 @@ Scenario('Delete the point annotation @desktop', function(I) {
I.waitForVisible(SELECTOR_CONFIRM_DELETE_BTN);
I.click(SELECTOR_CONFIRM_DELETE_BTN);

I.say('Point reply should be deleted');
I.waitForVisible(SELECTOR_ANNOTATION_DIALOG);
I.waitNumberOfVisibleElements(SELECTOR_ANNOTATION_COMMENT, 1);

I.say('Delete the point annotation');
I.click(SELECTOR_DELETE_COMMENT_BTN);

I.say('Delete confirmation should appear');
I.waitForVisible(SELECTOR_CONFIRM_DELETE_BTN);
I.click(SELECTOR_CONFIRM_DELETE_BTN);

I.say('Point annotation should be deleted');
I.waitForDetached(SELECTOR_ANNOTATION_POINT_MARKER, 1);
I.waitForDetached(SELECTOR_ANNOTATION_DIALOG, 1);
Expand Down
15 changes: 9 additions & 6 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ export const CLASS_ANNOTATION_POINT_MARKER = 'ba-point-annotation-marker';
export const SELECTOR_ANNOTATION_POINT_MARKER = `.${CLASS_ANNOTATION_POINT_MARKER}`;
export const CLASS_ANNOTATION_POINT_BUTTON = 'ba-point-annotation-btn';
export const SELECTOR_ANNOTATION_POINT_BUTTON = `.${CLASS_ANNOTATION_POINT_BUTTON}`;
export const CLASS_HIGHLIGHT_QUAD_CORNER_CONTAINER = 'ba-quad-corner-container';
export const SELECTOR_HIGHLIGHT_QUAD_CORNER_CONTAINER = `.${CLASS_HIGHLIGHT_QUAD_CORNER_CONTAINER}`;
export const CLASS_HIGHLIGHT_QUAD_CORNER = 'ba-quad-corner';
export const SELECTOR_HIGHLIGHT_QUAD_CORNER = `.${CLASS_HIGHLIGHT_QUAD_CORNER}`;

// Dialog CSS constants
export const CLASS_ANNOTATION_DIALOG = 'ba-annotation-dialog';
Expand All @@ -59,8 +55,6 @@ export const CLASS_TEXTAREA = 'ba-textarea';
export const SELECTOR_TEXTAREA = `.${CLASS_TEXTAREA}`;
export const CLASS_ANNOTATION_TEXTAREA = 'annotation-textarea';
export const SELECTOR_ANNOTATION_TEXTAREA = `.${CLASS_ANNOTATION_TEXTAREA}`;
export const CLASS_REPLY_TEXTAREA = 'reply-textarea';
export const SELECTOR_REPLY_TEXTAREA = `.${CLASS_REPLY_TEXTAREA}`;
export const CLASS_INVALID_INPUT = 'ba-invalid-input';
export const SELECTOR_INVALID_INPUT = `.${CLASS_INVALID_INPUT}`;

Expand Down Expand Up @@ -95,6 +89,11 @@ export const SELECTOR_USER_NAME = `.${CLASS_USER_NAME}`;
export const CLASS_COMMENT_DATE = 'comment-date';
export const SELECTOR_COMMENT_DATE = `.${CLASS_COMMENT_DATE}`;

export const CLASS_REPLY_CONTAINER = 'reply-container';
export const SELECTOR_REPLY_CONTAINER = `.${CLASS_REPLY_CONTAINER}`;
export const CLASS_REPLY_TEXTAREA = 'reply-textarea';
export const SELECTOR_REPLY_TEXTAREA = `.${CLASS_REPLY_TEXTAREA}`;

export const CLASS_CREATE_COMMENT = 'ba-create-comment';
export const SELECTOR_CREATE_COMMENT = `.${CLASS_CREATE_COMMENT}`;

Expand All @@ -116,6 +115,10 @@ export const CLASS_ADD_HIGHLIGHT_BTN = 'ba-add-highlight-btn';
export const SELECTOR_ADD_HIGHLIGHT_BTN = `.${CLASS_ADD_HIGHLIGHT_BTN}`;
export const CLASS_ADD_HIGHLIGHT_COMMENT_BTN = 'ba-highlight-comment-btn';
export const SELECTOR_ADD_HIGHLIGHT_COMMENT_BTN = `.${CLASS_ADD_HIGHLIGHT_COMMENT_BTN}`;
export const CLASS_HIGHLIGHT_QUAD_CORNER_CONTAINER = 'ba-quad-corner-container';
export const SELECTOR_HIGHLIGHT_QUAD_CORNER_CONTAINER = `.${CLASS_HIGHLIGHT_QUAD_CORNER_CONTAINER}`;
export const CLASS_HIGHLIGHT_QUAD_CORNER = 'ba-quad-corner';
export const SELECTOR_HIGHLIGHT_QUAD_CORNER = `.${CLASS_HIGHLIGHT_QUAD_CORNER}`;

// Drawing dialog CSS constants
export const CLASS_ANNOTATION_DRAWING_LABEL = 'ba-annotation-drawing-label';
Expand Down

0 comments on commit 3639df4

Please sign in to comment.