Skip to content
41 linesCodeBlameRaw

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.

Account deletion: from Settings and sudo, soft for 30 days, then purged to ghost (identity 0037)1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { accountWentSummary, confirmsUsername, staffDeletionRefusal } from "./deleted-accounts.ts";
5
6const deletion = {
7 username: "ada",
8 workspaces: 2,
9 tokens: 1,
10 ssh_keys: 0,
11 applications: 0,
12 repositories: 0,
13 sole_owner_of: [],
14 protected: false,
15};
16
17test("what went reads as one line", () => {
18 assert.equal(
19 accountWentSummary({ workspaces: 2, teams: 1, repositories: 3, tokens: 1, sshKeys: 2, staff: null, reason: null }),
20 "2 workspaces, 1 team, 3 repositories, 1 token, 2 SSH keys",
21 );
22});
23
24test("an account that owns workspaces alone, or is protected, is refused", () => {
25 assert.equal(staffDeletionRefusal(deletion), null);
26 const owner = { ...deletion, sole_owner_of: [{ slug: "acme", name: "Acme", members: 3, billing: null }] };
27 assert.equal(
28 staffDeletionRefusal(owner),
29 "ada is the only owner of 1 workspace. Each needs another owner, or to be deleted by its owner, first.",
30 );
31 assert.equal(
32 staffDeletionRefusal({ ...owner, username: "g1t", protected: true }),
33 "g1t is protected and can never be deleted.",
34 );
35});
36
37test("staff confirm with the username", () => {
38 assert.ok(confirmsUsername("ada", " ADA "));
39 assert.ok(!confirmsUsername("ada", ""));
40 assert.ok(!confirmsUsername("ada", "grace"));
41});