Skip to content

Commit 32b1d51

Browse files
committed
test: ffi: ts: fix test
We return a different error structure now, so we have to adjust the test. I adjusted the way we test the to match the errors tests. We check conditions in the browser context and then assert the results outside the browser context.
1 parent b25942f commit 32b1d51

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

crypto-ffi/bindings/js/test/wdio/transactionContext.test.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
CoreCryptoError,
66
CoreCryptoContext,
77
ErrorType,
8+
isMlsOtherError,
89
} from "../../src/CoreCrypto";
910

1011
beforeEach(async () => {
@@ -43,7 +44,9 @@ describe("transaction context", () => {
4344
const alice = crypto.randomUUID();
4445
await ccInit(alice);
4546

46-
const error = await browser.execute(async (clientName) => {
47+
const result = await browser.execute(async (clientName) => {
48+
49+
const isMlsOtherError = window.ccModule.isMlsOtherError;
4750
const cc = window.ensureCcDefined(clientName);
4851

4952
let context: CoreCryptoContext | null = null;
@@ -58,16 +61,18 @@ describe("transaction context", () => {
5861
1
5962
);
6063
} catch (err) {
61-
const error = err as CoreCryptoError<ErrorType>;
62-
return { name: error.name, message: error.message };
64+
console.log(JSON.stringify(err))
65+
return {
66+
errorWasThrown: true,
67+
isCorrectInstance: isMlsOtherError(err),
68+
contextMatches: err.context.context.msg === "This transaction context has already been finished and can no longer be used."
69+
};
6370
}
6471
return null;
6572
}, alice);
66-
expect(error).not.toBeNull();
67-
expect(error?.name).toEqual("MlsErrorOther");
68-
expect(error?.message).toEqual(
69-
"This transaction context has already been finished and can no longer be used."
70-
);
73+
expect(result.errorWasThrown).toBe(true);
74+
expect(result.isCorrectInstance).toBe(true);
75+
expect(result.contextMatches).toBe(true);
7176
});
7277

7378
it("should roll back transaction after error", async () => {
@@ -78,7 +83,7 @@ describe("transaction context", () => {
7883
const cc = window.ensureCcDefined(clientName);
7984
const basicCredentialType = window.ccModule.CredentialType.Basic;
8085
const conversationId = new window.ccModule.ConversationId(
81-
new TextEncoder().encode("testConversation")
86+
new TextEncoder().encode("testConversation").buffer
8287
);
8388

8489
const expectedError = new Error("Message of expected error", {

0 commit comments

Comments
 (0)