Skip to content

Commit

Permalink
one failing test left
Browse files Browse the repository at this point in the history
  • Loading branch information
pvh committed Dec 31, 2024
1 parent 9fdda55 commit 72e6490
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/automerge-repo/test/remoteHeads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { DummyStorageAdapter } from "../src/helpers/DummyStorageAdapter.js"
import { collectMessages } from "./helpers/collectMessages.js"
import { TestDoc } from "./types.js"
import { pause } from "../src/helpers/pause.js"

describe("DocHandle.remoteHeads", () => {
const TEST_ID = parseAutomergeUrl(generateAutomergeUrl()).documentId
Expand Down Expand Up @@ -155,7 +156,7 @@ describe("DocHandle.remoteHeads", () => {
assert.deepStrictEqual(heads, aliceServiceWorkerDoc.heads())
})

it.only("should report remoteHeads only for documents the subscriber has open", async () => {
it("should report remoteHeads only for documents the subscriber has open", async () => {
const { alice, bob, bobServiceWorkerStorageId } = await setup()

// alice subscribes to bob's service worker
Expand All @@ -168,6 +169,8 @@ describe("DocHandle.remoteHeads", () => {
const bobDocB = bob.create<TestDoc>()
bobDocB.change(d => (d.foo = "B"))

await pause(50)

// alice opens doc A
console.log("alice.find", bobDocA.url)
const aliceDocAPromise = alice.find<TestDoc>(bobDocA.url)
Expand Down Expand Up @@ -200,6 +203,8 @@ describe("DocHandle.remoteHeads", () => {
const bobDocB = bob.create<TestDoc>()
bobDocB.change(d => (d.foo = "B"))

await pause(50)

// alice opens the docs
const _aliceDocA = await alice.find<TestDoc>(bobDocA.url)
const _aliceDocB = await alice.find<TestDoc>(bobDocB.url)
Expand Down Expand Up @@ -247,6 +252,8 @@ describe("DocHandle.remoteHeads", () => {
// alice subscribes to bob's service worker
alice.subscribeToRemotes([bobServiceWorkerStorageId])

await pause(50)

// alice opens doc A
const alice1DocAPromise = alice.find<TestDoc>(bobDocA.url)

Expand All @@ -260,7 +267,7 @@ describe("DocHandle.remoteHeads", () => {

const alice1DocA = await alice1DocAPromise

assert.strictEqual(remoteHeadsChangedMessages.length, 2)
assert.strictEqual(remoteHeadsChangedMessages.length, 1)
assert(
remoteHeadsChangedMessages.every(
d => d.documentId === alice1DocA.documentId
Expand Down

0 comments on commit 72e6490

Please sign in to comment.