This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 831
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing avatar for show current profiles (#9563)
- Loading branch information
Germain
authored
Nov 11, 2022
1 parent
1dbf9c2
commit e8d4fbb
Showing
10 changed files
with
127 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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 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 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
8 changes: 4 additions & 4 deletions
8
test/components/structures/__snapshots__/RoomView-test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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,79 @@ | ||
/* | ||
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. | ||
*/ | ||
|
||
import { getByTestId, render, waitFor } from "@testing-library/react"; | ||
import { mocked } from "jest-mock"; | ||
import { MatrixClient, PendingEventOrdering } from "matrix-js-sdk/src/client"; | ||
import { Room } from "matrix-js-sdk/src/models/room"; | ||
import { RoomMember } from "matrix-js-sdk/src/models/room-member"; | ||
import React from "react"; | ||
|
||
import MemberAvatar from "../../../../src/components/views/avatars/MemberAvatar"; | ||
import RoomContext from "../../../../src/contexts/RoomContext"; | ||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg"; | ||
import SettingsStore from "../../../../src/settings/SettingsStore"; | ||
import { getRoomContext } from "../../../test-utils/room"; | ||
import { stubClient } from "../../../test-utils/test-utils"; | ||
|
||
describe("MemberAvatar", () => { | ||
const ROOM_ID = "roomId"; | ||
|
||
let mockClient: MatrixClient; | ||
let room: Room; | ||
let member: RoomMember; | ||
|
||
function getComponent(props) { | ||
return <RoomContext.Provider value={getRoomContext(room, {})}> | ||
<MemberAvatar | ||
member={null} | ||
width={35} | ||
height={35} | ||
{...props} | ||
/> | ||
</RoomContext.Provider>; | ||
} | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
|
||
stubClient(); | ||
mockClient = mocked(MatrixClientPeg.get()); | ||
|
||
room = new Room(ROOM_ID, mockClient, mockClient.getUserId() ?? "", { | ||
pendingEventOrdering: PendingEventOrdering.Detached, | ||
}); | ||
|
||
member = new RoomMember(ROOM_ID, "@bob:example.org"); | ||
jest.spyOn(room, "getMember").mockReturnValue(member); | ||
jest.spyOn(member, "getMxcAvatarUrl").mockReturnValue("http://placekitten.com/400/400"); | ||
}); | ||
|
||
it("shows an avatar for useOnlyCurrentProfiles", async () => { | ||
jest.spyOn(SettingsStore, "getValue").mockImplementation((settingName: string) => { | ||
return settingName === "useOnlyCurrentProfiles"; | ||
}); | ||
|
||
const { container } = render(getComponent({})); | ||
|
||
let avatar: HTMLElement; | ||
await waitFor(() => { | ||
avatar = getByTestId(container, "avatar-img"); | ||
expect(avatar).toBeInTheDocument(); | ||
}); | ||
|
||
expect(avatar!.getAttribute("src")).not.toBe(""); | ||
}); | ||
}); |
This file contains 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 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 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 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 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