Use stable test selectors from Hydrogen (`data-testid`)

Follow-up to https://github.com/matrix-org/matrix-public-archive/pull/29#discussion_r909492946

---

Updated Hydrogen to add the consistent `data-testid` attribute selectors,
https://github.com/vector-im/hydrogen-web/pull/773

```
npm install hydrogen-view-sdk@npm:@mlm/hydrogen-view-sdk@0.0.13-scratch
```
This commit is contained in:
Eric Eastwood 2022-07-05 06:23:47 -05:00 committed by GitHub
parent cfbd6182a9
commit d508521171
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 21 deletions

28
package-lock.json generated
View File

@ -9,7 +9,7 @@
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"express": "^4.17.2", "express": "^4.17.2",
"hydrogen-view-sdk": "npm:@mlm/hydrogen-view-sdk@^0.0.12", "hydrogen-view-sdk": "npm:@mlm/hydrogen-view-sdk@^0.0.13-scratch",
"linkedom": "^0.14.1", "linkedom": "^0.14.1",
"matrix-public-archive-shared": "file:./shared/", "matrix-public-archive-shared": "file:./shared/",
"nconf": "^0.11.3", "nconf": "^0.11.3",
@ -128,9 +128,9 @@
"dev": true "dev": true
}, },
"node_modules/@matrix-org/olm": { "node_modules/@matrix-org/olm": {
"version": "3.2.3", "version": "3.2.8",
"resolved": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.3.tgz", "resolved": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz",
"integrity": "sha512-OhC9wwZ/ox9vputA1MR2A7QlYlvfXCV+tdbADOR7Jn7o9qoXh3HWf+AbSpXTK3daF0GIHA69Ws8XOnWqu5n53A==", "integrity": "sha512-yCJzEYY2aG1z+7nxKYZC4DFYwQO/5iG019qgotJhauYJRhEG9gLrKTvXO6lRHS8TjnZzsZFZyO/hQUlI4Dryig==",
"license": "Apache-2.0" "license": "Apache-2.0"
}, },
"node_modules/@sindresorhus/is": { "node_modules/@sindresorhus/is": {
@ -1990,11 +1990,11 @@
}, },
"node_modules/hydrogen-view-sdk": { "node_modules/hydrogen-view-sdk": {
"name": "@mlm/hydrogen-view-sdk", "name": "@mlm/hydrogen-view-sdk",
"version": "0.0.12", "version": "0.0.13-scratch",
"resolved": "https://registry.npmjs.org/@mlm/hydrogen-view-sdk/-/hydrogen-view-sdk-0.0.12.tgz", "resolved": "https://registry.npmjs.org/@mlm/hydrogen-view-sdk/-/hydrogen-view-sdk-0.0.13-scratch.tgz",
"integrity": "sha512-zPmJJVUKQCIxw9vAwcTzwU9OT/U/9Gvspafx10l8a2flguj8BLBOorYw0EghBK/MdSsc//b+GRwpYqrvz8VAfQ==", "integrity": "sha512-LAytm2lqVCvpFriizKQXjSJgOomx29ReD6w2sQhbHIfeP5DZ6wNxRybCBeBFrU1+2BiT7BTNmZp5Cwe8PGt14Q==",
"dependencies": { "dependencies": {
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.3.tgz", "@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz",
"another-json": "^0.2.0", "another-json": "^0.2.0",
"base64-arraybuffer": "^0.2.0", "base64-arraybuffer": "^0.2.0",
"dompurify": "^2.3.0", "dompurify": "^2.3.0",
@ -3979,8 +3979,8 @@
"dev": true "dev": true
}, },
"@matrix-org/olm": { "@matrix-org/olm": {
"version": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.3.tgz", "version": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz",
"integrity": "sha512-OhC9wwZ/ox9vputA1MR2A7QlYlvfXCV+tdbADOR7Jn7o9qoXh3HWf+AbSpXTK3daF0GIHA69Ws8XOnWqu5n53A==" "integrity": "sha512-yCJzEYY2aG1z+7nxKYZC4DFYwQO/5iG019qgotJhauYJRhEG9gLrKTvXO6lRHS8TjnZzsZFZyO/hQUlI4Dryig=="
}, },
"@sindresorhus/is": { "@sindresorhus/is": {
"version": "0.14.0", "version": "0.14.0",
@ -5265,11 +5265,11 @@
} }
}, },
"hydrogen-view-sdk": { "hydrogen-view-sdk": {
"version": "npm:@mlm/hydrogen-view-sdk@0.0.12", "version": "npm:@mlm/hydrogen-view-sdk@0.0.13-scratch",
"resolved": "https://registry.npmjs.org/@mlm/hydrogen-view-sdk/-/hydrogen-view-sdk-0.0.12.tgz", "resolved": "https://registry.npmjs.org/@mlm/hydrogen-view-sdk/-/hydrogen-view-sdk-0.0.13-scratch.tgz",
"integrity": "sha512-zPmJJVUKQCIxw9vAwcTzwU9OT/U/9Gvspafx10l8a2flguj8BLBOorYw0EghBK/MdSsc//b+GRwpYqrvz8VAfQ==", "integrity": "sha512-LAytm2lqVCvpFriizKQXjSJgOomx29ReD6w2sQhbHIfeP5DZ6wNxRybCBeBFrU1+2BiT7BTNmZp5Cwe8PGt14Q==",
"requires": { "requires": {
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.3.tgz", "@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz",
"another-json": "^0.2.0", "another-json": "^0.2.0",
"base64-arraybuffer": "^0.2.0", "base64-arraybuffer": "^0.2.0",
"dompurify": "^2.3.0", "dompurify": "^2.3.0",

View File

@ -31,7 +31,7 @@
}, },
"dependencies": { "dependencies": {
"express": "^4.17.2", "express": "^4.17.2",
"hydrogen-view-sdk": "npm:@mlm/hydrogen-view-sdk@^0.0.12", "hydrogen-view-sdk": "npm:@mlm/hydrogen-view-sdk@^0.0.13-scratch",
"linkedom": "^0.14.1", "linkedom": "^0.14.1",
"matrix-public-archive-shared": "file:./shared/", "matrix-public-archive-shared": "file:./shared/",
"nconf": "^0.11.3", "nconf": "^0.11.3",

View File

@ -330,18 +330,14 @@ describe('matrix-public-archive', () => {
// Make sure the user avatar is visible on the message // Make sure the user avatar is visible on the message
const avatarImageElement = dom.document.querySelector( const avatarImageElement = dom.document.querySelector(
// FIXME: Use more stable select here instead of `.avatar`, `[data-event-id="${imageEventId}"] [data-testid="avatar"] img`
// see https://github.com/vector-im/hydrogen-web/pull/773
`[data-event-id="${imageEventId}"] .avatar img`
); );
assert(avatarImageElement); assert(avatarImageElement);
assert.match(avatarImageElement.getAttribute('src'), new RegExp(`^http://.*`)); assert.match(avatarImageElement.getAttribute('src'), new RegExp(`^http://.*`));
// Make sure the image message is visible // Make sure the image message is visible
const imageElement = dom.document.querySelector( const imageElement = dom.document.querySelector(
// FIXME: Use more stable select here instead of `.media`, `[data-event-id="${imageEventId}"] [data-testid="media"] img`
// see https://github.com/vector-im/hydrogen-web/pull/773
`[data-event-id="${imageEventId}"] .media img`
); );
assert(imageElement); assert(imageElement);
assert.match(imageElement.getAttribute('src'), new RegExp(`^http://.*`)); assert.match(imageElement.getAttribute('src'), new RegExp(`^http://.*`));