From c67d5ff663b876a15a3831f5a2b564c4002e99b6 Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 15 Oct 2026 15:18:30 +0300 Subject: ui: add chat drawer to the desktop client ServerClient fetches new chat lines on the same one-second poll as the market and hands them over separately from market changes. The shared UI gets a chat icon in the status bar, beside the eject button, shown only against a server. It opens a drawer above the status bar with everyone's lines and a field to send one, laid over the content so the window keeps its size. While the drawer is closed the icon counts unread lines. A line the server refuses is reported in the drawer itself. --- .../market/guess/ui/client/RemoteContextsTest.java | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'ui-client/src/test/java/market') diff --git a/ui-client/src/test/java/market/guess/ui/client/RemoteContextsTest.java b/ui-client/src/test/java/market/guess/ui/client/RemoteContextsTest.java index e3b11f0..ea9d5ea 100644 --- a/ui-client/src/test/java/market/guess/ui/client/RemoteContextsTest.java +++ b/ui-client/src/test/java/market/guess/ui/client/RemoteContextsTest.java @@ -72,7 +72,7 @@ class RemoteContextsTest { maya.pull(); var heard = new CountDownLatch(1); - maya.startPolling(heard::countDown); + maya.startPolling(heard::countDown, said -> {}); var bought = tomMarket.placeOrder("Tom", event.key(), event.key() + ":0", "BUY", BigDecimal.ONE, 10); assertTrue(bought.isSuccess(), bought.getMessage()); @@ -149,6 +149,28 @@ class RemoteContextsTest { return new BigDecimal(new RemoteAccountContext(client).getAccount(name).getData().balance()); } + @Test + void chatReachesEveryoneOnceAndLeavesTheMarketAlone() { + try (var yael = new ServerClient(server.api); + var zohar = new ServerClient(server.api)) { + yael.login("Yael"); + zohar.login("Zohar"); + zohar.pullChat(); // whatever other tests said + zohar.pull(); + + var hello = "שלום, anyone trading?"; + assertTrue(yael.say(hello).isSuccess()); + assertFalse(yael.say(" ").isSuccess()); + + var heard = zohar.pullChat(); + assertEquals(1, heard.size()); + assertEquals("Yael", heard.get(0).sender()); + assertEquals(hello, heard.get(0).text()); + assertTrue(zohar.pullChat().isEmpty(), "a message is delivered once"); + assertFalse(zohar.pull(), "chat must not look like a market change"); + } + } + @Test void anUnreachableServerIsAFailedResultNotAnException() { try (var nobody = new ServerClient("http://localhost:1/api")) { -- cgit v1.2.3