about summary refs log tree commit diff
path: root/jest
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-04-05 18:56:02 -0500
committerGitHub <noreply@github.com>2023-04-05 18:56:02 -0500
commitea04c2bd330dc5b46d6f9df0d7d4619bbd8f56d0 (patch)
tree870c7d3dbffe1f382cba30b858eaa2b76b31af36 /jest
parent8e28d3c6be8e063b6d563b0068cb4fc907ff5df0 (diff)
downloadvoidsky-ea04c2bd330dc5b46d6f9df0d7d4619bbd8f56d0.tar.zst
Add user invite codes (#393)
* Add mobile UIs for invite codes

* Update invite code UIs for web

* Finish implementing invite code behaviors (including notifications of invited users)

* Bump deps

* Update web right nav to use real data; also fix lint
Diffstat (limited to 'jest')
-rw-r--r--jest/test-pds.ts17
1 files changed, 15 insertions, 2 deletions
diff --git a/jest/test-pds.ts b/jest/test-pds.ts
index 1e87df811..851775580 100644
--- a/jest/test-pds.ts
+++ b/jest/test-pds.ts
@@ -27,7 +27,9 @@ export interface TestPDS {
   close: () => Promise<void>
 }
 
-export async function createServer(): Promise<TestPDS> {
+export async function createServer(
+  {inviteRequired}: {inviteRequired: boolean} = {inviteRequired: false},
+): Promise<TestPDS> {
   const repoSigningKey = await crypto.Secp256k1Keypair.create()
   const plcRotationKey = await crypto.Secp256k1Keypair.create()
   const port = await getPort()
@@ -61,7 +63,7 @@ export async function createServer(): Promise<TestPDS> {
     serverDid,
     recoveryKey,
     adminPassword: ADMIN_PASSWORD,
-    inviteRequired: false,
+    inviteRequired,
     didPlcUrl: plcUrl,
     jwtSecret: 'jwt-secret',
     availableUserDomains: ['.test'],
@@ -76,6 +78,7 @@ export async function createServer(): Promise<TestPDS> {
     blobstoreTmp: `${blobstoreLoc}/tmp`,
     maxSubscriptionBuffer: 200,
     repoBackfillLimitMs: HOUR,
+    userInviteInterval: 1,
   })
 
   const db =
@@ -131,8 +134,18 @@ class Mocker {
 
   async createUser(name: string) {
     const agent = new BskyAgent({service: this.agent.service})
+
+    const inviteRes = await agent.api.com.atproto.server.createInviteCode(
+      {useCount: 1},
+      {
+        headers: {authorization: `Basic ${btoa(`admin:${ADMIN_PASSWORD}`)}`},
+        encoding: 'application/json',
+      },
+    )
+
     const email = `fake${Object.keys(this.users).length + 1}@fake.com`
     const res = await agent.createAccount({
+      inviteCode: inviteRes.data.code,
       email,
       handle: name + '.test',
       password: 'hunter2',