From 4f01ceb2f23cebe999f89f0aca70946b753a2c2d Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 24 Jul 2015 12:45:35 +0200 Subject: [PATCH] Adding tests for history tabs --- e2e/full/issues/issue-detail.e2e.js | 3 + e2e/full/tasks/task-detail.e2e.js | 2 + .../user-stories/user-story-detail.e2e.js | 2 + e2e/helpers/detail-helper.js | 67 +++++++++++++++++++ e2e/utils/detail.js | 29 ++++++++ 5 files changed, 103 insertions(+) diff --git a/e2e/full/issues/issue-detail.e2e.js b/e2e/full/issues/issue-detail.e2e.js index b4ba4054..1ddd2b5b 100644 --- a/e2e/full/issues/issue-detail.e2e.js +++ b/e2e/full/issues/issue-detail.e2e.js @@ -28,6 +28,8 @@ describe('Issue detail', async function(){ it('assigned to edition', utils.detail.assignedToTesting); + it('history', utils.detail.historyTesting); + it('screenshot', async function() { await utils.common.takeScreenshot("issues", "detail updated"); }); @@ -38,4 +40,5 @@ describe('Issue detail', async function(){ let url = await browser.getCurrentUrl(); expect(url.endsWith(issuesUrl)).to.be.true; }); + }) diff --git a/e2e/full/tasks/task-detail.e2e.js b/e2e/full/tasks/task-detail.e2e.js index 7bcaeda3..5df24b11 100644 --- a/e2e/full/tasks/task-detail.e2e.js +++ b/e2e/full/tasks/task-detail.e2e.js @@ -29,6 +29,8 @@ describe('Task detail', function(){ it('assigned to edition', utils.detail.assignedToTesting); + it('history', utils.detail.historyTesting); + it('screenshot', async function() { await utils.common.takeScreenshot("tasks", "detail updated"); }); diff --git a/e2e/full/user-stories/user-story-detail.e2e.js b/e2e/full/user-stories/user-story-detail.e2e.js index 60c73e43..b1ff45a6 100644 --- a/e2e/full/user-stories/user-story-detail.e2e.js +++ b/e2e/full/user-stories/user-story-detail.e2e.js @@ -28,6 +28,8 @@ describe('User story detail', function(){ it('assigned to edition', utils.detail.assignedToTesting); + it('history', utils.detail.historyTesting); + it('screenshot', async function() { await utils.common.takeScreenshot("user-stories", "detail updated"); }); diff --git a/e2e/helpers/detail-helper.js b/e2e/helpers/detail-helper.js index 0a54c31e..c63b829d 100644 --- a/e2e/helpers/detail-helper.js +++ b/e2e/helpers/detail-helper.js @@ -133,6 +133,73 @@ helper.assignToLightbox = function() { return obj; }; +helper.history = function() { + let el = $('section.history'); + let obj = { + el:el, + + selectCommentsTab: function() { + el.$$('.history-tabs li a').first().click(); + }, + + selectActivityTab: function() { + el.$$('.history-tabs li a').last().click(); + }, + + addComment: async function(comment) { + el.$('textarea[tg-markitup]').sendKeys(comment); + el.$('input.save-comment').click(); + await browser.waitForAngular(); + }, + + countComments: async function() { + let moreComments = el.$('.comments-list .show-more-comments') + let moreCommentsIsPresent = await moreComments.isPresent(); + if (moreCommentsIsPresent){ + moreComments.click(); + } + await browser.waitForAngular(); + let comments = await el.$$(".activity-single.comment"); + return comments.length; + }, + + countActivities: async function() { + let moreActivities = el.$('.changes-list .show-more-comments') + let selectActivityTabIsPresent = await moreActivities.isPresent(); + if (selectActivityTabIsPresent){ + moreActivities.click(); + } + await browser.waitForAngular(); + let activities = await el.$$(".activity-single.activity"); + return activities.length; + }, + + countDeletedComments: async function() { + let moreComments = el.$('.comments-list .show-more-comments') + let moreCommentsIsPresent = await moreComments.isPresent(); + if (moreCommentsIsPresent){ + moreComments.click(); + } + await browser.waitForAngular(); + let comments = await el.$$(".activity-single.comment.deleted-comment"); + return comments.length; + }, + + deleteLastComment: async function() { + el.$$(".activity-single.comment .comment-delete").last().click(); + await browser.waitForAngular(); + }, + + restoreLastComment: async function() { + el.$$(".activity-single.comment.deleted-comment .comment-restore").last().click(); + await browser.waitForAngular(); + } + } + + return obj; + +} + helper.delete = function() { let el = $('tg-delete-button'); diff --git a/e2e/utils/detail.js b/e2e/utils/detail.js index bffe6775..8cc4e4fe 100644 --- a/e2e/utils/detail.js +++ b/e2e/utils/detail.js @@ -54,6 +54,35 @@ helper.assignedToTesting = async function() { expect(newUserName).to.be.not.equal(userName); } +helper.historyTesting = async function() { + let historyHelper = detailHelper.history(); + + //Adding a comment + historyHelper.selectCommentsTab(); + let commentsCounter = await historyHelper.countComments(); + let date = Date.now() + await historyHelper.addComment("New comment " + date); + let newCommentsCounter = await historyHelper.countComments(); + expect(newCommentsCounter).to.be.equal(commentsCounter+1); + + //Deleting last comment + let deletedCommentsCounter = await historyHelper.countDeletedComments(); + await historyHelper.deleteLastComment(); + let newDeletedCommentsCounter = await historyHelper.countDeletedComments(); + expect(newDeletedCommentsCounter).to.be.equal(deletedCommentsCounter+1); + + //Restore last coment + deletedCommentsCounter = await historyHelper.countDeletedComments(); + await historyHelper.restoreLastComment(); + newDeletedCommentsCounter = await historyHelper.countDeletedComments(); + expect(newDeletedCommentsCounter).to.be.equal(deletedCommentsCounter-1); + + //Check activity + historyHelper.selectActivityTab(); + let activitiesCounter = await historyHelper.countActivities(); + expect(activitiesCounter).to.be.least(newCommentsCounter); +} + helper.deleteTesting = async function() { let deleteHelper = detailHelper.delete(); await deleteHelper.delete();