Skip to content

Commit 6eeb520

Browse files
committed
feat: adjust hulylake client for storage adapter
Signed-off-by: Alexander Onnikov <[email protected]>
1 parent 4cc3dde commit 6eeb520

File tree

7 files changed

+233
-111
lines changed

7 files changed

+233
-111
lines changed

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v22

packages/client-resources/src/__tests__/connection.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ describe('MockWebSocket', () => {
261261

262262
ws.send(pingConst)
263263

264-
await new Promise(resolve => setTimeout(resolve, 50))
264+
await new Promise((resolve) => setTimeout(resolve, 50))
265265

266266
expect(receivedMessage).toBe(pongConst)
267267

@@ -290,7 +290,7 @@ describe('connect function', () => {
290290
mockWebSockets = []
291291

292292
// Give time for all timers to clear
293-
await new Promise(resolve => setTimeout(resolve, 100))
293+
await new Promise((resolve) => setTimeout(resolve, 100))
294294
})
295295

296296
it('should establish connection', async () => {
@@ -311,13 +311,13 @@ describe('connect function', () => {
311311
expect(client).toBeDefined()
312312

313313
// Wait for connection to establish
314-
await new Promise(resolve => setTimeout(resolve, 100))
314+
await new Promise((resolve) => setTimeout(resolve, 100))
315315

316316
// Close connection immediately to prevent timers from continuing
317317
await client.close()
318318

319319
// Wait for close to complete
320-
await new Promise(resolve => setTimeout(resolve, 50))
320+
await new Promise((resolve) => setTimeout(resolve, 50))
321321
})
322322

323323
it('should handle transactions', async () => {
@@ -339,7 +339,7 @@ describe('connect function', () => {
339339
connections.push(client)
340340

341341
// Wait for connection to establish
342-
await new Promise(resolve => setTimeout(resolve, 150))
342+
await new Promise((resolve) => setTimeout(resolve, 150))
343343

344344
// Simulate a transaction from server
345345
const testTx: TxCreateDoc<Doc> = {
@@ -363,12 +363,12 @@ describe('connect function', () => {
363363

364364
mockWs.simulateTransaction(testTx)
365365

366-
await new Promise(resolve => setTimeout(resolve, 100))
366+
await new Promise((resolve) => setTimeout(resolve, 100))
367367

368368
expect(txReceived).toBeDefined()
369369

370370
// Close immediately after test
371371
await client.close()
372-
await new Promise(resolve => setTimeout(resolve, 50))
372+
await new Promise((resolve) => setTimeout(resolve, 50))
373373
})
374374
})

packages/client-resources/src/__tests__/integration.test.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export class MockClientConnection implements ClientConnection {
186186
}
187187
await this.transactions.tx(tx)
188188

189-
this.handlers.forEach(h => {
189+
this.handlers.forEach((h) => {
190190
h(tx)
191191
})
192192

@@ -246,7 +246,7 @@ export class MockClientConnection implements ClientConnection {
246246
}
247247

248248
simulateTransaction (tx: Tx): void {
249-
this.handlers.forEach(h => {
249+
this.handlers.forEach((h) => {
250250
h(tx)
251251
})
252252
}
@@ -285,10 +285,7 @@ export async function createTestClient (initialTxes: Tx[] = []): Promise<{
285285
/**
286286
* Helper to create a test transaction
287287
*/
288-
export function createTestTx (
289-
objectClass: Ref<Class<Doc>> = core.class.Space,
290-
attributes: any = {}
291-
): TxCreateDoc<Doc> {
288+
export function createTestTx (objectClass: Ref<Class<Doc>> = core.class.Space, attributes: any = {}): TxCreateDoc<Doc> {
292289
return {
293290
_id: generateId(),
294291
_class: core.class.TxCreateDoc,
@@ -339,7 +336,7 @@ describe('Client-Resources Integration Tests', () => {
339336

340337
// The mock connection immediately notifies handlers when we call tx
341338
// So notifySpy should have been called
342-
await new Promise(resolve => setTimeout(resolve, 100))
339+
await new Promise((resolve) => setTimeout(resolve, 100))
343340

344341
expect(notifySpy).toHaveBeenCalled()
345342

@@ -525,17 +522,13 @@ describe('Client-Resources Integration Tests', () => {
525522
const tx2 = createTestTx(core.class.Space, { name: 'Space2' })
526523
const tx3 = createTestTx(core.class.Space, { name: 'Space3' })
527524

528-
await Promise.all([
529-
client.tx(tx1),
530-
client.tx(tx2),
531-
client.tx(tx3)
532-
])
525+
await Promise.all([client.tx(tx1), client.tx(tx2), client.tx(tx3)])
533526

534527
connection.simulateTransaction(tx1)
535528
connection.simulateTransaction(tx2)
536529
connection.simulateTransaction(tx3)
537530

538-
await new Promise(resolve => setTimeout(resolve, 100))
531+
await new Promise((resolve) => setTimeout(resolve, 100))
539532

540533
expect(notifySpy.mock.calls.length).toBeGreaterThanOrEqual(3)
541534

packages/client/src/__tests__/client.test.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class TestConnection implements ClientConnection {
185185
await this.transactions.tx(tx)
186186

187187
// Notify handlers
188-
this.handlers.forEach(h => {
188+
this.handlers.forEach((h) => {
189189
h(tx)
190190
})
191191

@@ -247,7 +247,7 @@ class TestConnection implements ClientConnection {
247247

248248
// Simulate receiving transactions from server
249249
simulateTransaction (tx: Tx): void {
250-
this.handlers.forEach(h => {
250+
this.handlers.forEach((h) => {
251251
h(tx)
252252
})
253253
}
@@ -336,7 +336,7 @@ describe('Client Core Implementation', () => {
336336
testConnection.simulateTransaction(tx)
337337

338338
// Wait for async operations
339-
await new Promise(resolve => setTimeout(resolve, 100))
339+
await new Promise((resolve) => setTimeout(resolve, 100))
340340

341341
expect(notifySpy).toHaveBeenCalled()
342342
})
@@ -387,7 +387,11 @@ describe('Client Core Implementation', () => {
387387
it('should handle reconnection events', async () => {
388388
let eventReceived: ClientConnectEvent | undefined
389389

390-
const onConnectHandler = async (event: ClientConnectEvent, lastTx: string | undefined, data: any): Promise<void> => {
390+
const onConnectHandler = async (
391+
event: ClientConnectEvent,
392+
lastTx: string | undefined,
393+
data: any
394+
): Promise<void> => {
391395
eventReceived = event
392396
}
393397

@@ -418,7 +422,7 @@ describe('Client Core Implementation', () => {
418422

419423
testConnection.simulateTransaction(workspaceTx)
420424

421-
await new Promise(resolve => setTimeout(resolve, 100))
425+
await new Promise((resolve) => setTimeout(resolve, 100))
422426

423427
expect(notifySpy).toHaveBeenCalled()
424428
})
@@ -466,7 +470,7 @@ describe('Client Core Implementation', () => {
466470
// Simulate receiving the same transaction from remote
467471
testConnection.simulateTransaction(tx)
468472

469-
await new Promise(resolve => setTimeout(resolve, 100))
473+
await new Promise((resolve) => setTimeout(resolve, 100))
470474

471475
// Should still notify but skip model update
472476
expect(notifySpy).toHaveBeenCalled()

0 commit comments

Comments
 (0)