diff --git a/e2e/full/issues/issue-detail.e2e.js b/e2e/full/issues/issue-detail.e2e.js index 789c7125..8cd1f86e 100644 --- a/e2e/full/issues/issue-detail.e2e.js +++ b/e2e/full/issues/issue-detail.e2e.js @@ -36,10 +36,13 @@ describe('Issue detail', async function(){ it('block', utils.detail.blockTesting); + it('attachments', utils.detail.attachmentTesting) + it('delete', utils.detail.deleteTesting); it('redirected', 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 d5cde251..9b68993f 100644 --- a/e2e/full/tasks/task-detail.e2e.js +++ b/e2e/full/tasks/task-detail.e2e.js @@ -37,6 +37,8 @@ describe('Task detail', function(){ it('block', utils.detail.blockTesting); + it('attachments', utils.detail.attachmentTesting) + it('delete', utils.detail.deleteTesting); it('redirected', async function (){ diff --git a/e2e/full/user-stories/user-story-detail.e2e.js b/e2e/full/user-stories/user-story-detail.e2e.js index 95c4ec74..1750f118 100644 --- a/e2e/full/user-stories/user-story-detail.e2e.js +++ b/e2e/full/user-stories/user-story-detail.e2e.js @@ -36,6 +36,8 @@ describe('User story detail', function(){ it('block', utils.detail.blockTesting); + it('attachments', utils.detail.attachmentTesting) + it('delete', utils.detail.deleteTesting); it('redirected', async function (){ diff --git a/e2e/full/wiki.e2e.js b/e2e/full/wiki.e2e.js index 72f9d5ae..72cd248c 100644 --- a/e2e/full/wiki.e2e.js +++ b/e2e/full/wiki.e2e.js @@ -84,5 +84,5 @@ describe('wiki', function() { expect(text).to.be.equal("\n- aa"); }); - //TODO attachments + it('attachments', utils.detail.attachmentTesting); }); diff --git a/e2e/helpers/detail-helper.js b/e2e/helpers/detail-helper.js index ec9b58cb..a3525967 100644 --- a/e2e/helpers/detail-helper.js +++ b/e2e/helpers/detail-helper.js @@ -1,5 +1,4 @@ var utils = require('../utils'); - var helper = module.exports; helper.title = function() { @@ -254,3 +253,64 @@ helper.delete = function() { return obj; } + +helper.attachment = function() { + let el = $('tg-attachments'); + + let obj = { + el:el, + upload: async function(filePath, name) { + await el.$('#add-attach').sendKeys(filePath); + await browser.waitForAngular(); + //TODO: ask JF why this is needed + await browser.sleep(2000) + await el.$$('div[tg-attachment] .editable-attachment-comment input').last().sendKeys(name); + await browser.actions().sendKeys(protractor.Key.ENTER).perform(); + await browser.waitForAngular(); + }, + + renameLastAttchment: async function (name) { + await browser.actions().mouseMove(el.$$('div[tg-attachment]').last()).perform(); + await el.$$('div[tg-attachment] .attachment-settings .icon-edit').last().click(); + await el.$$('div[tg-attachment] .editable-attachment-comment input').last().sendKeys(name); + await browser.actions().sendKeys(protractor.Key.ENTER).perform(); + await browser.waitForAngular(); + }, + + getLastAttachmentName: async function () { + let name = await el.$$('div[tg-attachment] .attachment-comments').last().getText(); + return name; + }, + + countAttachments: async function(){ + let attachments = await el.$$('div[tg-attachment] .attachment-comments') + return attachments.length; + }, + + countDeprecatedAttachments: async function(){ + let attachmentsJSON = await el.$$('.more-attachments .more-attachments-num').getAttribute('translate-values'); + return parseInt(eval(attachmentsJSON[0])); + }, + + deprecateLastAttachment: async function() { + await browser.actions().mouseMove(el.$$('div[tg-attachment]').last()).perform(); + await el.$$('div[tg-attachment] .attachment-settings .icon-edit').last().click(); + await el.$$('div[tg-attachment] .editable-attachment-deprecated input').last().click(); + await el.$$('div[tg-attachment] .attachment-settings .editable-settings.icon-floppy').last().click(); + await browser.waitForAngular(); + }, + + showDeprecated: async function(){ + await el.$('.more-attachments-num').click(); + }, + + deleteLastAttachment: async function() { + await browser.actions().mouseMove(el.$$('div[tg-attachment]').last()).perform(); + await el.$$('div[tg-attachment] .attachment-settings .icon-delete').last().click(); + await utils.lightbox.confirm.ok(); + await browser.waitForAngular(); + }, + } + + return obj; +} diff --git a/e2e/upload-file-test.txt b/e2e/upload-file-test.txt new file mode 100644 index 00000000..d5c7132a --- /dev/null +++ b/e2e/upload-file-test.txt @@ -0,0 +1 @@ +This is a testing file diff --git a/e2e/utils/detail.js b/e2e/utils/detail.js index 727428e9..c7ea6f04 100644 --- a/e2e/utils/detail.js +++ b/e2e/utils/detail.js @@ -1,3 +1,4 @@ +var path = require('path'); var detailHelper = require('../helpers').detail; var chai = require('chai'); @@ -84,17 +85,60 @@ helper.historyTesting = async function() { } helper.blockTesting = function() { - let blockHelper = detailHelper.block(); - let blockLightboxHelper = detailHelper.blockLightbox(); - blockHelper.block(); - blockLightboxHelper.waitOpen(); - blockLightboxHelper.fill('This is a testing block reason'); - blockLightboxHelper.submit(); - blockLightboxHelper.waitClose(); - expect($('.block-description').getText()).to.be.eventually.equal('This is a testing block reason'); - expect($('.block-description').isDisplayed()).to.be.eventually.true; - blockHelper.unblock(); - expect($('.block-description').isDisplayed()).to.be.eventually.false; + let blockHelper = detailHelper.block(); + let blockLightboxHelper = detailHelper.blockLightbox(); + blockHelper.block(); + blockLightboxHelper.waitOpen(); + blockLightboxHelper.fill('This is a testing block reason'); + blockLightboxHelper.submit(); + blockLightboxHelper.waitClose(); + expect($('.block-description').getText()).to.be.eventually.equal('This is a testing block reason'); + expect($('.block-description').isDisplayed()).to.be.eventually.true; + blockHelper.unblock(); + expect($('.block-description').isDisplayed()).to.be.eventually.false; +} + +helper.attachmentTesting = async function() { + let attachmentHelper = detailHelper.attachment(); + let date = Date.now(); + + // Uploading attachment + let attachmentsLength = await attachmentHelper.countAttachments(); + var fileToUpload = './upload-file-test.txt', + absolutePath = path.resolve(process.cwd(), 'e2e', fileToUpload); + await attachmentHelper.upload(absolutePath, 'This is the testing name ' + date); + + // Check set name + let name = await attachmentHelper.getLastAttachmentName(); + expect(name).to.be.equal('This is the testing name ' + date); + + // Check new length + let newAttachmentsLength = await attachmentHelper.countAttachments(); + expect(newAttachmentsLength).to.be.equal(attachmentsLength + 1); + + // Renaming + await attachmentHelper.renameLastAttchment('This is the new testing name ' + date); + name = await attachmentHelper.getLastAttachmentName(); + expect(name).to.be.equal('This is the new testing name ' + date) + + // Deprecating + let deprecatedAttachmentsLength = await attachmentHelper.countDeprecatedAttachments(); + await attachmentHelper.deprecateLastAttachment(); + let newDeprecatedAttachmentsLength = await attachmentHelper.countDeprecatedAttachments(); + expect(newDeprecatedAttachmentsLength).to.be.equal(deprecatedAttachmentsLength + 1); + + // Show deprecated + attachmentsLength = await attachmentHelper.countAttachments(); + deprecatedAttachmentsLength = await attachmentHelper.countDeprecatedAttachments(); + await attachmentHelper.showDeprecated(); + newAttachmentsLength = await attachmentHelper.countAttachments(); + expect(newAttachmentsLength).to.be.equal(attachmentsLength + deprecatedAttachmentsLength); + + // Deleting + attachmentsLength = await attachmentHelper.countAttachments(); + await attachmentHelper.deleteLastAttachment(); + newAttachmentsLength = await attachmentHelper.countAttachments(); + expect(newAttachmentsLength).to.be.equal(attachmentsLength - 1); } helper.deleteTesting = async function() {