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 account deletion: soft delete for 30 days, staff restore and purge, ghost for what remains (identity 0037) | 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; | |
| 3 | ||
| 4 | import { accountDeletionRefusal, confirmsUsername, whatAccountDeletionTakes } from "./account-deletion.ts"; | |
| 5 | ||
| 6 | const nothing = { | |
| 7 | username: "ada", | |
| 8 | workspaces: 0, | |
| 9 | tokens: 0, | |
| 10 | ssh_keys: 0, | |
| 11 | applications: 0, | |
| 12 | repositories: 0, | |
| 13 | sole_owner_of: [], | |
| 14 | protected: false, | |
| 15 | }; | |
| 16 | ||
| Merge sudo: delete an account with the workspaces it alone owns, purge each | 17 | const sole = (slug: string) => ({ slug, name: slug, members: 3, billing: null, protected: false }); |
| Merge account deletion: soft delete for 30 days, staff restore and purge, ghost for what remains (identity 0037) | 18 | |
| 19 | test("the dialog lists only what the account has", () => { | |
| 20 | assert.deepEqual(whatAccountDeletionTakes(nothing), []); | |
| 21 | assert.deepEqual( | |
| 22 | whatAccountDeletionTakes({ ...nothing, workspaces: 2, repositories: 1, tokens: 3, ssh_keys: 1, applications: 2 }), | |
| 23 | [ | |
| 24 | "Your membership of 2 workspaces", | |
| 25 | "Your role on 1 repository you were added to", | |
| 26 | "3 access tokens", | |
| 27 | "1 SSH key", | |
| 28 | "2 connected applications", | |
| 29 | ], | |
| 30 | ); | |
| 31 | assert.deepEqual(whatAccountDeletionTakes({ ...nothing, workspaces: 1, tokens: 1 }), [ | |
| 32 | "Your membership of 1 workspace", | |
| 33 | "1 access token", | |
| 34 | ]); | |
| 35 | }); | |
| 36 | ||
| 37 | test("owning a workspace alone stands in the way, and names it", () => { | |
| 38 | assert.equal(accountDeletionRefusal(null), null); | |
| 39 | assert.equal(accountDeletionRefusal({ ...nothing, workspaces: 4 }), null); | |
| 40 | assert.equal( | |
| 41 | accountDeletionRefusal({ ...nothing, sole_owner_of: [sole("acme")] }), | |
| 42 | "You are the only owner of acme. Make someone else an owner of it, or delete it, first.", | |
| 43 | ); | |
| 44 | assert.equal( | |
| 45 | accountDeletionRefusal({ ...nothing, sole_owner_of: [sole("acme"), sole("globex"), sole("initech")] }), | |
| 46 | "You are the only owner of acme, globex and initech. Make someone else an owner of each, or delete them, first.", | |
| 47 | ); | |
| 48 | }); | |
| 49 | ||
| 50 | test("a protected account says so first", () => { | |
| 51 | assert.equal( | |
| 52 | accountDeletionRefusal({ ...nothing, username: "g1t", protected: true, sole_owner_of: [sole("acme")] }), | |
| 53 | "g1t is protected and can never be deleted.", | |
| 54 | ); | |
| 55 | }); | |
| 56 | ||
| 57 | test("only the username itself confirms", () => { | |
| 58 | assert.ok(confirmsUsername("ada", " Ada ")); | |
| 59 | assert.ok(!confirmsUsername("ada", "")); | |
| 60 | assert.ok(!confirmsUsername("ada", " ")); | |
| 61 | assert.ok(!confirmsUsername("ada", "ada-l")); | |
| 62 | }); |
This file's history is long; its oldest lines are credited to the oldest commit read.