Commit 765e6234 authored by Sam Saccone's avatar Sam Saccone

tests: Add editing focus test

Fixes #1560
parent aa89c299
......@@ -107,9 +107,17 @@ module.exports = function Page(browser) {
};
// ----------------- DOM element access methods
this.getActiveElement = function () {
return browser.switchTo().activeElement();
};
this.getFocussedTagName = function () {
return this.getActiveElement().getTagName();
};
this.getFocussedElementId = function () {
return browser.switchTo().activeElement().getAttribute(!idSelectors ? 'id' : 'class');
return this.getActiveElement()
.getAttribute(!idSelectors ? 'id' : 'class');
};
this.getEditInputForItemAtIndex = function (index) {
......
......@@ -216,6 +216,11 @@ module.exports.todoMVCTest = function (frameworkName, baseUrl, speedMode, laxMod
page.doubleClickItemAtIndex(1);
});
test.it('should focus the input', function () {
testOps.assertInputFocused();
testOps.assertNewInputNotFocused();
});
test.it('should hide other controls when editing', function () {
testOps.assertItemToggleIsHidden(1);
testOps.assertItemLabelIsHidden(1);
......
......@@ -21,8 +21,22 @@ function TestOperations(page) {
});
}
this.assertNewInputNotFocused = function () {
return page.getFocussedElementId()
.then(function(name) {
assert.notEqual(name, 'new-todo');
});
};
this.assertInputFocused = function () {
return page.getFocussedTagName()
.then(function (name) {
assert.equal(name, 'input', 'input does not have focus');
});
};
this.assertFocussedElementId = function (expectedId) {
page.getFocussedElementId().then(function (id) {
page.getFocussedTagName().then(function (id) {
assert.notEqual(id.indexOf(expectedId), -1, 'The focused element did not have the expected id ' + expectedId);
});
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment