Files
blap/apps/web/test/slash-commands/status-test.ts
T
David Baker 3ab233940c User status in user menu (#33797)
* Add user status on user profile icon

Currently unstyled & no tests

* Style the user status icon

* Update snapshot

for avatar wrapper

* More snapshot updates

* add if braces

* Split out user status functions

to avoid circular dep which has the weird effect of just breaking
jest's mocking.

* type imports

* Update imports

* Update snapshot

* Tests

* baseline image

* Just snapshot the component itself

* User status in user menu

first pass, unstyled

* fix export

* superstylin'

* snapshots

* Add story & test

* Snapshots

and re-use the repeated rules

* Tests

* Fix jest lcov projectRoot config

* Change tooltip text to just 'clear'

* Add comment & fix console warn

* Remove all options screenshot

as it's not really particularly useful as a preset story

* remove stale screenshot

* fix imports

---------

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2026-06-16 09:01:34 +00:00

62 lines
2.3 KiB
TypeScript

/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import { stubClient } from "../test-utils";
import { statusCommand } from "../../src/slash-commands/status";
import { UserFriendlyError } from "../../src/languageHandler";
describe("/status", () => {
const roomId = "!room:example.com";
let client: ReturnType<typeof stubClient>;
beforeEach(() => {
client = stubClient();
});
function run(args?: string) {
return statusCommand.run(client, roomId, null, args);
}
it("should reject if no args provided", () => {
const result = run(undefined);
expect(result.error).toBeInstanceOf(UserFriendlyError);
expect((result.error as UserFriendlyError).message).toBe(
"No arguments provided. You should supply an emoij and an optional text component.",
);
});
it("should reject if no text is provided after the emoji", () => {
const result = run("🎉");
expect(result.error).toBeInstanceOf(UserFriendlyError);
expect((result.error as UserFriendlyError).message).toBe("You did not provide any status text");
});
it("should reject if the emoji field has more than one grapheme segment", () => {
const result = run("ab hello");
expect(result.error).toBeInstanceOf(UserFriendlyError);
expect((result.error as UserFriendlyError).message).toBe("The first argument must be an emoji");
});
it("should reject if the status text exceeds the maximum byte length", () => {
const longText = "a".repeat(257);
const result = run(`🎉 ${longText}`);
expect(result.error).toBeInstanceOf(UserFriendlyError);
expect((result.error as UserFriendlyError).message).toBe("The text you provided was too long.");
});
it("should set the extended profile property on success", async () => {
const result = run("🎉 Having a great day");
expect(result.error).toBeUndefined();
await result.promise;
expect(client.setExtendedProfileProperty).toHaveBeenCalledWith("org.matrix.msc4426.status", {
emoji: "🎉",
text: "Having a great day",
});
});
});