Reset user input when cancel button is used in edit mode

pull/3646/head
Alex Dik 9 years ago
parent 92009a1dd7
commit 9ec5cd8ea6
  1. 2
      frontend/app/work_packages/directives/inplace_editor/inplace-editor-edit-pane-directive.js
  2. 1
      frontend/tests/integration/pages/work-package-show-page.js
  3. 19
      frontend/tests/integration/specs/work-packages/work-package-edit-spec.js

@ -182,6 +182,8 @@ module.exports = function(
$scope.$watch('editableFieldsState.editAll.state', function(state) {
$scope.fieldController.isEditing = state;
$scope.fieldController.lockFocus = true;
!state && $scope.fieldController.updateWriteValue();
});
},
link: function(scope, element, attrs, fieldController) {

@ -33,6 +33,7 @@ WorkPackageShowPage.prototype = {
wpId: 819,
editButton: $('.button[title="Edit"]'),
focusElement: $('#work-package-subject .focus-input'),
focusElementValue: $('#work-package-subject span.inplace-edit--read-value > span:first-child'),
overviewButton: $('#work-packages-details-view-button'),
editableFields: $$('.focus-input'),

@ -34,13 +34,16 @@ describe('Work package edit', function() {
expectFocusEquals = function (id) {
var activeId = browser.driver.switchTo().activeElement().getId();
expect(activeId).to.eventually.deep.equal(id);
};
}, val;
describe('when clicking edit button on show page', function () {
beforeEach(function () {
val = 'my_value';
page.get();
page.editButton.isPresent().then(function () {
page.editButton.click();
page.focusElement.sendKeys(val);
})
});
@ -57,9 +60,6 @@ describe('Work package edit', function() {
});
it('should keep the user input when switching to overview mode', function () {
var val = 'my_value';
page.focusElement.sendKeys(val);
page.overviewButton.click().then(function () {
page.focusElement.isPresent().then(function () {
expect(page.focusElement.getAttribute('value')).to.eventually.equal(val);
@ -67,11 +67,18 @@ describe('Work package edit', function() {
});
});
describe('when triggering the edit actions', function () {
it('should cancel editing when the cancel button is clicked', function () {
describe('when triggering the cancel action', function () {
beforeEach(function () {
page.editActions.cancel.click();
});
it('should cancel editing', function () {
expect(page.editableFields.count()).to.eventually.equal(0);
});
it('should reset user input', function () {
expect(page.focusElementValue.getText()).to.eventually.not.equal(val);
});
});
});
});

Loading…
Cancel
Save