-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
135 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
"reblog", | ||
"reblogged", | ||
"reblogs", | ||
"sadams", | ||
"serializers", | ||
"shortcode", | ||
"subprotocol", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export function asyncNextTick(): Promise<void> { | ||
return new Promise<void>((resolve) => { | ||
process.nextTick(resolve); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,50 @@ | ||
import assert from "node:assert"; | ||
|
||
import waitForExpect from "@sadams/wait-for-expect"; | ||
|
||
import { type mastodon } from "../../../src"; | ||
import { waitForCondition } from "../../../test-utils/wait-for-condition"; | ||
|
||
describe("conversations", () => { | ||
it("interacts with conversations", async () => { | ||
await using alice = await sessions.acquire(); | ||
await using bob = await sessions.acquire(); | ||
const status = await bob.rest.v1.statuses.create({ | ||
status: `@${alice.acct} Hi alice`, | ||
visibility: "direct", | ||
}); | ||
|
||
let conversation: mastodon.v1.Conversation | undefined; | ||
|
||
await waitForCondition(async () => { | ||
const conversations = await alice.rest.v1.conversations.list(); | ||
conversation = conversations.find((c) => c.lastStatus?.id === status.id); | ||
return conversation != undefined; | ||
}); | ||
|
||
assert(conversation != undefined); | ||
|
||
conversation = await alice.rest.v1.conversations | ||
.$select(conversation.id) | ||
.read(); | ||
expect(conversation.unread).toBe(false); | ||
|
||
conversation = await alice.rest.v1.conversations | ||
.$select(conversation.id) | ||
.unread(); | ||
expect(conversation.unread).toBe(true); | ||
|
||
await alice.rest.v1.conversations.$select(conversation.id).remove(); | ||
try { | ||
await alice.rest.v1.accounts.$select(bob.id).follow(); | ||
await bob.rest.v1.accounts.$select(alice.id).follow(); | ||
|
||
const status = await bob.rest.v1.statuses.create({ | ||
status: `@${alice.acct} Hi alice`, | ||
visibility: "direct", | ||
}); | ||
|
||
await waitForExpect(async () => { | ||
const conversations = await alice.rest.v1.conversations.list(); | ||
conversation = conversations.find( | ||
(c) => c.lastStatus?.id === status.id, | ||
); | ||
expect(conversation?.accounts.map((a) => a.id)).toContain(bob.id); | ||
}); | ||
|
||
assert(conversation != undefined); | ||
|
||
conversation = await alice.rest.v1.conversations | ||
.$select(conversation.id) | ||
.read(); | ||
expect(conversation.unread).toBe(false); | ||
|
||
conversation = await alice.rest.v1.conversations | ||
.$select(conversation.id) | ||
.unread(); | ||
expect(conversation.unread).toBe(true); | ||
} finally { | ||
await alice.rest.v1.accounts.$select(bob.id).unfollow(); | ||
await bob.rest.v1.accounts.$select(alice.id).unfollow(); | ||
if (conversation) { | ||
await alice.rest.v1.conversations.$select(conversation.id).remove(); | ||
} | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters