mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 14:15:24 +00:00
fix(session-sharing): show participant presence in member terminals (#1504)
This commit is contained in:
1 parent
0f6e48a95c
commit
4ed9b69aab
6 files changed
+114
-5
No files matched your search
@@ -75,6 +75,52 @@ describe("session-sharing activate", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("shows terminal participants and clears them after the last guest leaves or the socket closes", async () => {
|
||||
rendered = await renderWithApp(plugin, {
|
||||
manifest,
|
||||
locales,
|
||||
api: stubApi(),
|
||||
});
|
||||
expect(rendered.registered.slot("terminal.overlay")).toEqual([
|
||||
"session-sharing.participants",
|
||||
]);
|
||||
let receive: (message: {
|
||||
type: string;
|
||||
[key: string]: unknown;
|
||||
}) => void = () => {};
|
||||
const unsubscribe = vi.fn();
|
||||
rendered.renderSlot("terminal.overlay", {
|
||||
subscribe: (listener: typeof receive) => {
|
||||
receive = listener;
|
||||
return unsubscribe;
|
||||
},
|
||||
});
|
||||
const owner = { isOwner: true, permissionLevel: "read-write", label: null };
|
||||
const guest = {
|
||||
isOwner: false,
|
||||
permissionLevel: "read-only",
|
||||
label: "Guest 1",
|
||||
};
|
||||
await act(() =>
|
||||
receive({ type: "participants", participants: [owner, guest] }),
|
||||
);
|
||||
expect(
|
||||
screen.getByTitle(
|
||||
`${locales.sessionSharing.guestView.ownerLabel}, Guest 1`,
|
||||
).textContent,
|
||||
).toBe("2");
|
||||
await act(() => receive({ type: "participants", participants: [owner] }));
|
||||
expect(screen.queryByText("2")).toBeNull();
|
||||
await act(() =>
|
||||
receive({ type: "participants", participants: [owner, guest] }),
|
||||
);
|
||||
await act(() => receive({ type: "session_closed" }));
|
||||
expect(screen.queryByText("2")).toBeNull();
|
||||
await rendered.deactivate();
|
||||
expect(unsubscribe).toHaveBeenCalled();
|
||||
rendered = null;
|
||||
});
|
||||
|
||||
it("registers only the guest views on a guest page", async () => {
|
||||
rendered = await renderWithApp(plugin, {
|
||||
manifest,
|
||||
|
||||
Reference in new issue
Block a user