Skip to content

Commit

Permalink
test: check UI5 focus use case
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBuchholz committed Nov 29, 2024
1 parent 610b46c commit 84ef209
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});
});
</script>
</head>
<body id='content' class='sapUiBody'></body>
<body class='sapUiBody'></body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}]

0 comments on commit 84ef209

Please sign in to comment.