diff --git a/test/attributes.test.ts b/test/attributes.test.ts index aeb874f1..f1a7279e 100644 --- a/test/attributes.test.ts +++ b/test/attributes.test.ts @@ -7,11 +7,13 @@ import { ValidationSchema } from "./lib/validation"; const launcher = new Launcher(); let client1: ConnectorClient; let client2: ConnectorClient; +let client1Address: string; let client2Address: string; beforeAll(async () => { [client1, client2] = await launcher.launch(2); await establishRelationship(client1, client2); + client1Address = (await client1.account.getIdentityInfo()).result.address; client2Address = (await client2.account.getIdentityInfo()).result.address; }, 30000); afterAll(() => launcher.stop()); @@ -132,36 +134,42 @@ describe("Execute AttributeQueries", () => { expect(attributes).toContainEqual(attribute); }); - // TODO: requires an active relationship and an accept from peer before relationship attribute can be queried - // test("should execute a RelationshipAttributeQuery", async () => { - // await createRelationshipAttribute(client1, { - // content: { - // value: { - // "@type": "ProprietaryString", - // title: "ATitle", - // value: "AString" - // }, - // key: "AKey", - // confidentiality: "public" - // }, - // peer: "peer" - // }); - - // const executeRelationshipAttributeQueryResult = await client1.attributes.executeRelationshipAttributeQuery({ - // query: { - // key: "AKey", - // owner: client1Address, - // attributeCreationHints: { - // valueType: "ProprietaryString", - // title: "A title", - // confidentiality: "public" - // } - // } - // }); - // expect(executeRelationshipAttributeQueryResult).toBeSuccessful(ValidationSchema.ConnectorAttribute); - - // expect(executeRelationshipAttributeQueryResult.result.content.value.value).toBe("AString"); - // }); + test("should execute a RelationshipAttributeQuery", async () => { + const createRequest = await client1.attributes.createAndShareRelationshipAttribute({ + content: { + value: { + "@type": "ProprietaryString", + title: "ATitle", + value: "AString" + }, + key: "AKey", + confidentiality: "public" + }, + peer: "peer" + }); + + await syncUntilHasMessages(client2); + + await client2.incomingRequests.accept(createRequest.result.id, { items: [{ accept: true }] }); + + await syncUntilHasMessages(client1); + + const executeRelationshipAttributeQueryResult = await client1.attributes.executeRelationshipAttributeQuery({ + query: { + key: "AKey", + owner: client1Address, + attributeCreationHints: { + valueType: "ProprietaryString", + title: "A title", + confidentiality: "public" + } + } + }); + + expect(executeRelationshipAttributeQueryResult).toBeSuccessful(ValidationSchema.ConnectorAttribute); + + expect(executeRelationshipAttributeQueryResult.result.content.value.value).toBe("AString"); + }); describe("Create Identity Attribute", () => { test("Should share an Identity Attribute", async () => { diff --git a/test/iqlquery.test.ts b/test/iqlquery.test.ts index aaac82fc..3138def1 100644 --- a/test/iqlquery.test.ts +++ b/test/iqlquery.test.ts @@ -263,7 +263,6 @@ test("Remote ProposeAttributeRequest containing IQL Query without existing attri incomingRequestItem.attribute.owner = client1Address; const requestItemAttribute = incomingRequestItem.attribute; - // TODO: also add tags in createIdentityAttribute? const attributeId = (await client1.attributes.createIdentityAttribute({ content: { value: requestItemAttribute.value } })).result.id; /* Reply to the response with the first matched attribute. Wait on C2 for