Commit a0f59a93 authored by Colin Eberhardt's avatar Colin Eberhardt

Adds test for focus when app is initially loaded

This adds an additional test case that ensures the todo input field is focussed when the app initially loads.

Thia relates to the test failures in issue #1034
parent 8e7d2985
...@@ -27,7 +27,7 @@ module.exports = function Page(browser) { ...@@ -27,7 +27,7 @@ module.exports = function Page(browser) {
this.back = function() { this.back = function() {
return browser.navigate().back(); return browser.navigate().back();
} };
// ----------------- try / get methods // ----------------- try / get methods
...@@ -59,6 +59,12 @@ module.exports = function Page(browser) { ...@@ -59,6 +59,12 @@ module.exports = function Page(browser) {
// ----------------- DOM element access methods // ----------------- DOM element access methods
this.getFocussedElementId = function () {
return browser.switchTo().activeElement().getAttribute('id').then(function(id) {
return id;
});
};
this.getEditInputForItemAtIndex = function (index) { this.getEditInputForItemAtIndex = function (index) {
var xpath = this.xPathForItemAtIndex(index) + '//input[contains(@class,"edit")]'; var xpath = this.xPathForItemAtIndex(index) + '//input[contains(@class,"edit")]';
return this.findByXpath(xpath); return this.findByXpath(xpath);
......
...@@ -68,6 +68,12 @@ module.exports.todoMVCTest = function (frameworkName, baseUrl, speedMode, laxMod ...@@ -68,6 +68,12 @@ module.exports.todoMVCTest = function (frameworkName, baseUrl, speedMode, laxMod
}); });
} }
test.describe('When page is initially opened', function () {
test.it('should focus on the todo input field', function () {
testOps.assertFocussedElementId("new-todo");
});
});
test.describe('No Todos', function () { test.describe('No Todos', function () {
test.it('should hide #main and #footer', function () { test.it('should hide #main and #footer', function () {
testOps.assertItemCount(0); testOps.assertItemCount(0);
......
...@@ -22,6 +22,12 @@ function TestOperations(page) { ...@@ -22,6 +22,12 @@ function TestOperations(page) {
}); });
} }
this.assertFocussedElementId = function(expectedId) {
page.getFocussedElementId().then(function(id) {
assert.equal(id, expectedId, 'The focused element did not have the expected id ' + expectedId);
});
};
this.assertClearCompleteButtonIsHidden = function () { this.assertClearCompleteButtonIsHidden = function () {
page.tryGetClearCompleteButton().then(function (element) { page.tryGetClearCompleteButton().then(function (element) {
testIsHidden(element, 'clear completed items button'); testIsHidden(element, 'clear completed items button');
...@@ -141,7 +147,7 @@ function TestOperations(page) { ...@@ -141,7 +147,7 @@ function TestOperations(page) {
// execute all the tests // execute all the tests
return Q.all(tests); return Q.all(tests);
}) });
}); });
}; };
......
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