diff --git a/src/capabilities/tests/ui5-focus.js/index.html b/src/capabilities/tests/ui5-focus/index.html similarity index 77% rename from src/capabilities/tests/ui5-focus.js/index.html rename to src/capabilities/tests/ui5-focus/index.html index 069db72..f25e990 100644 --- a/src/capabilities/tests/ui5-focus.js/index.html +++ b/src/capabilities/tests/ui5-focus/index.html @@ -63,20 +63,27 @@ this.getView().setModel(model); // Set focus on the second row this.getView().byId("myTable").attachEventOnce("updateFinished", function() { - this.getItems()[1].focus(); - // Notify the test framework - const xhr = new XMLHttpRequest(); - xhr.open('POST', '/_/log'); - xhr.send('{}'); // TODO how do we assess focus is correctly set ? + // Need to do it asynchronously or the first item is selected instead + setTimeout(() => { + const listItem = this.getItems()[1]; + listItem.focus(); + + // Notify the test framework + const xhr = new XMLHttpRequest(); + xhr.open('POST', '/_/log'); + xhr.send(JSON.stringify({ + 'is-focus-set': document.activeElement.id === listItem.getFocusDomRef()?.id, + })); + }, 0); }); } }); XMLView.create({definition: jQuery('#myXml').html()}).then(function (oView) { - oView.placeAt("content"); + oView.placeAt(document.querySelector('body')); }); }); - + diff --git a/src/capabilities/tests/ui5-focus.js/index.js b/src/capabilities/tests/ui5-focus/index.js similarity index 57% rename from src/capabilities/tests/ui5-focus.js/index.js rename to src/capabilities/tests/ui5-focus/index.js index 489bf2c..de332b4 100644 --- a/src/capabilities/tests/ui5-focus.js/index.js +++ b/src/capabilities/tests/ui5-focus/index.js @@ -3,9 +3,9 @@ const assert = require('assert') module.exports = [{ - label: 'Loads a page which requires the focus', + label: 'UI5 focus handling', url: 'ui5-focus/index.html', endpoint: ({ body }) => { - assert.strictEqual(body['sap.m.Button'], true) + assert.strictEqual(body['is-focus-set'], true) } }]