Compare commits

...
This repository has been archived on 2022-08-19. You can view files and clone it, but cannot push or open issues or pull requests.

3 Commits

Author SHA1 Message Date
Eric Eastwood 19bb69c495 Move eventId getter to SimpleTile which is inherited by a few other tiles
See https://github.com/vector-im/hydrogen-web/pull/690#discussion_r817007275
2022-03-01 17:27:48 -06:00
Eric Eastwood 4bd169fd89 Add eventId getter 2022-02-25 02:07:42 -06:00
Eric Eastwood a6e3e3a7b4 Add data-event-id="$xxx" attributes to timeline items for easy selecting in tests
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.*`)
);
```
2022-02-25 01:50:42 -06:00
2 changed files with 15 additions and 8 deletions

View File

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

View File

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