| 1 | import { execFile, execFileSync } from 'node:child_process'; |
| 2 | import { mkdtempSync, rmSync |
| 3 | import { tmpdir } |
| 4 | import path from 'node:path |
| 5 | import { promisify } |
| 6 | import type { INestApplication |
| 7 | import { AuthService } |
| 8 | import request from 'supertest |
| 9 | import { afterAll, beforeAll |
| 10 | |
| 11 | import type { Auth |
| 12 | import { S3Service } |
| 13 | import { hasBackends, signUp |
| 14 | |
| 15 | type Account |
| 16 | |
| 17 | describe.skipIf(!hasBackends |
| 18 | let app: |
| 19 | let origin: |
| 20 | let owner: |
| 21 | let alice: |
| 22 | let mallory: |
| 23 | let bob: |
| 24 | let organizationId: |
| 25 | let aliceMemberId: |
| 26 | let work: |
| 27 | const stamp = |
| 28 | const ownerName = |
| 29 | const aliceName = |
| 30 | const org = |
| 31 | |
| 32 | const api = |
| 33 | const auth = |
| 34 | const at = |
| 35 | const git = |
| 36 | execFileSync( |
| 37 | 'git', |
| 38 | ['-c', 'user.name=E2E' |
| 39 | { cwd: work, |
| 40 | ).trim(); |
| 41 | // The server runs in this process, so anything that talks to it must not block the event loop. |
| 42 | const push = |
| 43 | promisify(execFile)( |
| 44 | 'git', |
| 45 | [ |
| 46 | 'push', |
| 47 | '-q', |
| 48 | `${origin.replace( |
| 49 | 'HEAD:refs/heads/main', |
| 50 | ], |
| 51 | { cwd: work, |
| 52 | ); |
| 53 | const settings = |
| 54 | api() |
| 55 | .patch(`/api/organizations/${org |
| 56 | .set('cookie', |
| 57 | .send(changes); |
| 58 | const create = |
| 59 | api().post(' |
| 60 | |
| 61 | beforeAll(async () |
| 62 | ({ app, origin |
| 63 | owner = await |
| 64 | alice = await |
| 65 | mallory = await |
| 66 | bob = await |
| 67 | |
| 68 | const created = |
| 69 | body: { name: ' |
| 70 | headers: new Headers |
| 71 | }); |
| 72 | organizationId = created! |
| 73 | const member = |
| 74 | body: { userId: alice |
| 75 | }); |
| 76 | aliceMemberId = member! |
| 77 | await settings(owner |
| 78 | |
| 79 | work = mkdtempSync( |
| 80 | git('init', |
| 81 | git('commit', |
| 82 | }, 120_000); |
| 83 | |
| 84 | afterAll(async () |
| 85 | await app?.close |
| 86 | if (work) rmSync |
| 87 | }); |
| 88 | |
| 89 | it('keeps usernames and organization slugs apart', |
| 90 | await expect( |
| 91 | auth().createOrganization({ |
| 92 | body: { name: ' |
| 93 | headers: new Headers |
| 94 | }), |
| 95 | ).rejects.toThrow( |
| 96 | await expect(signUp |
| 97 | 'An organization already uses that name', |
| 98 | ); |
| 99 | }); |
| 100 | |
| 101 | it('follows the organization’s policy on who creates repositories', |
| 102 | await settings(alice |
| 103 | membersCanCreatePrivateRepositories: false, |
| 104 | }).expect(403) |
| 105 | await settings(owner |
| 106 | membersCanCreatePublicRepositories: false, |
| 107 | membersCanCreatePrivateRepositories: false, |
| 108 | }).expect(200) |
| 109 | await create(alice |
| 110 | await create(mallory |
| 111 | |
| 112 | const { body |
| 113 | name: 'widget', |
| 114 | organization: org, |
| 115 | visibility: 'private', |
| 116 | }).expect(201) |
| 117 | expect(body.slug |
| 118 | |
| 119 | // A slug is unique per namespace, so the founder's own `widget` is not suffixed. |
| 120 | const personal = |
| 121 | expect(personal.body |
| 122 | }); |
| 123 | |
| 124 | it('gives members their organization role on its repositories', |
| 125 | const { body |
| 126 | .get(at()) |
| 127 | .set('cookie', |
| 128 | .expect(200); |
| 129 | expect(body.viewerRole |
| 130 | await api().get |
| 131 | await api().get |
| 132 | |
| 133 | await push(aliceName |
| 134 | const branches = |
| 135 | .get(at(' |
| 136 | .set('cookie', |
| 137 | .expect(200); |
| 138 | expect(branches.body |
| 139 | }); |
| 140 | |
| 141 | it('lists the repository under the organization and on the dashboard', |
| 142 | const listed = |
| 143 | .get(`/api/repositories/${org |
| 144 | .set('cookie', |
| 145 | .expect(200); |
| 146 | expect( |
| 147 | listed.body.repositories |
| 148 | ).toEqual(['widget' |
| 149 | const anonymous = |
| 150 | expect(anonymous.body |
| 151 | |
| 152 | const mine = |
| 153 | .get('/api/repositories') |
| 154 | .set('cookie', |
| 155 | .expect(200); |
| 156 | expect(mine.body |
| 157 | expect.objectContaining({ |
| 158 | owner: org, |
| 159 | slug: 'widget', |
| 160 | viewerRole: 'write', |
| 161 | }), |
| 162 | ]); |
| 163 | }); |
| 164 | |
| 165 | it('shows the organization to everyone, and who is in it to members only', |
| 166 | const publicView = |
| 167 | expect(publicView.body |
| 168 | slug: org, |
| 169 | name: 'Acme', |
| 170 | repositoryCount: 0, |
| 171 | members: [], |
| 172 | viewerRole: null, |
| 173 | }); |
| 174 | const outsider = |
| 175 | .get(`/api/organizations/${org |
| 176 | .set('cookie', |
| 177 | .expect(200); |
| 178 | expect(outsider.body |
| 179 | |
| 180 | const memberView = |
| 181 | .get(`/api/organizations/${org |
| 182 | .set('cookie', |
| 183 | .expect(200); |
| 184 | expect(memberView.body |
| 185 | expect( |
| 186 | memberView.body.members |
| 187 | ).toEqual([ownerName, |
| 188 | |
| 189 | const organizationsOf = |
| 190 | const call = |
| 191 | return (account ? |
| 192 | }; |
| 193 | expect((await organizationsOf |
| 194 | expect((await organizationsOf |
| 195 | expect((await organizationsOf |
| 196 | expect.objectContaining({ |
| 197 | ]); |
| 198 | |
| 199 | const mine = |
| 200 | .get('/api/organizations') |
| 201 | .set('cookie', |
| 202 | .expect(200); |
| 203 | expect(mine.body |
| 204 | expect.objectContaining({ |
| 205 | ]); |
| 206 | }); |
| 207 | |
| 208 | it('invites a user by username without revealing their email', |
| 209 | const carol = |
| 210 | const invite = |
| 211 | api() |
| 212 | .post(`/api/organizations/${org |
| 213 | .set('cookie', |
| 214 | .send({ username |
| 215 | |
| 216 | await invite(alice |
| 217 | await invite(owner |
| 218 | await invite(owner |
| 219 | await invite(owner |
| 220 | |
| 221 | // Carol never verified her email, which Better Auth's own listing insists on. |
| 222 | const { body: |
| 223 | .get('/api/invitations/organizations') |
| 224 | .set('cookie', |
| 225 | .expect(200); |
| 226 | expect(received.invitations |
| 227 | expect.objectContaining({ |
| 228 | organization: expect.objectContaining |
| 229 | role: 'member', |
| 230 | invitedByUsername: ownerName, |
| 231 | }), |
| 232 | ]); |
| 233 | await auth().acceptInvitation |
| 234 | body: { invitationId: received |
| 235 | headers: new Headers |
| 236 | }); |
| 237 | |
| 238 | const { body |
| 239 | .get(`/api/organizations/${org |
| 240 | .set('cookie', |
| 241 | .expect(200); |
| 242 | expect(body.viewerRole |
| 243 | }); |
| 244 | |
| 245 | it('lets an admin set and remove the organization logo', |
| 246 | const png = |
| 247 | const upload = |
| 248 | api() |
| 249 | .put(`/api/organizations/${org |
| 250 | .set('cookie', |
| 251 | .set('Content-Type', |
| 252 | .send(png); |
| 253 | |
| 254 | await upload(alice |
| 255 | await upload(mallory |
| 256 | const { body |
| 257 | |
| 258 | const profile = |
| 259 | expect(profile.body |
| 260 | const served = |
| 261 | .get(new URL |
| 262 | .expect(200) |
| 263 | .expect('Content-Type', |
| 264 | expect(Buffer.from |
| 265 | |
| 266 | await api() |
| 267 | .delete(`/api/organizations/${org |
| 268 | .set('cookie', |
| 269 | .expect(204); |
| 270 | const cleared = |
| 271 | expect(cleared.body |
| 272 | }); |
| 273 | |
| 274 | it('removes the logo from storage with the organization', |
| 275 | const temporary = |
| 276 | body: { name: ' |
| 277 | headers: new Headers |
| 278 | }); |
| 279 | await api() |
| 280 | .put(`/api/organizations/temp${stamp |
| 281 | .set('cookie', |
| 282 | .set('Content-Type', |
| 283 | .send(Buffer.from |
| 284 | .expect(200); |
| 285 | const stored = |
| 286 | const s3 = |
| 287 | const listed = |
| 288 | Bucket: s3.bucket |
| 289 | Prefix: `avatars/${temporary |
| 290 | }); |
| 291 | return listed.Contents |
| 292 | }; |
| 293 | expect(await stored |
| 294 | |
| 295 | await auth().deleteOrganization |
| 296 | body: { organizationId: temporary |
| 297 | headers: new Headers |
| 298 | }); |
| 299 | expect(await stored |
| 300 | }); |
| 301 | |
| 302 | it('reserves route names and reports a name held in the other namespace as taken', |
| 303 | await expect(signUp |
| 304 | 'That name is reserved', |
| 305 | ); |
| 306 | await expect( |
| 307 | auth().createOrganization({ |
| 308 | body: { name: ' |
| 309 | headers: new Headers |
| 310 | }), |
| 311 | ).rejects.toThrow( |
| 312 | |
| 313 | const { available |
| 314 | body: { username: org |
| 315 | }); |
| 316 | expect(available).toBe |
| 317 | await expect( |
| 318 | auth().checkOrganizationSlug({ |
| 319 | body: { slug: aliceName |
| 320 | headers: new Headers |
| 321 | }), |
| 322 | ).rejects.toThrow( |
| 323 | |
| 324 | const { body |
| 325 | expect(body.slug |
| 326 | }); |
| 327 | |
| 328 | it('gives a team its role on a repository', |
| 329 | await auth().addMember |
| 330 | body: { userId: bob |
| 331 | }); |
| 332 | const team = |
| 333 | body: { name: ' |
| 334 | headers: new Headers |
| 335 | }); |
| 336 | await auth().addTeamMember |
| 337 | body: { teamId: team |
| 338 | headers: new Headers |
| 339 | }); |
| 340 | const role = |
| 341 | (await api(). |
| 342 | .viewerRole; |
| 343 | |
| 344 | expect(await role |
| 345 | await api() |
| 346 | .put(at(` |
| 347 | .set('cookie', |
| 348 | .send({ role: |
| 349 | .expect(403); |
| 350 | await api() |
| 351 | .put(at(` |
| 352 | .set('cookie', |
| 353 | .send({ role: |
| 354 | .expect(204); |
| 355 | expect(await role |
| 356 | |
| 357 | const { body |
| 358 | .get(at(' |
| 359 | .set('cookie', |
| 360 | .expect(200); |
| 361 | // Better Auth gives every organization a default team, which has no access here. |
| 362 | expect(body.teams |
| 363 | expect.objectContaining({ |
| 364 | ); |
| 365 | expect( |
| 366 | body.teams.filter |
| 367 | ).toHaveLength(1); |
| 368 | |
| 369 | await api() |
| 370 | .delete(at(` |
| 371 | .set('cookie', |
| 372 | .expect(204); |
| 373 | expect(await role |
| 374 | }); |
| 375 | |
| 376 | it('counts commits to an organization repository in the contribution graph', |
| 377 | git( |
| 378 | '-c', |
| 379 | `user.email=${aliceName}@example.com` |
| 380 | 'commit', |
| 381 | '-q', |
| 382 | '--allow-empty', |
| 383 | '-m', |
| 384 | 'from alice', |
| 385 | ); |
| 386 | await push(aliceName |
| 387 | |
| 388 | await vi.waitFor |
| 389 | async () => |
| 390 | const { body |
| 391 | .get(`/api/users/${aliceName |
| 392 | .set('cookie', |
| 393 | .expect(200); |
| 394 | expect(body.totalContributions |
| 395 | }, |
| 396 | { timeout: 10_000, interval |
| 397 | ); |
| 398 | // Private to the organization, so nobody outside it sees the count. |
| 399 | const outside = |
| 400 | .get(`/api/users/${aliceName |
| 401 | .expect(200); |
| 402 | expect(outside.body |
| 403 | }); |
| 404 | |
| 405 | it('forks into an organization an admin runs', |
| 406 | await create(owner |
| 407 | const fork = |
| 408 | api() |
| 409 | .post(`/api/repositories/${ownerName |
| 410 | .set('cookie', |
| 411 | .send({ name: |
| 412 | |
| 413 | await fork(alice |
| 414 | const { body |
| 415 | expect(body).toMatchObject |
| 416 | await fork(owner |
| 417 | await api().get |
| 418 | }); |
| 419 | |
| 420 | it('transfers at once where the owner holds the destination, and on acceptance elsewhere', |
| 421 | await create(owner |
| 422 | const transfer = |
| 423 | api() |
| 424 | .post(`/api/repositories/${from |
| 425 | .set('cookie', |
| 426 | .send({ owner: |
| 427 | |
| 428 | await transfer(ownerName |
| 429 | await api() |
| 430 | .post(`/api/repositories/${ownerName |
| 431 | .set('cookie', |
| 432 | .send({ owner: |
| 433 | .expect(409); |
| 434 | |
| 435 | const { body |
| 436 | expect(body).toMatchObject |
| 437 | username: org, |
| 438 | slug: 'gadget', |
| 439 | pending: false, |
| 440 | }); |
| 441 | // The old name still leads there. |
| 442 | const followed = |
| 443 | .get(`/api/repositories/${ownerName |
| 444 | .set('cookie', |
| 445 | .expect(200); |
| 446 | expect(followed.body |
| 447 | const moved = |
| 448 | .get(`/api/repositories/${org |
| 449 | .set('cookie', |
| 450 | .expect(200); |
| 451 | expect(moved.body |
| 452 | await transfer(org |
| 453 | |
| 454 | // To someone else, it waits for them. |
| 455 | const offered = |
| 456 | expect(offered.body |
| 457 | const incoming = |
| 458 | .get('/api/transfers') |
| 459 | .set('cookie', |
| 460 | .expect(200); |
| 461 | expect(incoming.body |
| 462 | expect.objectContaining({ |
| 463 | repository: expect.objectContaining |
| 464 | to: aliceName, |
| 465 | requestedByUsername: ownerName, |
| 466 | }), |
| 467 | ]); |
| 468 | await api() |
| 469 | .post(`/api/transfers/${incoming |
| 470 | .set('cookie', |
| 471 | .expect(404); |
| 472 | await api() |
| 473 | .post(`/api/transfers/${incoming |
| 474 | .set('cookie', |
| 475 | .expect(201); |
| 476 | const accepted = |
| 477 | .get(`/api/repositories/${aliceName |
| 478 | .set('cookie', |
| 479 | .expect(200); |
| 480 | expect(accepted.body |
| 481 | }); |
| 482 | |
| 483 | it('waits for an organization admin when a member transfers in, and lets either side call it off', |
| 484 | const offer = |
| 485 | api() |
| 486 | .post(`/api/repositories/${aliceName |
| 487 | .set('cookie', |
| 488 | .send({ owner: |
| 489 | const incoming = |
| 490 | ( |
| 491 | await api() |
| 492 | .get('/api/transfers') |
| 493 | .set('cookie', |
| 494 | .expect(200) |
| 495 | ).body.transfers |
| 496 | const callOff = |
| 497 | api() |
| 498 | .delete(`/api/transfers/${repositoryId |
| 499 | .set('cookie', |
| 500 | |
| 501 | // Alice is only a member, so the organization's admins decide. |
| 502 | const { body |
| 503 | expect(body).toMatchObject |
| 504 | const [declined] |
| 505 | expect(declined).toMatchObject |
| 506 | await callOff(declined |
| 507 | await callOff(declined |
| 508 | expect(await incoming |
| 509 | |
| 510 | await offer().expect |
| 511 | const [withdrawn] |
| 512 | await callOff(withdrawn |
| 513 | expect(await incoming |
| 514 | |
| 515 | await offer().expect |
| 516 | const [accepted] |
| 517 | await api() |
| 518 | .post(`/api/transfers/${accepted |
| 519 | .set('cookie', |
| 520 | .expect(201); |
| 521 | const moved = |
| 522 | .get(`/api/repositories/${org |
| 523 | .set('cookie', |
| 524 | .expect(200); |
| 525 | expect(moved.body |
| 526 | }); |
| 527 | |
| 528 | it('keeps private repositories to teams when the base permission is none', |
| 529 | await settings(owner |
| 530 | await api().get |
| 531 | const listed = |
| 532 | .get(`/api/repositories/${org |
| 533 | .set('cookie', |
| 534 | .expect(200); |
| 535 | // Its public repositories are still listed; the private `widget` is not. |
| 536 | expect( |
| 537 | listed.body.repositories |
| 538 | ).not.toContain( |
| 539 | |
| 540 | const current = |
| 541 | .get(`/api/organizations/${org |
| 542 | .set('cookie', |
| 543 | .expect(200); |
| 544 | expect(current.body |
| 545 | await api() |
| 546 | .get(`/api/organizations/${org |
| 547 | .set('cookie', |
| 548 | .expect(403); |
| 549 | await settings(owner |
| 550 | }); |
| 551 | |
| 552 | it('lists and removes outside collaborators', |
| 553 | await api() |
| 554 | .put(at(` |
| 555 | .set('cookie', |
| 556 | .send({ role: |
| 557 | .expect(200); |
| 558 | const outside = |
| 559 | .get(`/api/organizations/${org |
| 560 | .set('cookie', |
| 561 | .expect(200); |
| 562 | expect(outside.body |
| 563 | expect.objectContaining({ |
| 564 | username: `mallory${stamp |
| 565 | repositories: [{ slug: |
| 566 | }), |
| 567 | ]); |
| 568 | await api() |
| 569 | .delete(`/api/organizations/${org |
| 570 | .set('cookie', |
| 571 | .expect(204); |
| 572 | const after = |
| 573 | .get(`/api/organizations/${org |
| 574 | .set('cookie', |
| 575 | .expect(200); |
| 576 | expect(after.body |
| 577 | }); |
| 578 | |
| 579 | it('shows pinned repositories and public members on the profile', |
| 580 | await api() |
| 581 | .put(`/api/organizations/${org |
| 582 | .set('cookie', |
| 583 | .send({ repositories: |
| 584 | .expect(204); |
| 585 | await api() |
| 586 | .put(`/api/organizations/${org |
| 587 | .set('cookie', |
| 588 | .expect(204); |
| 589 | await settings(owner |
| 590 | |
| 591 | const { body |
| 592 | expect(body.description |
| 593 | // `widget` is private, so the public sees only `lib`. |
| 594 | expect(body.pinned |
| 595 | expect(body.members |
| 596 | aliceName, |
| 597 | ]); |
| 598 | const of = await |
| 599 | .get(`/api/users/${aliceName |
| 600 | .expect(200); |
| 601 | expect(of.body |
| 602 | expect.objectContaining({ |
| 603 | ]); |
| 604 | |
| 605 | const inside = |
| 606 | .get(`/api/organizations/${org |
| 607 | .set('cookie', |
| 608 | .expect(200); |
| 609 | expect(inside.body |
| 610 | 'lib', |
| 611 | 'widget', |
| 612 | ]); |
| 613 | |
| 614 | await api() |
| 615 | .delete(`/api/organizations/${org |
| 616 | .set('cookie', |
| 617 | .expect(404); |
| 618 | await api() |
| 619 | .delete(`/api/organizations/${org |
| 620 | .set('cookie', |
| 621 | .expect(204); |
| 622 | const hidden = |
| 623 | expect(hidden.body |
| 624 | }); |
| 625 | |
| 626 | it('lets a team maintainer manage the team without administering the organization', |
| 627 | const team = |
| 628 | `/api/organizations/${org}/teams/core${ |
| 629 | const { body |
| 630 | .get(team()) |
| 631 | .set('cookie', |
| 632 | .expect(200); |
| 633 | expect(body).toMatchObject |
| 634 | expect(body.members |
| 635 | `bob${stamp}`, |
| 636 | ]); |
| 637 | |
| 638 | await api() |
| 639 | .put(team(` |
| 640 | .set('cookie', |
| 641 | .expect(403); |
| 642 | await api() |
| 643 | .put(team(` |
| 644 | .set('cookie', |
| 645 | .expect(204); |
| 646 | await api() |
| 647 | .put(team(` |
| 648 | .set('cookie', |
| 649 | .expect(204); |
| 650 | await api() |
| 651 | .put(team(` |
| 652 | .set('cookie', |
| 653 | .expect(400); |
| 654 | |
| 655 | const updated = |
| 656 | .get(team()) |
| 657 | .set('cookie', |
| 658 | .expect(200); |
| 659 | expect(updated.body |
| 660 | expect(updated.body |
| 661 | expect.objectContaining({ |
| 662 | expect.objectContaining({ |
| 663 | ]); |
| 664 | const listed = |
| 665 | .get(`/api/organizations/${org |
| 666 | .set('cookie', |
| 667 | .expect(200); |
| 668 | expect(listed.body |
| 669 | expect.objectContaining({ |
| 670 | ); |
| 671 | await api().get |
| 672 | }); |
| 673 | |
| 674 | it('dismisses maintainers, and stops a member leaving the team from maintaining it', |
| 675 | const team = |
| 676 | `/api/organizations/${org}/teams/core${ |
| 677 | const canManage = |
| 678 | (await api(). |
| 679 | .viewerCanManage; |
| 680 | |
| 681 | await api() |
| 682 | .delete(team(` |
| 683 | .set('cookie', |
| 684 | .expect(204); |
| 685 | expect(await canManage |
| 686 | |
| 687 | await api() |
| 688 | .put(team(` |
| 689 | .set('cookie', |
| 690 | .expect(204); |
| 691 | await api() |
| 692 | .delete(team(` |
| 693 | .set('cookie', |
| 694 | .expect(204); |
| 695 | await api() |
| 696 | .put(team(` |
| 697 | .set('cookie', |
| 698 | .expect(204); |
| 699 | const { body |
| 700 | .get(team()) |
| 701 | .set('cookie', |
| 702 | .expect(200); |
| 703 | expect(body.members |
| 704 | expect.objectContaining({ |
| 705 | ); |
| 706 | expect(await canManage |
| 707 | }); |
| 708 | |
| 709 | it('refuses to fork private repositories unless the organization allows it', |
| 710 | const fork = |
| 711 | api() |
| 712 | .post(at(' |
| 713 | .set('cookie', |
| 714 | .send({ name: |
| 715 | await fork().expect |
| 716 | await settings(owner |
| 717 | await fork().expect |
| 718 | }); |
| 719 | |
| 720 | it('records the organization default branch on new repositories', |
| 721 | await settings(owner |
| 722 | await create(owner |
| 723 | const { body |
| 724 | .get(`/api/repositories/${org |
| 725 | .set('cookie', |
| 726 | .expect(200); |
| 727 | expect(body.defaultBranch |
| 728 | }); |
| 729 | |
| 730 | it('narrows repository search to one owner with org:', |
| 731 | const { body |
| 732 | .get(`/api/search/repositories?q=${encodeURIComponent |
| 733 | .expect(200); |
| 734 | expect( |
| 735 | body.repositories.map |
| 736 | (r: { |
| 737 | ), |
| 738 | ).toEqual([`${org |
| 739 | }); |
| 740 | |
| 741 | it('matches no code for an owner qualifier alone, or an owner with no public repositories', |
| 742 | const search = |
| 743 | api() |
| 744 | .get(`/api/search/code?q=${encodeURIComponent |
| 745 | .expect(200); |
| 746 | expect((await search |
| 747 | expect((await search |
| 748 | }); |
| 749 | |
| 750 | it('lets members create what the policy allows', |
| 751 | await settings(owner |
| 752 | 200, |
| 753 | ); |
| 754 | await create(alice |
| 755 | name: 'gizmo', |
| 756 | organization: org, |
| 757 | visibility: 'public', |
| 758 | }).expect(201) |
| 759 | await create(alice |
| 760 | name: 'secret', |
| 761 | organization: org, |
| 762 | visibility: 'private', |
| 763 | }).expect(403) |
| 764 | }); |
| 765 | |
| 766 | it('refuses to delete an organization that still has repositories', |
| 767 | await expect( |
| 768 | auth().deleteOrganization({ |
| 769 | body: { organizationId |
| 770 | headers: new Headers |
| 771 | }), |
| 772 | ).rejects.toThrow( |
| 773 | 'Delete or transfer the organization’s repositories first', |
| 774 | ); |
| 775 | await api().get |
| 776 | }); |
| 777 | |
| 778 | it('takes access away with membership', |
| 779 | await auth().removeMember |
| 780 | body: { memberIdOrEmail: aliceMemberId |
| 781 | headers: new Headers |
| 782 | }); |
| 783 | await api().get |
| 784 | }); |
| 785 | }); |