Add data-event-id="$xxx" attributes to timeline items for easy selecting in end-to-end tests (#690)

Split out from https://github.com/vector-im/hydrogen-web/pull/653

Example test assertions: db6d3797d7/test/e2e-tests.js (L248-L252)

```js
// Make sure the $abc event on the page has "foobarbaz" text in it
assert.match(
  dom.document.querySelector(`[data-event-id="$abc"]`).outerHTML,
  new RegExp(`.*foobarbaz.*`)
);
```
This commit is contained in:
Eric Eastwood 2022-03-01 18:36:14 -06:00 committed by GitHub
parent 2e1283d199
commit c09964dc30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 8 deletions

View file

@ -44,6 +44,10 @@ export class SimpleTile extends ViewModel {
return this._entry.asEventKey(); return this._entry.asEventKey();
} }
get eventId() {
return this._entry.id;
}
get isPending() { get isPending() {
return this._entry.isPending; return this._entry.isPending;
} }

View file

@ -40,14 +40,17 @@ export class BaseMessageView extends TemplateView {
if (this._interactive) { if (this._interactive) {
children.push(t.button({className: "Timeline_messageOptions"}, "⋯")); children.push(t.button({className: "Timeline_messageOptions"}, "⋯"));
} }
const li = t.el(this._tagName, {className: { const li = t.el(this._tagName, {
className: {
"Timeline_message": true, "Timeline_message": true,
own: vm.isOwn, own: vm.isOwn,
unsent: vm.isUnsent, unsent: vm.isUnsent,
unverified: vm.isUnverified, unverified: vm.isUnverified,
disabled: !this._interactive, disabled: !this._interactive,
continuation: vm => vm.isContinuation, continuation: vm => vm.isContinuation,
}}, children); },
'data-event-id': vm.eventId
}, children);
// given that there can be many tiles, we don't add // given that there can be many tiles, we don't add
// unneeded DOM nodes in case of a continuation, and we add it // unneeded DOM nodes in case of a continuation, and we add it
// with a side-effect binding to not have to create sub views, // with a side-effect binding to not have to create sub views,