From c20ff9d368315e2aadae1815fc9f0680c97a68af Mon Sep 17 00:00:00 2001 From: Juanfran Date: Tue, 10 May 2016 14:55:35 +0200 Subject: [PATCH] test e2e confirmation close wysiwyg --- e2e/helpers/detail-helper.js | 4 +- e2e/helpers/wiki-helper.js | 11 +++- e2e/shared/detail.js | 51 ++++++++++++++----- e2e/suites/issues/issue-detail.e2e.js | 2 +- e2e/suites/tasks/task-detail.e2e.js | 2 +- .../user-stories/user-story-detail.e2e.js | 2 +- e2e/suites/wiki.e2e.js | 23 +++++++++ e2e/utils/lightbox.js | 10 ++++ 8 files changed, 87 insertions(+), 18 deletions(-) diff --git a/e2e/helpers/detail-helper.js b/e2e/helpers/detail-helper.js index b97358ca..ebff2cf8 100644 --- a/e2e/helpers/detail-helper.js +++ b/e2e/helpers/detail-helper.js @@ -29,7 +29,9 @@ helper.description = function(){ let obj = { el: el, - + focus: function() { + el.$('textarea').click(); + }, enabledEditionMode: async function(){ await el.$(".view-description").click(); }, diff --git a/e2e/helpers/wiki-helper.js b/e2e/helpers/wiki-helper.js index f883e63d..214bf9b6 100644 --- a/e2e/helpers/wiki-helper.js +++ b/e2e/helpers/wiki-helper.js @@ -38,6 +38,10 @@ helper.editor = function(){ let obj = { el: el, + focus: function() { + el.$("textarea").click(); + }, + enabledEditionMode: async function(){ await el.$("section[tg-editable-wiki-content] .view-wiki-content").click(); }, @@ -58,7 +62,7 @@ helper.editor = function(){ }, getInnerHtml: async function(text){ - let wikiText = await el.$(".content").getInnerHtml(); + let wikiText = await el.$(".view-wiki-content .wysiwyg").getInnerHtml(); return wikiText; }, @@ -75,7 +79,10 @@ helper.editor = function(){ await el.$(".preview-icon a").click(); await browser.waitForAngular(); }, - + closePreview: async function(){ + await el.$(".actions .wysiwyg").click(); + await browser.waitForAngular(); + }, save: async function(){ await el.$(".save").click(); await browser.waitForAngular(); diff --git a/e2e/shared/detail.js b/e2e/shared/detail.js index f1e95ae8..fc59b856 100644 --- a/e2e/shared/detail.js +++ b/e2e/shared/detail.js @@ -3,6 +3,7 @@ var detailHelper = require('../helpers').detail; var commonHelper = require('../helpers').common; var customFieldsHelper = require('../helpers/custom-fields-helper'); var commonUtil = require('../utils/common'); +var lightbox = require('../utils/lightbox'); var notifications = require('../utils/notifications'); var chai = require('chai'); @@ -46,21 +47,47 @@ shared.tagsTesting = async function() { expect(newtagsText).to.be.not.eql(tagsText); } -shared.descriptionTesting = async function() { - let descriptionHelper = detailHelper.description(); - let description = await descriptionHelper.getInnerHtml(); - let date = Date.now(); - descriptionHelper.enabledEditionMode(); - descriptionHelper.setText("New description " + date); - descriptionHelper.save(); +shared.descriptionTesting = function() { + it('confirm close with ESC', async function() { + let descriptionHelper = detailHelper.description(); - let newDescription = await descriptionHelper.getInnerHtml(); - let notificationOpen = await notifications.success.open(); + descriptionHelper.enabledEditionMode(); - expect(notificationOpen).to.be.equal.true; - expect(newDescription).to.be.not.equal(description); + browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); - await notifications.success.close(); + await lightbox.confirm.cancel(); + + let descriptionVisibility = await $('.edit-description').isDisplayed(); + + expect(descriptionVisibility).to.be.true; + + descriptionHelper.focus(); + + browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); + + await lightbox.confirm.ok(); + + descriptionVisibility = await $('.edit-description').isDisplayed(); + + expect(descriptionVisibility).to.be.false; + }); + + it('edit', async function() { + let descriptionHelper = detailHelper.description(); + let description = await descriptionHelper.getInnerHtml(); + let date = Date.now(); + descriptionHelper.enabledEditionMode(); + descriptionHelper.setText("New description " + date); + descriptionHelper.save(); + + let newDescription = await descriptionHelper.getInnerHtml(); + let notificationOpen = await notifications.success.open(); + + expect(notificationOpen).to.be.equal.true; + expect(newDescription).to.be.not.equal(description); + + await notifications.success.close(); + }); } shared.statusTesting = async function(status1 , status2) { diff --git a/e2e/suites/issues/issue-detail.e2e.js b/e2e/suites/issues/issue-detail.e2e.js index b713dbaa..af466e1c 100644 --- a/e2e/suites/issues/issue-detail.e2e.js +++ b/e2e/suites/issues/issue-detail.e2e.js @@ -29,7 +29,7 @@ describe('Issue detail', async function(){ it('tags edition', sharedDetail.tagsTesting); - it('description edition', sharedDetail.descriptionTesting); + describe('description', sharedDetail.descriptionTesting); it('status edition', sharedDetail.statusTesting.bind(this, 'In progress', 'Ready for test')); diff --git a/e2e/suites/tasks/task-detail.e2e.js b/e2e/suites/tasks/task-detail.e2e.js index 850cd3e1..74fab211 100644 --- a/e2e/suites/tasks/task-detail.e2e.js +++ b/e2e/suites/tasks/task-detail.e2e.js @@ -31,7 +31,7 @@ describe('Task detail', function(){ it('tags edition', sharedDetail.tagsTesting); - it('description edition', sharedDetail.descriptionTesting); + describe('description', sharedDetail.descriptionTesting); it('status edition', sharedDetail.statusTesting.bind(this, 'In progress', 'Ready for test')); diff --git a/e2e/suites/user-stories/user-story-detail.e2e.js b/e2e/suites/user-stories/user-story-detail.e2e.js index e63d3294..e3e21339 100644 --- a/e2e/suites/user-stories/user-story-detail.e2e.js +++ b/e2e/suites/user-stories/user-story-detail.e2e.js @@ -30,7 +30,7 @@ describe('User story detail', function(){ it('tags edition', sharedDetail.tagsTesting); - it('description edition', sharedDetail.descriptionTesting); + describe('description', sharedDetail.descriptionTesting); it('status edition', sharedDetail.statusTesting.bind(this, 'Ready', 'In progress')); diff --git a/e2e/suites/wiki.e2e.js b/e2e/suites/wiki.e2e.js index f0c37d72..0429e0be 100644 --- a/e2e/suites/wiki.e2e.js +++ b/e2e/suites/wiki.e2e.js @@ -60,6 +60,7 @@ describe('wiki', function() { //preview wikiHelper.editor().preview(); await utils.common.takeScreenshot("wiki", "home-edition-preview"); + wikiHelper.editor().closePreview(); //save wikiHelper.editor().save(); @@ -74,6 +75,28 @@ describe('wiki', function() { await utils.common.takeScreenshot("wiki", "home-edition"); }); + it('confirm close with ESC in lightbox', async function() { + wikiHelper.editor().enabledEditionMode(); + + browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); + + await utils.lightbox.confirm.cancel(); + + let descriptionVisibility = await $('.view-wiki-content').isDisplayed(); + + expect(descriptionVisibility).to.be.false; + + wikiHelper.editor().focus(); + + browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); + + await utils.lightbox.confirm.ok(); + + descriptionVisibility = await $('.view-wiki-content').isDisplayed(); + + expect(descriptionVisibility).to.be.true; + }); + it('attachments', sharedDetail.attachmentTesting); it('delete', async function() { diff --git a/e2e/utils/lightbox.js b/e2e/utils/lightbox.js index 471bb098..9b8fe6d8 100644 --- a/e2e/utils/lightbox.js +++ b/e2e/utils/lightbox.js @@ -71,3 +71,13 @@ lightbox.confirm.ok = async function() { await lightbox.close(lb); }; + + +lightbox.confirm.cancel = async function() { + let lb = $('.lightbox-generic-ask'); + await lightbox.open(lb); + + lb.$('.button-red').click(); + + await lightbox.close(lb); +};