diff --git a/.gitignore b/.gitignore index 18a1d2d1..ae661769 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ tmp/ app/config/main.coffee app/plugins/taiga-front-extras scss-lint.log +e2e/screenshots/ diff --git a/app/coffee/modules/common/attachments.coffee b/app/coffee/modules/common/attachments.coffee index 0c521519..fb966130 100644 --- a/app/coffee/modules/common/attachments.coffee +++ b/app/coffee/modules/common/attachments.coffee @@ -197,6 +197,7 @@ AttachmentsDirective = ($config, $confirm, $templates, $translate) -> $el.on "change", ".attachments-header input", (event) -> files = _.toArray(event.target.files) + return if files.length < 1 $scope.$apply -> @@ -336,4 +337,4 @@ AttachmentDirective = ($template, $compile, $translate, $rootScope) -> restrict: "AE" } -module.directive("tgAttachment", ["$tgTemplate", "$compile", "$translate", "$rootScope", AttachmentDirective]) \ No newline at end of file +module.directive("tgAttachment", ["$tgTemplate", "$compile", "$translate", "$rootScope", AttachmentDirective]) diff --git a/conf.e2e.js b/conf.e2e.js index 3622aa4c..e5682b17 100644 --- a/conf.e2e.js +++ b/conf.e2e.js @@ -10,7 +10,13 @@ exports.config = { framework: 'mocha', params: { glob: { - host: 'http://localhost:9001/' + host: 'http://localhost:9001/', + attachments: { + unix: './upload-file-test.txt', + windows: 'C:\\test\\upload-file-test.txt', + unixImg: './upload-image-test.png', + windowsImg: 'C:\\test\\upload-image-test.png' + } } }, mochaOpts: { @@ -18,7 +24,8 @@ exports.config = { compilers: 'js:babel/register' }, // capabilities: { - // 'browserName': 'firefox' + // browserName: 'internet explorer', + // version: '11' // }, suites: { auth: "e2e/auth/*.e2e.js", @@ -37,6 +44,8 @@ exports.config = { team: "e2e/full/team.e2e.js" }, onPrepare: function() { + require('./e2e/capabilities.js'); + browser.driver.manage().window().maximize(); browser.getCapabilities().then(function (cap) { diff --git a/e2e/capabilities.js b/e2e/capabilities.js new file mode 100644 index 00000000..f754e79f --- /dev/null +++ b/e2e/capabilities.js @@ -0,0 +1,102 @@ +//////////////////////////////////////////////// +// Protractor Browser Capabilities Extensions // +//////////////////////////////////////////////// +"use strict"; + +module.exports = browser.getCapabilities().then(function(s) { + var browserName, browserVersion; + var shortName, shortVersion; + var ie, ff, ch, sa; + var platform; + platform = s.caps_.platform; + browserName = s.caps_.browserName; + browserVersion = s.caps_.version; + shortVersion = browserVersion.split('.')[0]; + ie = /i.*explore/.test(browserName); + ff = /firefox/.test(browserName); + ch = /chrome/.test(browserName); + sa = /safari/.test(browserName); + + if (ie) { + shortName = 'ie'; + } else if (ff) { + shortName = 'ff'; + } else if (ch) { + shortName = 'ch'; + } else if (sa) { + shortName = 'sa'; + } else { + throw new Exception('Unsupported browser: '+ browserName); + }; + + // Returns one of these: ['ch', 'ff', 'sa', 'ie'] + browser.getShortBrowserName = function() { + return shortName; + }; + + // Returns one of these: ['ch33', 'ff27', 'sa7', 'ie11', 'ie10', 'ie9'] + browser.getShortNameVersionAll = function() { + return shortName + shortVersion; + }; + + // Returns one of these: ['ch', 'ff', 'sa', 'ie11', 'ie10', 'ie9'] + browser.getShortNameVersion = function() { + if (ie) { + return shortName + shortVersion; + } else { + return shortName; + }; + }; + + // Return if current browser is IE, optionally specifying if it is a particular IE version + browser.isInternetExplorer = function(ver) { + if (ver == null) { + return ie; + } else { + return ie && ver.toString() === shortVersion; + } + }; + + // Function alias + browser.isIE = browser.isInternetExplorer; + + browser.isSafari = function() { + return sa; + }; + + browser.isFirefox = function() { + return ff; + }; + + // Return if current browser is Chrome, optionally specifying if it is a particular Chrome version + browser.isChrome = function(ver) { + if (ver == null) { + return ch; + } else { + return ch && ver.toString() === shortVersion; + } + }; + + browser.inWindows = function() { + return /^WIN|XP/.test(platform); + }; + + browser.inOSX = function() { + return /^MAC/.test(platform); + }; + + // Save current webdriver session id for later use + browser.webdriverRemoteSessionId = s.caps_['webdriver.remote.sessionid']; + + browser.inSauceLabs = function() { + return !!(browser.params.inSauceLabs); + }; + + browser.inBrowserStack = function() { + return !!(browser.params.inBrowserStack); + }; + + browser.inTheCloud = function() { + return !!(browser.params.inSauceLabs || browser.params.inBrowserStack); + }; +}); diff --git a/e2e/full/backlog.e2e.js b/e2e/full/backlog.e2e.js index d3787aa9..8cc5b9e3 100644 --- a/e2e/full/backlog.e2e.js +++ b/e2e/full/backlog.e2e.js @@ -322,7 +322,7 @@ describe('backlog', function() { expect(ussSprintCount).to.be.equal(initUssSprintCount + 1); }); - it('select us with SHIFT', async function() { + utils.common.browserSkip('internet explorer', 'select us with SHIFT', async function() { let dragableElements = backlogHelper.userStories(); let firstInput = dragableElements.get(0).$('input[type="checkbox"]'); diff --git a/e2e/full/user-profile/edit-user-profile.e2e.js b/e2e/full/user-profile/edit-user-profile.e2e.js index 0aef0a36..4026ec6f 100644 --- a/e2e/full/user-profile/edit-user-profile.e2e.js +++ b/e2e/full/user-profile/edit-user-profile.e2e.js @@ -48,8 +48,9 @@ describe('edit user profile', function() { let imageContainer = $('.image-container'); let htmlChanges = await utils.common.outerHtmlChanges(imageContainer); + var fileToUpload = utils.common.uploadImagePath(); - await utils.common.uploadFile(inputFile, './upload-image-test.png'); + await utils.common.uploadFile(inputFile, fileToUpload); await htmlChanges(); diff --git a/e2e/utils/common.js b/e2e/utils/common.js index e0229356..820ad23b 100644 --- a/e2e/utils/common.js +++ b/e2e/utils/common.js @@ -36,8 +36,7 @@ common.browserSkip = function(browserName, name, fn) { if (browser.browserName !== browserName) { return it.call(this, name, fn); } else { - // return it.skip.call(this, name, fn); - return it.call(this, name, fn); + return it.skip.call(this, name, fn); } }; @@ -317,11 +316,9 @@ common.uploadFile = async function(inputFile, filePath) { $(arguments[0]).removeClass('hidden'); }; - let absolutePath = path.resolve(process.cwd(), 'e2e', filePath); - await browser.executeScript(toggleInput, inputFile.getWebElement()); - await inputFile.sendKeys(absolutePath); + await inputFile.sendKeys(filePath); await browser.executeScript(toggleInput, inputFile.getWebElement()); }; @@ -362,3 +359,19 @@ common.goToFirstTask = async function() { await common.waitLoader(); } + +common.uploadFilePath = function() { + if (browser.inWindows()) { + return browser.params.glob.attachments.windows; + } else { + return path.resolve(process.cwd(), 'e2e', browser.params.glob.attachments.unix); + } +}; + +common.uploadImagePath = function() { + if (browser.inWindows()) { + return browser.params.glob.attachments.windowsImg; + } else { + return path.resolve(process.cwd(), 'e2e', browser.params.glob.attachments.unixImg); + } +}; diff --git a/e2e/utils/detail.js b/e2e/utils/detail.js index 9f914e5f..9cf005d9 100644 --- a/e2e/utils/detail.js +++ b/e2e/utils/detail.js @@ -141,9 +141,9 @@ helper.attachmentTesting = async function() { // 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); + var fileToUpload = commonUtil.uploadFilePath(); + + await attachmentHelper.upload(fileToUpload, 'This is the testing name ' + date); // Check set name let name = await attachmentHelper.getLastAttachmentName(); diff --git a/e2e/utils/nav.js b/e2e/utils/nav.js index 22e436ba..98b3a0a1 100644 --- a/e2e/utils/nav.js +++ b/e2e/utils/nav.js @@ -8,7 +8,7 @@ var actions = { let project = $$('div[tg-dropdown-project-list] li a').get(index); - common.link(project); + project.click(); common.waitLoader(); },