diff --git a/e2e/full/custom-fields.e2e.js b/e2e/full/custom-fields.e2e.js new file mode 100644 index 00000000..a00a39d2 --- /dev/null +++ b/e2e/full/custom-fields.e2e.js @@ -0,0 +1,185 @@ +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/helpers/custom-fields-helper.js b/e2e/helpers/custom-fields-helper.js new file mode 100644 index 00000000..f3dfef47 --- /dev/null +++ b/e2e/helpers/custom-fields-helper.js @@ -0,0 +1,71 @@ +var utils = require('../utils'); + +var helper = module.exports; + +helper.create = function(indexType, name, desc, option) { + let type = $$('div[tg-project-custom-attributes]').get(indexType); + + type.$('.js-add-custom-field-button').click(); + + let form = type.$$('form').last(); + + form.$('input[name="name"]').sendKeys(name); + form.$('input[name="description"]').sendKeys(desc); + form.$(`select option:nth-child(${option})`).click(); + + let saveButton = form.$('.js-create-custom-field-button'); + + browser.actions() + .mouseMove(saveButton) + .click() + .perform(); +}; + +helper.edit = function(indexType, indexCustomField, name, desc, option) { + let form = helper.getCustomFiledsByType(indexType).get(indexCustomField); + + browser.actions() + .mouseMove(form.$('.js-edit-custom-field-button')) + .click() + .perform(); + + form.$('input[name="name"]').sendKeys(name); + form.$('input[name="description"]').sendKeys(desc); + form.$(`select option:nth-child(${option})`).click(); + + let saveButton = form.$('.js-update-custom-field-button'); + + browser.actions() + .mouseMove(saveButton) + .click() + .perform(); +}; + +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}); +}; + +helper.getCustomFiledsByType = function(indexType) { + return $$('div[tg-project-custom-attributes]').get(indexType).$$('.js-sortable > div'); +}; + +helper.delete = async function(indexType, indexCustomField) { + let customField = helper.getCustomFiledsByType(indexType).get(indexCustomField); + + let count = await helper.getCustomFiledsByType(indexType).count(); + + customField.$('.js-delete-custom-field-button').click(); + + utils.lightbox.confirm.ok(); +}; + +helper.getName = function(indexType, indexCustomField) { + return helper.getCustomFiledsByType(indexType).get(indexCustomField).$('.custom-name span').getText(); +}; diff --git a/e2e/utils/common.js b/e2e/utils/common.js index 03f3f111..8c98ae3c 100644 --- a/e2e/utils/common.js +++ b/e2e/utils/common.js @@ -118,7 +118,7 @@ common.dragEnd = function(elm) { }, 1000); }; -common.drag = async function(elm, elm2) { +common.drag = async function(elm, elm2, offset) { // this code doesn't have sense (jquery ui + scroll drag + selenium = :( ) await browser.actions() .mouseMove(elm) @@ -126,7 +126,7 @@ common.drag = async function(elm, elm2) { .perform(); await browser.actions() - .mouseMove(elm2) + .mouseMove(elm2, offset) .perform(); await browser.sleep(60);