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 828
Use Compound tooltips instead of homegrown in TextWithTooltip & InfoTooltip #12052
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7a35a22
Migrate InfoTooltip to use Compound Tooltip
t3chguy 4bb8b39
Migrate DecoratedRoomAvatar.tsx to Compound tooltips
t3chguy 77a65b5
Small type tweaks
t3chguy 3b73d37
Remove unused props
t3chguy cd1b04e
Migrate TextWithTooltip.tsx to Compound tooltips
t3chguy 9d65854
Update snapshots
t3chguy 240da56
Add comment
t3chguy 22771d8
Update snapshot
t3chguy 7a5959f
Revert accidental layout change to TextWithTooltip from inline to block
t3chguy 11af350
Improve test coverage and simplify
t3chguy 0431ff4
Update snapshots
t3chguy 1278ecb
Ditch the sleep call
t3chguy 760fb2f
Improve coverage
t3chguy 22cd32e
Merge branch 'develop' into t3chguy/cr/157
t3chguy 5e3d4b9
Merge branch 'develop' into t3chguy/cr/157
t3chguy 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 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
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
66 changes: 66 additions & 0 deletions
66
test/components/views/avatars/DecoratedRoomAvatar-test.tsx
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,66 @@ | ||
/* | ||
Copyright 2023 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 { render, waitFor } from "@testing-library/react"; | ||
import { mocked } from "jest-mock"; | ||
import { JoinRule, MatrixClient, PendingEventOrdering, Room } from "matrix-js-sdk/src/matrix"; | ||
import React from "react"; | ||
import userEvent from "@testing-library/user-event"; | ||
|
||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg"; | ||
import { stubClient } from "../../../test-utils"; | ||
import DecoratedRoomAvatar from "../../../../src/components/views/avatars/DecoratedRoomAvatar"; | ||
import DMRoomMap from "../../../../src/utils/DMRoomMap"; | ||
|
||
describe("DecoratedRoomAvatar", () => { | ||
const ROOM_ID = "roomId"; | ||
|
||
let mockClient: MatrixClient; | ||
let room: Room; | ||
|
||
beforeEach(() => { | ||
stubClient(); | ||
mockClient = mocked(MatrixClientPeg.safeGet()); | ||
|
||
room = new Room(ROOM_ID, mockClient, mockClient.getUserId() ?? "", { | ||
pendingEventOrdering: PendingEventOrdering.Detached, | ||
}); | ||
|
||
const dmRoomMap = { | ||
getUserIdForRoomId: jest.fn(), | ||
} as unknown as DMRoomMap; | ||
jest.spyOn(DMRoomMap, "shared").mockReturnValue(dmRoomMap); | ||
}); | ||
|
||
it("shows an avatar with globe icon and tooltip for public room", async () => { | ||
room.getJoinRule = jest.fn().mockReturnValue(JoinRule.Public); | ||
const { container, asFragment } = render(<DecoratedRoomAvatar room={room} size="32px" />); | ||
|
||
const globe = container.querySelector(".mx_DecoratedRoomAvatar_icon_globe")!; | ||
expect(globe).toBeVisible(); | ||
await userEvent.hover(globe!); | ||
|
||
// wait for the tooltip to open | ||
const tooltip = await waitFor(() => { | ||
const tooltip = document.getElementById(globe.getAttribute("aria-describedby")!); | ||
expect(tooltip).toBeVisible(); | ||
return tooltip; | ||
}); | ||
expect(tooltip).toHaveTextContent("This room is public"); | ||
|
||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This uses a ReactNode and not a pair of strings so will need Compound/Design work to be supported