diff --git a/e2e/full/admin/attributes/custom-fields.e2e.js b/e2e/full/admin/attributes/custom-fields.e2e.js index 2d98ea4e..053d2186 100644 --- a/e2e/full/admin/attributes/custom-fields.e2e.js +++ b/e2e/full/admin/attributes/custom-fields.e2e.js @@ -1,6 +1,5 @@ var utils = require('../../../utils'); - -var adminAttributesHelper = require('../../../helpers').adminAttributes; +var customFieldsHelper = require('../../../helpers/custom-fields-helper'); var chai = require('chai'); var chaiAsPromised = require('chai-as-promised'); @@ -8,116 +7,181 @@ var chaiAsPromised = require('chai-as-promised'); chai.use(chaiAsPromised); var expect = chai.expect; -describe('attributes - custom fields', function() { - before(async function(){ - browser.get('http://localhost:9001/project/project-0/admin/project-values/custom-fields'); - +describe('custom-fields', function() { + before(async function() { + browser.get('http://localhost:9001/project/project-3/admin/project-values/custom-fields'); await utils.common.waitLoader(); utils.common.takeScreenshot('attributes', 'custom-fields'); }); - it('new', async function() { - let section = adminAttributesHelper.getSection(0); - let rows = section.rows(); - let count = await rows.count(); + describe('create custom fields', function() { + describe('userstories', function() { + let typeIndex = 0; - let formWrapper = section.openNew(); + it('create', async function() { + let oldCountCustomFields = await customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - let form = adminAttributesHelper.getCustomFieldsForm(formWrapper); + customFieldsHelper.create(typeIndex, 'test1-text', 'desc1', 1); - await form.name().sendKeys('test test'); + // debounce :( + await utils.notifications.success.open(); + await browser.sleep(2000); - await form.save(); + customFieldsHelper.create(typeIndex, 'test1-multi', 'desc1', 3); - await browser.waitForAngular(); + // debounce :( + await utils.notifications.success.open(); + await browser.sleep(2000); - let newCount = await rows.count(); + // customFieldsHelper.create(typeIndex, 'test1-date', 'desc1', 4); - expect(newCount).to.be.equal(count + 1); - }); + // // debounce :( + // await utils.notifications.success.open(); + // await browser.sleep(2000); - it('duplicate', async function() { - let section = adminAttributesHelper.getSection(0); - let rows = section.rows(); - let count = await rows.count(); + let countCustomFields = customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - let formWrapper = section.openNew(); + expect(countCustomFields).to.be.eventually.equal(oldCountCustomFields + 2); + }); - let form = adminAttributesHelper.getCustomFieldsForm(formWrapper); + it('edit', async function() { + customFieldsHelper.edit(typeIndex, 0, 'edit', 'desc2', 2); - await form.name().sendKeys('test test'); + expect(utils.notifications.success.open()).to.be.eventually.true; + }); - await form.save(); + it('drag', async function() { + let nameOld = await customFieldsHelper.getName(typeIndex, 0); - await browser.waitForAngular(); + await customFieldsHelper.drag(typeIndex, 0, 1); - let newCount = await rows.count(); + let nameNew = customFieldsHelper.getName(typeIndex, 1); - let errors = await form.errors().count(); + expect(nameNew).to.be.eventually.equal(nameOld); + }); - utils.common.takeScreenshot('attributes', 'status-error'); + it('delete', async function() { + let oldCountCustomFields = await customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - expect(errors).to.be.equal(1); - expect(newCount).to.be.equal(count); - }); + customFieldsHelper.delete(typeIndex, 0); - it('delete', async function() { - let section = adminAttributesHelper.getSection(0); - let rows = section.rows(); + let countCustomFields = customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - let count = await rows.count(); + expect(countCustomFields).to.be.eventually.equal(oldCountCustomFields - 1); + }); + }); - let row = rows.get(count - 1); + describe('tasks', function() { + let typeIndex = 1; - section.delete(row); + it('create', async function() { + let oldCountCustomFields = await customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - let el = $('.lightbox-generic-ask'); + customFieldsHelper.create(typeIndex, 'test1-text', 'desc1', 1); - await utils.lightbox.open(el); + // debounce :( + await utils.notifications.success.open(); + await browser.sleep(2000); - utils.common.takeScreenshot('attributes', 'delete-custom-field'); + customFieldsHelper.create(typeIndex, 'test1-multi', 'desc1', 3); - el.$('.button-green').click(); + // debounce :( + await utils.notifications.success.open(); + await browser.sleep(2000); - await utils.lightbox.close(el); + // customFieldsHelper.create(typeIndex, 'test1-date', 'desc1', 4); - let newCount = await rows.count(); + // // debounce :( + // await utils.notifications.success.open(); + // await browser.sleep(2000); - expect(newCount).to.be.equal(count - 1); - }); + let countCustomFields = customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - it('edit', async function() { - let section = adminAttributesHelper.getSection(0); - let rows = section.rows(); - let row = rows.get(0); + expect(countCustomFields).to.be.eventually.equal(oldCountCustomFields + 2); + }); - await section.edit(row); + it('edit', async function() { + customFieldsHelper.edit(typeIndex, 0, 'edit', 'desc2', 2); - let form = adminAttributesHelper.getCustomFieldsForm(row.$('form')); + expect(utils.notifications.success.open()).to.be.eventually.true; + }); - let newCfName = 'test test' + Date.now(); - await form.name().clear(); - await form.name().sendKeys(newCfName); + it('drag', async function() { + let nameOld = await customFieldsHelper.getName(typeIndex, 0); - await form.save(); + await customFieldsHelper.drag(typeIndex, 0, 1); - await browser.waitForAngular(); + let nameNew = customFieldsHelper.getName(typeIndex, 1); - let newCfs = await adminAttributesHelper.getCustomFieldsNames(section.el); + expect(nameNew).to.be.eventually.equal(nameOld); + }); - expect(newCfs.indexOf(newCfName)).to.be.not.equal(-1); - }); + it('delete', async function() { + let oldCountCustomFields = await customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - it('drag', async function() { - let section = adminAttributesHelper.getSection(0); - let rows = section.rows(); - let cfs = await adminAttributesHelper.getCustomFieldsNames(section.el); + customFieldsHelper.delete(typeIndex, 0); - await utils.common.drag(rows.get(0), rows.get(2)); + let countCustomFields = customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - let newCfs = await adminAttributesHelper.getCustomFieldsNames(section.el); + expect(countCustomFields).to.be.eventually.equal(oldCountCustomFields - 1); + }); + }); - expect(cfs[0]).to.be.equal(newCfs[1]); + describe('issues', function() { + let typeIndex = 2; + + it('create', async function() { + let oldCountCustomFields = await customFieldsHelper.getCustomFiledsByType(typeIndex).count(); + + customFieldsHelper.create(typeIndex, 'test1-text', 'desc1', 1); + + // debounce :( + await utils.notifications.success.open(); + await browser.sleep(2000); + + customFieldsHelper.create(typeIndex, 'test1-multi', 'desc1', 3); + + // debounce :( + await utils.notifications.success.open(); + await browser.sleep(2000); + + // customFieldsHelper.create(typeIndex, 'test1-date', 'desc1', 4); + + // // debounce :( + // await utils.notifications.success.open(); + // await browser.sleep(2000); + + let countCustomFields = customFieldsHelper.getCustomFiledsByType(typeIndex).count(); + + expect(countCustomFields).to.be.eventually.equal(oldCountCustomFields + 2); + }); + + it('edit', async function() { + customFieldsHelper.edit(typeIndex, 0, 'edit', 'desc2', 2); + + expect(utils.notifications.success.open()).to.be.eventually.true; + }); + + it('drag', async function() { + let nameOld = await customFieldsHelper.getName(typeIndex, 0); + + await customFieldsHelper.drag(typeIndex, 0, 1); + + let nameNew = customFieldsHelper.getName(typeIndex, 1); + + expect(nameNew).to.be.eventually.equal(nameOld); + }); + + it('delete', async function() { + let oldCountCustomFields = await customFieldsHelper.getCustomFiledsByType(typeIndex).count(); + + customFieldsHelper.delete(typeIndex, 0); + + let countCustomFields = customFieldsHelper.getCustomFiledsByType(typeIndex).count(); + + expect(countCustomFields).to.be.eventually.equal(oldCountCustomFields - 1); + }); + }); }); }); diff --git a/e2e/full/custom-fields.e2e.js b/e2e/full/custom-fields.e2e.js deleted file mode 100644 index a00a39d2..00000000 --- a/e2e/full/custom-fields.e2e.js +++ /dev/null @@ -1,185 +0,0 @@ -var utils = require('../utils'); -var customFieldsHelper = require('../helpers/custom-fields-helper'); - -var chai = require('chai'); -var chaiAsPromised = require('chai-as-promised'); - -chai.use(chaiAsPromised); -var expect = chai.expect; - -describe('custom-fields', function() { - before(async function() { - browser.get('http://localhost:9001/project/project-3/admin/project-values/custom-fields'); - await utils.common.waitLoader(); - }); - - describe('create custom fields', function() { - describe('userstories', function() { - let typeIndex = 0; - - it('create', async function() { - let oldCountCustomFields = await customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - - customFieldsHelper.create(typeIndex, 'test1-text', 'desc1', 1); - - // debounce :( - await utils.notifications.success.open(); - await browser.sleep(2000); - - customFieldsHelper.create(typeIndex, 'test1-multi', 'desc1', 3); - - // debounce :( - await utils.notifications.success.open(); - await browser.sleep(2000); - - // customFieldsHelper.create(typeIndex, 'test1-date', 'desc1', 4); - - // // debounce :( - // await utils.notifications.success.open(); - // await browser.sleep(2000); - - let countCustomFields = customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - - expect(countCustomFields).to.be.eventually.equal(oldCountCustomFields + 2); - }); - - it('edit', async function() { - customFieldsHelper.edit(typeIndex, 0, 'edit', 'desc2', 2); - - expect(utils.notifications.success.open()).to.be.eventually.true; - }); - - it('drag', async function() { - let nameOld = await customFieldsHelper.getName(typeIndex, 0); - - await customFieldsHelper.drag(typeIndex, 0, 1); - - let nameNew = customFieldsHelper.getName(typeIndex, 1); - - expect(nameNew).to.be.eventually.equal(nameOld); - }); - - it('delete', async function() { - let oldCountCustomFields = await customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - - customFieldsHelper.delete(typeIndex, 0); - - let countCustomFields = customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - - expect(countCustomFields).to.be.eventually.equal(oldCountCustomFields - 1); - }); - }); - - describe('tasks', function() { - let typeIndex = 1; - - it('create', async function() { - let oldCountCustomFields = await customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - - customFieldsHelper.create(typeIndex, 'test1-text', 'desc1', 1); - - // debounce :( - await utils.notifications.success.open(); - await browser.sleep(2000); - - customFieldsHelper.create(typeIndex, 'test1-multi', 'desc1', 3); - - // debounce :( - await utils.notifications.success.open(); - await browser.sleep(2000); - - // customFieldsHelper.create(typeIndex, 'test1-date', 'desc1', 4); - - // // debounce :( - // await utils.notifications.success.open(); - // await browser.sleep(2000); - - let countCustomFields = customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - - expect(countCustomFields).to.be.eventually.equal(oldCountCustomFields + 2); - }); - - it('edit', async function() { - customFieldsHelper.edit(typeIndex, 0, 'edit', 'desc2', 2); - - expect(utils.notifications.success.open()).to.be.eventually.true; - }); - - it('drag', async function() { - let nameOld = await customFieldsHelper.getName(typeIndex, 0); - - await customFieldsHelper.drag(typeIndex, 0, 1); - - let nameNew = customFieldsHelper.getName(typeIndex, 1); - - expect(nameNew).to.be.eventually.equal(nameOld); - }); - - it('delete', async function() { - let oldCountCustomFields = await customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - - customFieldsHelper.delete(typeIndex, 0); - - let countCustomFields = customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - - expect(countCustomFields).to.be.eventually.equal(oldCountCustomFields - 1); - }); - }); - - describe('issues', function() { - let typeIndex = 2; - - it('create', async function() { - let oldCountCustomFields = await customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - - customFieldsHelper.create(typeIndex, 'test1-text', 'desc1', 1); - - // debounce :( - await utils.notifications.success.open(); - await browser.sleep(2000); - - customFieldsHelper.create(typeIndex, 'test1-multi', 'desc1', 3); - - // debounce :( - await utils.notifications.success.open(); - await browser.sleep(2000); - - // customFieldsHelper.create(typeIndex, 'test1-date', 'desc1', 4); - - // // debounce :( - // await utils.notifications.success.open(); - // await browser.sleep(2000); - - let countCustomFields = customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - - expect(countCustomFields).to.be.eventually.equal(oldCountCustomFields + 2); - }); - - it('edit', async function() { - customFieldsHelper.edit(typeIndex, 0, 'edit', 'desc2', 2); - - expect(utils.notifications.success.open()).to.be.eventually.true; - }); - - it('drag', async function() { - let nameOld = await customFieldsHelper.getName(typeIndex, 0); - - await customFieldsHelper.drag(typeIndex, 0, 1); - - let nameNew = customFieldsHelper.getName(typeIndex, 1); - - expect(nameNew).to.be.eventually.equal(nameOld); - }); - - it('delete', async function() { - let oldCountCustomFields = await customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - - customFieldsHelper.delete(typeIndex, 0); - - let countCustomFields = customFieldsHelper.getCustomFiledsByType(typeIndex).count(); - - expect(countCustomFields).to.be.eventually.equal(oldCountCustomFields - 1); - }); - }); - }); -}); diff --git a/e2e/full/issues/issue-detail.e2e.js b/e2e/full/issues/issue-detail.e2e.js index 018a1e7e..3d1679d4 100644 --- a/e2e/full/issues/issue-detail.e2e.js +++ b/e2e/full/issues/issue-detail.e2e.js @@ -36,6 +36,8 @@ describe('Issue detail', async function(){ it('attachments', utils.detail.attachmentTesting); + describe('custom-fields', utils.detail.customFields.bind(this, 2)); + it('screenshot', async function() { await utils.common.takeScreenshot("issues", "detail updated"); }); diff --git a/e2e/full/tasks/task-detail.e2e.js b/e2e/full/tasks/task-detail.e2e.js index c127e8f2..272223d2 100644 --- a/e2e/full/tasks/task-detail.e2e.js +++ b/e2e/full/tasks/task-detail.e2e.js @@ -51,6 +51,8 @@ describe('Task detail', function(){ it('attachments', utils.detail.attachmentTesting); + describe('custom-fields', utils.detail.customFields.bind(this, 1)); + 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 c9039d3e..d3606ab7 100644 --- a/e2e/full/user-stories/user-story-detail.e2e.js +++ b/e2e/full/user-stories/user-story-detail.e2e.js @@ -67,6 +67,8 @@ describe('User story detail', function(){ it('attachments', utils.detail.attachmentTesting); + describe('custom-fields', utils.detail.customFields.bind(this, 0)); + describe('related tasks', function() { it('create', async function() { let oldRelatedTaskCount = await usDetailHelper.relatedTasks().count(); diff --git a/e2e/helpers/admin-attributes-helper.js b/e2e/helpers/admin-attributes-helper.js index 5f4cbee8..d9d0d53a 100644 --- a/e2e/helpers/admin-attributes-helper.js +++ b/e2e/helpers/admin-attributes-helper.js @@ -100,17 +100,3 @@ helper.getGenericForm = function(form) { helper.getGenericNames = function(section) { return section.$$('.status-name span').getText(); }; - -helper.getCustomFieldsForm = function(form) { - let obj = Object.create(helper.getForm(form)); - - obj.name = function() { - return form.$('.custom-name input'); - }; - - return obj; -}; - -helper.getCustomFieldsNames = function(section) { - return section.$$('.table-body .custom-name span').getText(); -}; diff --git a/e2e/helpers/custom-fields-helper.js b/e2e/helpers/custom-fields-helper.js index f3dfef47..c5607f10 100644 --- a/e2e/helpers/custom-fields-helper.js +++ b/e2e/helpers/custom-fields-helper.js @@ -45,10 +45,6 @@ helper.drag = function(indexType, indexCustomField, indexNewPosition) { let customField = helper.getCustomFiledsByType(indexType).get(indexCustomField); let newPosition = helper.getCustomFiledsByType(indexType).get(indexNewPosition).getLocation(); - // await browser.actions().mouseMove(customField).perform(); - - // let destination = el.$$('div[tg-attachment] .attachment-settings .icon-drag-v').first(); - return utils.common.drag(customField, newPosition, {y: 30}); }; @@ -69,3 +65,7 @@ helper.delete = async function(indexType, indexCustomField) { helper.getName = function(indexType, indexCustomField) { return helper.getCustomFiledsByType(indexType).get(indexCustomField).$('.custom-name span').getText(); }; + +helper.getDetailFields = function() { + return $$('.custom-fields-body div[tg-custom-attribute-value]'); +}; diff --git a/e2e/utils/detail.js b/e2e/utils/detail.js index 6752e547..bcc5808e 100644 --- a/e2e/utils/detail.js +++ b/e2e/utils/detail.js @@ -1,6 +1,8 @@ var path = require('path'); var detailHelper = require('../helpers').detail; var commonHelper = require('../helpers').common; +var customFieldsHelper = require('../helpers/custom-fields-helper'); +var commonUtil = require('./common'); var chai = require('chai'); var chaiAsPromised = require('chai-as-promised'); @@ -208,3 +210,98 @@ helper.watchersTesting = async function() { newUserNames = await watchersHelper.getWatchersUserNames(); expect(newUserNames.join()).to.be.equal(''); } + +helper.customFields = function(typeIndex) { + before(async function() { + let url = await browser.getCurrentUrl(); + + browser.get('http://localhost:9001/project/project-3/admin/project-values/custom-fields'); + + commonUtil.waitLoader(); + + customFieldsHelper.create(typeIndex, 'detail-test-custom-fields-text', 'desc1', 1); + + // debounce :( + browser.sleep(2000); + + customFieldsHelper.create(typeIndex, 'detail-test-custom-fields-multi', 'desc1', 3); + + // debounce :( + browser.sleep(2000); + + browser.get(url); + commonUtil.waitLoader(); + }); + + it('text create', async function() { + let customFields = customFieldsHelper.getDetailFields(); + let count = await customFields.count(); + + let textField = customFields.get(count - 2); + + textField.$('input').sendKeys('test text'); + textField.$('.icon-floppy').click(); + + // debounce + await browser.sleep(2000); + + let fieldText = textField.$('.read-mode span').getText(); + + expect(fieldText).to.be.eventually.equal('test text'); + }); + + it('text edit', async function() { + let customFields = customFieldsHelper.getDetailFields(); + let count = await customFields.count(); + + let textField = customFields.get(count - 2); + + textField.$('.icon-edit').click(); + + textField.$('input').sendKeys('test text edit'); + textField.$('.icon-floppy').click(); + + // debounce + await browser.sleep(2000); + + let fieldText = textField.$('.read-mode span').getText(); + + expect(fieldText).to.be.eventually.equal('test text edit'); + }); + + it('multi', async function() { + let customFields = customFieldsHelper.getDetailFields(); + let count = await customFields.count(); + + let textField = customFields.get(count - 1); + + textField.$('textarea').sendKeys('test text2'); + textField.$('.icon-floppy').click(); + + // debounce + await browser.sleep(2000); + + let fieldText = textField.$('.read-mode span').getText(); + + expect(fieldText).to.be.eventually.equal('test text2'); + }); + + it('multi edit', async function() { + let customFields = customFieldsHelper.getDetailFields(); + let count = await customFields.count(); + + let textField = customFields.get(count - 1); + + textField.$('.icon-edit').click(); + + textField.$('textarea').sendKeys('test text2 edit'); + textField.$('.icon-floppy').click(); + + // debounce + await browser.sleep(2000); + + let fieldText = textField.$('.read-mode span').getText(); + + expect(fieldText).to.be.eventually.equal('test text2 edit'); + }); +};