mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 10:30:44 +00:00
test: require slack async callbacks
This commit is contained in:
@@ -287,10 +287,13 @@ function findFirstActionsBlock(payload: { blocks?: Array<{ type: string }> }) {
|
||||
}
|
||||
|
||||
function createDeferred<T>() {
|
||||
let resolve!: (value: T | PromiseLike<T>) => void;
|
||||
let resolve: ((value: T | PromiseLike<T>) => void) | undefined;
|
||||
const promise = new Promise<T>((res) => {
|
||||
resolve = res;
|
||||
});
|
||||
if (!resolve) {
|
||||
throw new Error("Expected Slack slash deferred resolver to be initialized");
|
||||
}
|
||||
return { promise, resolve };
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ describe("sendMessageSlack file upload with user IDs", () => {
|
||||
|
||||
it("serializes concurrent sends to the same Slack target", async () => {
|
||||
const client = createUploadTestClient();
|
||||
let resolveFirst!: () => void;
|
||||
let resolveFirst: (() => void) | undefined;
|
||||
client.chat.postMessage.mockImplementation(async (payload: { text?: string }) => {
|
||||
if (payload.text === "first") {
|
||||
await new Promise<void>((resolve) => {
|
||||
@@ -204,6 +204,9 @@ describe("sendMessageSlack file upload with user IDs", () => {
|
||||
await Promise.resolve();
|
||||
|
||||
expect(client.chat.postMessage).toHaveBeenCalledTimes(1);
|
||||
if (!resolveFirst) {
|
||||
throw new Error("Expected first Slack send release callback to be initialized");
|
||||
}
|
||||
resolveFirst();
|
||||
|
||||
await expect(first).resolves.toMatchObject({
|
||||
|
||||
Reference in New Issue
Block a user