This repository was archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 819
Delabs Show current avatar and name for users in message history
#8764
Merged
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
de201f5
Delabs `Show current avatar and name for users in message history`
SimonBrandner 0c083dc
Improve cypress support
SimonBrandner efdecf8
Add `timeline.spec.ts`
SimonBrandner f4704f1
"Fix" type issues
SimonBrandner 0855629
Try to fix tests failing
SimonBrandner cd8c254
Add display name consts
SimonBrandner e8f015c
Test avatars too
SimonBrandner e9ef0d7
A bit of cleanup
SimonBrandner d946a04
Merge remote-tracking branch 'upstream/develop' into SimonBrandner/fe…
SimonBrandner 3f8b56b
Update dir name
SimonBrandner 4b68c7e
Add comment about waiting
SimonBrandner 224f850
Add `SettingsStore` type
SimonBrandner 2cd8149
Merge remote-tracking branch 'upstream/develop' into SimonBrandner/fe…
SimonBrandner fbe8c52
Use `LEVELS_ACCOUNT_SETTINGS`
SimonBrandner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
/// <reference types="cypress" /> | ||
|
||
import { MessageEvent } from "matrix-events-sdk"; | ||
|
||
import type { ISendEventResponse } from "matrix-js-sdk/src/@types/requests"; | ||
import type { EventType } from "matrix-js-sdk/src/@types/event"; | ||
import type { MatrixClient } from "matrix-js-sdk/src/client"; | ||
import { SynapseInstance } from "../../plugins/synapsedocker"; | ||
import { SettingLevel } from "../../../src/settings/SettingLevel"; | ||
import Chainable = Cypress.Chainable; | ||
|
||
// The avatar size used in the timeline | ||
const AVATAR_SIZE = 30; | ||
// The resize method used in the timeline | ||
const AVATAR_RESIZE_METHOD = "crop"; | ||
|
||
const ROOM_NAME = "Test room"; | ||
const OLD_AVATAR = "avatar_image1"; | ||
const NEW_AVATAR = "avatar_image2"; | ||
const OLD_NAME = "Alan"; | ||
const NEW_NAME = "Alan (away)"; | ||
|
||
const getEventTilesWithBodies = (): Chainable<JQuery> => { | ||
return cy.get(".mx_EventTile").filter((_i, e) => e.getElementsByClassName("mx_EventTile_body").length > 0); | ||
}; | ||
|
||
const expectDisplayName = (e: JQuery<HTMLElement>, displayName: string): void => { | ||
expect(e.find(".mx_DisambiguatedProfile_displayName").text()).to.equal(displayName); | ||
}; | ||
|
||
const expectAvatar = (e: JQuery<HTMLElement>, avatarUrl: string): void => { | ||
cy.getClient().then((cli: MatrixClient) => { | ||
expect(e.find(".mx_BaseAvatar_image").attr("src")).to.equal( | ||
// eslint-disable-next-line no-restricted-properties | ||
cli.mxcUrlToHttp(avatarUrl, AVATAR_SIZE, AVATAR_SIZE, AVATAR_RESIZE_METHOD), | ||
); | ||
}); | ||
}; | ||
|
||
const sendEvent = (roomId: string): Chainable<ISendEventResponse> => { | ||
return cy.sendEvent( | ||
roomId, | ||
null, | ||
"m.room.message" as EventType, | ||
MessageEvent.from("Message").serialize().content, | ||
); | ||
}; | ||
|
||
describe("Timeline", () => { | ||
let synapse: SynapseInstance; | ||
|
||
let roomId: string; | ||
|
||
let oldAvatarUrl: string; | ||
let newAvatarUrl: string; | ||
|
||
describe("useOnlyCurrentProfiles", () => { | ||
beforeEach(() => { | ||
cy.startSynapse("default").then(data => { | ||
synapse = data; | ||
cy.initTestUser(synapse, OLD_NAME).then(() => | ||
cy.window({ log: false }).then(() => { | ||
cy.createRoom({ name: ROOM_NAME }).then(_room1Id => { | ||
roomId = _room1Id; | ||
}); | ||
}), | ||
).then(() => { | ||
cy.uploadContent(OLD_AVATAR).then((url) => { | ||
oldAvatarUrl = url; | ||
cy.setAvatarUrl(url); | ||
}); | ||
}).then(() => { | ||
cy.uploadContent(NEW_AVATAR).then((url) => { | ||
newAvatarUrl = url; | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
cy.stopSynapse(synapse); | ||
}); | ||
|
||
it("should show historical profiles if disabled", () => { | ||
cy.setSettingValue("useOnlyCurrentProfiles", null, SettingLevel.ACCOUNT, false); | ||
sendEvent(roomId); | ||
cy.setDisplayName("Alan (away)"); | ||
cy.setAvatarUrl(newAvatarUrl); | ||
cy.wait(500); | ||
SimonBrandner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sendEvent(roomId); | ||
cy.viewRoomByName(ROOM_NAME); | ||
|
||
const events = getEventTilesWithBodies(); | ||
|
||
events.should("have.length", 2); | ||
events.each((e, i) => { | ||
if (i === 0) { | ||
expectDisplayName(e, OLD_NAME); | ||
expectAvatar(e, oldAvatarUrl); | ||
} else if (i === 1) { | ||
expectDisplayName(e, NEW_NAME); | ||
expectAvatar(e, newAvatarUrl); | ||
} | ||
}); | ||
}); | ||
|
||
it("should not show historical profiles if enabled", () => { | ||
cy.setSettingValue("useOnlyCurrentProfiles", null, SettingLevel.ACCOUNT, true); | ||
sendEvent(roomId); | ||
cy.setDisplayName(NEW_NAME); | ||
cy.setAvatarUrl(newAvatarUrl); | ||
cy.wait(500); | ||
sendEvent(roomId); | ||
cy.viewRoomByName(ROOM_NAME); | ||
|
||
const events = getEventTilesWithBodies(); | ||
|
||
events.should("have.length", 2); | ||
events.each((e) => { | ||
expectDisplayName(e, NEW_NAME); | ||
expectAvatar(e, newAvatarUrl); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.