aboutsummaryrefslogtreecommitdiffstats
path: root/ui-client/src/test/java/market/guess/ui/client
diff options
context:
space:
mode:
authorKostya <mail@sartin.in>2026-10-15 15:18:30 +0300
committerKostya <mail@sartin.in>2026-10-15 15:18:55 +0300
commitc67d5ff663b876a15a3831f5a2b564c4002e99b6 (patch)
tree98dcbbd1b8b21c5e88865ae0ebd8b270ff80d9a9 /ui-client/src/test/java/market/guess/ui/client
parent4563c9d6d6c1576b6fb45899c2b6d6073966d8b8 (diff)
downloadguess-market-c67d5ff663b876a15a3831f5a2b564c4002e99b6.tar.gz
guess-market-c67d5ff663b876a15a3831f5a2b564c4002e99b6.tar.xz
guess-market-c67d5ff663b876a15a3831f5a2b564c4002e99b6.zip
ui: add chat drawer to the desktop client 3.0
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.
Diffstat (limited to 'ui-client/src/test/java/market/guess/ui/client')
-rw-r--r--ui-client/src/test/java/market/guess/ui/client/RemoteContextsTest.java24
1 files changed, 23 insertions, 1 deletions
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 {
72 72
73 maya.pull(); 73 maya.pull();
74 var heard = new CountDownLatch(1); 74 var heard = new CountDownLatch(1);
75 maya.startPolling(heard::countDown); 75 maya.startPolling(heard::countDown, said -> {});
76 var bought = 76 var bought =
77 tomMarket.placeOrder("Tom", event.key(), event.key() + ":0", "BUY", BigDecimal.ONE, 10); 77 tomMarket.placeOrder("Tom", event.key(), event.key() + ":0", "BUY", BigDecimal.ONE, 10);
78 assertTrue(bought.isSuccess(), bought.getMessage()); 78 assertTrue(bought.isSuccess(), bought.getMessage());
@@ -150,6 +150,28 @@ class RemoteContextsTest {
150 } 150 }
151 151
152 @Test 152 @Test
153 void chatReachesEveryoneOnceAndLeavesTheMarketAlone() {
154 try (var yael = new ServerClient(server.api);
155 var zohar = new ServerClient(server.api)) {
156 yael.login("Yael");
157 zohar.login("Zohar");
158 zohar.pullChat(); // whatever other tests said
159 zohar.pull();
160
161 var hello = "שלום, anyone trading?";
162 assertTrue(yael.say(hello).isSuccess());
163 assertFalse(yael.say(" ").isSuccess());
164
165 var heard = zohar.pullChat();
166 assertEquals(1, heard.size());
167 assertEquals("Yael", heard.get(0).sender());
168 assertEquals(hello, heard.get(0).text());
169 assertTrue(zohar.pullChat().isEmpty(), "a message is delivered once");
170 assertFalse(zohar.pull(), "chat must not look like a market change");
171 }
172 }
173
174 @Test
153 void anUnreachableServerIsAFailedResultNotAnException() { 175 void anUnreachableServerIsAFailedResultNotAnException() {
154 try (var nobody = new ServerClient("http://localhost:1/api")) { 176 try (var nobody = new ServerClient("http://localhost:1/api")) {
155 assertFalse(nobody.login("Zed").isSuccess()); 177 assertFalse(nobody.login("Zed").isSuccess());