Skip to content

The open-source AI receptionist for businesses. Answers every call, books the appointment and hands over to a person when needed. You own the code and the data.

Trunk tests: admin action list names workspace.setOutboundCalls; test workspaces draw a free number (PR 1990)

Tim Gutberlet870c85fa388a
diff --git a/apps/api/test/admin.test.ts b/apps/api/test/admin.test.ts
index f20ba39a..92563817 100644
--- a/apps/api/test/admin.test.ts
+++ b/apps/api/test/admin.test.ts
@@ -280,6 +280,7 @@ describe('access', () => {
'workspace.delete',
'workspace.disable',
'workspace.enable',
+ 'workspace.setOutboundCalls',
'workspace.setSpendingCap',
'zapierApp.get',
'zapierApp.set',
diff --git a/apps/api/test/helpers.ts b/apps/api/test/helpers.ts
index 2331a470..cf4b5a3c 100644
--- a/apps/api/test/helpers.ts
+++ b/apps/api/test/helpers.ts
@@ -146,11 +146,19 @@ export async function createWorkspace(name: string, emailVerified = true) {
if (status !== 200) throw new Error(`workspace not created: ${status} ${JSON.stringify(body)}`)
const id: string = body.workspace.id
const [assistant] = await db.select().from(assistants).where(eq(assistants.workspace_id, id))
- const number = randomNumber()
// Set up as phoneNumber.setup does: created_at on the API's clock, the one calls.started_at uses.
- await db
- .insert(phone_numbers)
- .values({ id: uid('pn'), workspace_id: id, e164: number, provider: 'dev', created_at: new Date().toISOString() })
+ // A number is unique in the install, and a test file makes thousands of workspaces from 8 million random numbers:
+ // one already taken (by this file or another one in the same database) is drawn again, not an error.
+ let number = randomNumber()
+ for (;;) {
+ const added = await db
+ .insert(phone_numbers)
+ .values({ id: uid('pn'), workspace_id: id, e164: number, provider: 'dev', created_at: new Date().toISOString() })
+ .onConflictDoNothing({ target: phone_numbers.e164 })
+ .returning({ id: phone_numbers.id })
+ if (added.length) break
+ number = randomNumber()
+ }
const [contact] = await db
.insert(contacts)
.values({ id: uid('ct'), workspace_id: id, phone: randomNumber(), name: 'Known Caller' })