Skip to content

Commit 3fafcc3

Browse files
committed
contacts: add contact to group failing e2e test and module interface
1 parent 92fde3e commit 3fafcc3

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

contacts/src/e2e-tests/contacts.e2e.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,29 @@ describe("contacts module", () => {
150150
});
151151
}
152152
});
153+
154+
it("can add an existing contact to an existing group", async () => {
155+
const contacts = setupModule();
156+
157+
const groupUri =
158+
"http://localhost:3456/4243dbb6-3126-4bf9-9ea7-45e35c3c8d9d/Group/88f4eb67-f510-49c8-8d52-9080cd3e489f/index.ttl#this";
159+
160+
const contactUri =
161+
"http://localhost:3456/4243dbb6-3126-4bf9-9ea7-45e35c3c8d9d/Person/1973dcec-e71c-476c-87db-0d3332291214/index.ttl#this";
162+
163+
const groupBefore = await contacts.readGroup(groupUri);
164+
expect(
165+
groupBefore.members.some((contact) => contact.uri == contactUri),
166+
).toBe(false);
167+
168+
await contacts.addContactToGroup({ contactUri, groupUri });
169+
170+
const groupAfter = await contacts.readGroup(groupUri);
171+
expect(groupAfter.members).toContainEqual({
172+
uri: "http://localhost:3456/4243dbb6-3126-4bf9-9ea7-45e35c3c8d9d/Person/1973dcec-e71c-476c-87db-0d3332291214/index.ttl#this",
173+
name: "Molly Braaten",
174+
});
175+
});
153176
});
154177

155178
function setupModule() {

contacts/src/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ export interface ContactsModule {
5151
* @return FullGroup name and list of group members
5252
*/
5353
readGroup(uri: string): Promise<FullGroup>;
54+
55+
/**
56+
* Adds an existing contact to an existing group
57+
* @param command
58+
*/
59+
addContactToGroup(command: AddContactToGroupCommand): Promise<void>;
5460
}
5561

5662
/**
@@ -185,3 +191,17 @@ export interface CreateNewGroupCommand {
185191
*/
186192
groupName: string;
187193
}
194+
195+
/**
196+
* Data needed to add an existing contact to an existing group
197+
*/
198+
export interface AddContactToGroupCommand {
199+
/**
200+
* The URI of an existing group, to that the contact should be added
201+
*/
202+
contactUri: string;
203+
/**
204+
* The URI of an existing contact, that should be added to the group
205+
*/
206+
groupUri: string;
207+
}

contacts/src/rdflib/ContactsModuleRdfLib.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Fetcher, IndexedFormula, Node, sym, UpdateManager } from "rdflib";
22
import {
3+
AddContactToGroupCommand,
34
AddressBook,
45
ContactsModule,
56
CreateAddressBookCommand,
@@ -114,4 +115,6 @@ export class ContactsModuleRdfLib implements ContactsModule {
114115
members,
115116
};
116117
}
118+
119+
async addContactToGroup({ contactUri, groupUri }: AddContactToGroupCommand) {}
117120
}

0 commit comments

Comments
 (0)