From c59f65e43b03894782a79d3513fb82bb61dc8bb7 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 29 Jun 2022 12:56:20 +0200 Subject: [PATCH] Add a couple consistent selectors to reference in tests Using `data-testid` because it seems generic out of the list from: - https://docs.cypress.io/guides/core-concepts/cypress-app#Uniqueness - https://docs.cypress.io/guides/references/best-practices#How-It-Works --- src/platform/web/ui/avatar.js | 2 +- src/platform/web/ui/session/room/timeline/BaseMediaView.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/web/ui/avatar.js b/src/platform/web/ui/avatar.js index 5bc019cb..547d4b51 100644 --- a/src/platform/web/ui/avatar.js +++ b/src/platform/web/ui/avatar.js @@ -31,7 +31,7 @@ export function renderStaticAvatar(vm, size, extraClasses = undefined) { avatarClasses += ` ${extraClasses}`; } const avatarContent = hasAvatar ? renderImg(vm, size) : text(vm.avatarLetter); - const avatar = tag.div({className: avatarClasses}, [avatarContent]); + const avatar = tag.div({className: avatarClasses, "data-testid": "avatar"}, [avatarContent]); if (hasAvatar) { setAttribute(avatar, "data-avatar-letter", vm.avatarLetter); setAttribute(avatar, "data-avatar-color", vm.avatarColorNumber); diff --git a/src/platform/web/ui/session/room/timeline/BaseMediaView.js b/src/platform/web/ui/session/room/timeline/BaseMediaView.js index 16b5de14..9d534fd1 100644 --- a/src/platform/web/ui/session/room/timeline/BaseMediaView.js +++ b/src/platform/web/ui/session/room/timeline/BaseMediaView.js @@ -53,7 +53,7 @@ export class BaseMediaView extends BaseMessageView { children.push(progress); } return t.div({className: "Timeline_messageBody"}, [ - t.div({className: "media", style: `max-width: ${vm.width}px`}, children), + t.div({className: "media", style: `max-width: ${vm.width}px`, "data-testid": "media"}, children), t.if(vm => vm.error, t => t.p({className: "error"}, vm.error)) ]); }