Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@hcengineering/client-resources",
"comment": "fix formatting",
"type": "patch"
}
],
"packageName": "@hcengineering/client-resources"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@hcengineering/client",
"comment": "fix formatting",
"type": "patch"
}
],
"packageName": "@hcengineering/client"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@hcengineering/hulylake-client",
"comment": "refactoring hulylake client to extract multi-workspace client",
"type": "patch"
}
],
"packageName": "@hcengineering/hulylake-client"
}
14 changes: 7 additions & 7 deletions packages/client-resources/src/__tests__/connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ describe('MockWebSocket', () => {

ws.send(pingConst)

await new Promise(resolve => setTimeout(resolve, 50))
await new Promise((resolve) => setTimeout(resolve, 50))

expect(receivedMessage).toBe(pongConst)

Expand Down Expand Up @@ -290,7 +290,7 @@ describe('connect function', () => {
mockWebSockets = []

// Give time for all timers to clear
await new Promise(resolve => setTimeout(resolve, 100))
await new Promise((resolve) => setTimeout(resolve, 100))
})

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

// Wait for connection to establish
await new Promise(resolve => setTimeout(resolve, 100))
await new Promise((resolve) => setTimeout(resolve, 100))

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

// Wait for close to complete
await new Promise(resolve => setTimeout(resolve, 50))
await new Promise((resolve) => setTimeout(resolve, 50))
})

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

// Wait for connection to establish
await new Promise(resolve => setTimeout(resolve, 150))
await new Promise((resolve) => setTimeout(resolve, 150))

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

mockWs.simulateTransaction(testTx)

await new Promise(resolve => setTimeout(resolve, 100))
await new Promise((resolve) => setTimeout(resolve, 100))

expect(txReceived).toBeDefined()

// Close immediately after test
await client.close()
await new Promise(resolve => setTimeout(resolve, 50))
await new Promise((resolve) => setTimeout(resolve, 50))
})
})
19 changes: 6 additions & 13 deletions packages/client-resources/src/__tests__/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class MockClientConnection implements ClientConnection {
}
await this.transactions.tx(tx)

this.handlers.forEach(h => {
this.handlers.forEach((h) => {
h(tx)
})

Expand Down Expand Up @@ -246,7 +246,7 @@ export class MockClientConnection implements ClientConnection {
}

simulateTransaction (tx: Tx): void {
this.handlers.forEach(h => {
this.handlers.forEach((h) => {
h(tx)
})
}
Expand Down Expand Up @@ -285,10 +285,7 @@ export async function createTestClient (initialTxes: Tx[] = []): Promise<{
/**
* Helper to create a test transaction
*/
export function createTestTx (
objectClass: Ref<Class<Doc>> = core.class.Space,
attributes: any = {}
): TxCreateDoc<Doc> {
export function createTestTx (objectClass: Ref<Class<Doc>> = core.class.Space, attributes: any = {}): TxCreateDoc<Doc> {
return {
_id: generateId(),
_class: core.class.TxCreateDoc,
Expand Down Expand Up @@ -339,7 +336,7 @@ describe('Client-Resources Integration Tests', () => {

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

expect(notifySpy).toHaveBeenCalled()

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

await Promise.all([
client.tx(tx1),
client.tx(tx2),
client.tx(tx3)
])
await Promise.all([client.tx(tx1), client.tx(tx2), client.tx(tx3)])

connection.simulateTransaction(tx1)
connection.simulateTransaction(tx2)
connection.simulateTransaction(tx3)

await new Promise(resolve => setTimeout(resolve, 100))
await new Promise((resolve) => setTimeout(resolve, 100))

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

Expand Down
16 changes: 10 additions & 6 deletions packages/client/src/__tests__/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class TestConnection implements ClientConnection {
await this.transactions.tx(tx)

// Notify handlers
this.handlers.forEach(h => {
this.handlers.forEach((h) => {
h(tx)
})

Expand Down Expand Up @@ -247,7 +247,7 @@ class TestConnection implements ClientConnection {

// Simulate receiving transactions from server
simulateTransaction (tx: Tx): void {
this.handlers.forEach(h => {
this.handlers.forEach((h) => {
h(tx)
})
}
Expand Down Expand Up @@ -336,7 +336,7 @@ describe('Client Core Implementation', () => {
testConnection.simulateTransaction(tx)

// Wait for async operations
await new Promise(resolve => setTimeout(resolve, 100))
await new Promise((resolve) => setTimeout(resolve, 100))

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

const onConnectHandler = async (event: ClientConnectEvent, lastTx: string | undefined, data: any): Promise<void> => {
const onConnectHandler = async (
event: ClientConnectEvent,
lastTx: string | undefined,
data: any
): Promise<void> => {
eventReceived = event
}

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

testConnection.simulateTransaction(workspaceTx)

await new Promise(resolve => setTimeout(resolve, 100))
await new Promise((resolve) => setTimeout(resolve, 100))

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

await new Promise(resolve => setTimeout(resolve, 100))
await new Promise((resolve) => setTimeout(resolve, 100))

// Should still notify but skip model update
expect(notifySpy).toHaveBeenCalled()
Expand Down
Loading