v4: a user from another instance can't be renamed from their profile's manage tab — it offered the name field to every user, and the API refuses a remote one's rename with a 400, since their home names them. The tab now only shows their name, as the settings do for one's own.
The profile's and the settings' tests of a remote account's links to its home still expected the home's host itself, which 8bcc005 replaced with GET /api/users/:key/home; they now expect that.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { API_URL } from "../../config/api.ts";
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import { act, screen, waitFor, within } from "@testing-library/react";
|
||||
import { userEvent } from "@testing-library/user-event";
|
||||
@@ -65,9 +66,10 @@ describe("UserPublicProfile", () => {
|
||||
});
|
||||
expect(await screen.findByRole("heading", { name: "alice@home.example" }))
|
||||
.toBeInTheDocument();
|
||||
// Through the API, which redirects to the home's pages.
|
||||
expect(screen.getByRole("link", { name: "home.example" })).toHaveAttribute(
|
||||
"href",
|
||||
`${location.protocol}//home.example/@alice`,
|
||||
`${API_URL}/api/users/@alice%40home.example/home`,
|
||||
);
|
||||
expect(screen.queryByTitle("Change avatar")).not.toBeInTheDocument();
|
||||
expect(screen.queryByTitle("Edit email")).not.toBeInTheDocument();
|
||||
@@ -617,6 +619,20 @@ describe("UserPublicProfile", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("a user from another instance is named there, not here", async () => {
|
||||
open({
|
||||
session: makeSession({ id: "admin", role: "admin" }),
|
||||
user: { ...ann, username: "ann@home.example" },
|
||||
url: "/@ann@home.example/manage",
|
||||
});
|
||||
expect(
|
||||
await screen.findByText("ann@home.example", {
|
||||
selector: ".profile-appearance-value",
|
||||
}),
|
||||
).toBeInTheDocument();
|
||||
expect(screen.queryByRole("textbox", { name: "Username" })).toBeNull();
|
||||
});
|
||||
|
||||
test("non-admins get no manage tab, nor its page", async () => {
|
||||
open({
|
||||
session: makeSession({ id: "mod", role: "moderator" }),
|
||||
|
||||
Reference in New Issue
Block a user