Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Merge workspace invitations: nobody joins a workspace without saying yes, people are found by username, your own invites can bring someone in, and nobody is left without a workspace (identity 0040) | 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; | |
| 3 | ||
| 4 | import { inviteTarget, looksLikeEmail, peopleQuery } from "./people-search.ts"; | |
| 5 | import { declinedLine, invitationLine } from "./invitations.ts"; | |
| 6 | ||
| 7 | test("people are searched by username or name, and an email address is never looked up", () => { | |
| 8 | assert.equal(peopleQuery(" @daw "), "daw"); | |
| 9 | assert.equal(peopleQuery("Dawn W"), "Dawn W"); | |
| 10 | assert.equal(peopleQuery("dawn@example.com"), null); | |
| 11 | assert.equal(peopleQuery(" "), null); | |
| 12 | assert.equal(peopleQuery("@"), null); | |
| 13 | assert.equal(looksLikeEmail("@ada"), false); | |
| 14 | }); | |
| 15 | ||
| 16 | test("the invite form names an address or a username", () => { | |
| 17 | assert.deepEqual(inviteTarget("Ada@Example.com "), { email: "Ada@Example.com" }); | |
| 18 | assert.deepEqual(inviteTarget("@DaWeazl"), { username: "daweazl" }); | |
| 19 | assert.equal(inviteTarget(" "), null); | |
| 20 | }); | |
| 21 | ||
| 22 | test("an invitation says the role it joins with and how long it works", () => { | |
| 23 | const now = Date.parse("2026-10-08T12:00:00Z"); | |
| 24 | assert.equal( | |
| 25 | invitationLine({ role: "member", expiresAt: "2026-11-07T12:00:00Z" }, now), | |
| 26 | "invited you to join as a member. It works for 30 more days.", | |
| 27 | ); | |
| 28 | assert.equal(invitationLine({ role: "owner", expiresAt: "2026-10-09T00:00:00Z" }, now), "invited you to join as an owner. It expires within a day."); | |
| 29 | assert.match(declinedLine("Flagon, Inc."), /declined the invitation to Flagon, Inc\..*told/); | |
| 30 | }); |
This file's history is long; its oldest lines are credited to the oldest commit read.