Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Don't show 'saved' on display name save error #12600

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/views/settings/UserProfileSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const UserProfileSettings: React.FC = () => {
setInitialDisplayName(displayName);
} catch (e) {
setDisplayNameError(true);
throw e;
}
}, [displayName, client]);

Expand Down
19 changes: 19 additions & 0 deletions test/components/views/settings/UserProfileSettings-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,25 @@ describe("ProfileSettings", () => {
expect(client.setDisplayName).toHaveBeenCalledWith("The Value");
});

it("displays error if changing display name fails", async () => {
jest.spyOn(OwnProfileStore.instance, "displayName", "get").mockReturnValue("Alice");
mocked(client).setDisplayName.mockRejectedValue(new Error("Failed to set display name"));

renderProfileSettings(toastRack, client);

expect(editInPlaceOnSave).toBeDefined();

act(() => {
editInPlaceOnChange({
target: { value: "Not Alice any more" } as HTMLInputElement,
} as ChangeEvent<HTMLInputElement>);
});

await act(async () => {
await expect(editInPlaceOnSave()).rejects.toEqual(expect.any(Error));
});
});

it("resets on cancel", async () => {
jest.spyOn(OwnProfileStore.instance, "displayName", "get").mockReturnValue("Alice");

Expand Down
Loading