-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2629 from robintown/test-call-vm
Test CallViewModel
- Loading branch information
Showing
20 changed files
with
706 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
Copyright 2024 New Vector Ltd. | ||
SPDX-License-Identifier: AGPL-3.0-only | ||
Please see LICENSE in the repository root for full details. | ||
*/ | ||
|
||
import { expect, test } from "vitest"; | ||
import { render, screen } from "@testing-library/react"; | ||
import { axe } from "vitest-axe"; | ||
import { TooltipProvider } from "@vector-im/compound-web"; | ||
|
||
import { RoomHeaderInfo } from "./Header"; | ||
|
||
test("RoomHeaderInfo is accessible", async () => { | ||
const { container } = render( | ||
<TooltipProvider> | ||
<RoomHeaderInfo | ||
id="!a:example.org" | ||
name="Mission Control" | ||
avatarUrl="" | ||
encrypted | ||
participantCount={11} | ||
/> | ||
</TooltipProvider>, | ||
); | ||
expect(await axe(container)).toHaveNoViolations(); | ||
// Check that the room name acts as a heading | ||
screen.getByRole("heading", { name: "Mission Control" }); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
Copyright 2024 New Vector Ltd. | ||
SPDX-License-Identifier: AGPL-3.0-only | ||
Please see LICENSE in the repository root for full details. | ||
*/ | ||
|
||
import { test, expect, vi } from "vitest"; | ||
import { render, screen } from "@testing-library/react"; | ||
import { axe } from "vitest-axe"; | ||
import userEvent from "@testing-library/user-event"; | ||
|
||
import { StarRatingInput } from "./StarRatingInput"; | ||
|
||
test("StarRatingInput is accessible", async () => { | ||
const user = userEvent.setup(); | ||
const onChange = vi.fn(); | ||
const { container } = render( | ||
<StarRatingInput starCount={5} onChange={onChange} />, | ||
); | ||
expect(await axe(container)).toHaveNoViolations(); | ||
// Change the rating to 4 stars | ||
await user.click( | ||
( | ||
await screen.findAllByRole("radio", { name: "star_rating_input_label" }) | ||
)[3], | ||
); | ||
expect(onChange).toBeCalledWith(4); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
Copyright 2024 New Vector Ltd. | ||
SPDX-License-Identifier: AGPL-3.0-only | ||
Please see LICENSE in the repository root for full details. | ||
*/ | ||
|
||
import { render, screen } from "@testing-library/react"; | ||
import { expect, test, vi } from "vitest"; | ||
import { Room } from "matrix-js-sdk/src/matrix"; | ||
import { axe } from "vitest-axe"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
import userEvent from "@testing-library/user-event"; | ||
|
||
import { InviteModal } from "./InviteModal"; | ||
|
||
// Used by copy-to-clipboard | ||
window.prompt = (): null => null; | ||
|
||
test("InviteModal is accessible", async () => { | ||
const user = userEvent.setup(); | ||
const room = { | ||
roomId: "!a:example.org", | ||
name: "Mission Control", | ||
} as unknown as Room; | ||
const onDismiss = vi.fn(); | ||
const { container } = render( | ||
<InviteModal room={room} open={true} onDismiss={onDismiss} />, | ||
{ wrapper: BrowserRouter }, | ||
); | ||
|
||
expect(await axe(container)).toHaveNoViolations(); | ||
await user.click(screen.getByRole("button", { name: "action.copy_link" })); | ||
expect(onDismiss).toBeCalled(); | ||
}); |
Oops, something went wrong.