g1t/apps/web/app/lib/opened-by.test.ts

30 lines1,412 bytesCodeBlame

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.

g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent1import assert from "node:assert/strict";
2import { test } from "node:test";
3
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights4import { workOwner } from "../../../../packages/contracts/src/work.ts";
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent5import { madeByG1t, openedBy } from "./opened-by.ts";
6
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights7const syntaqx = { id: "usr_1", username: "syntaqx" };
8const g1t = { id: "usr_g1t_agent", username: "g1t", kind: "agent" as const };
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent9
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights10test("a pull request g1t made shows g1t, requested by whoever asked", () => {
11 const pull = { agent: "g1t", branch: null, author: g1t, requestedBy: syntaqx };
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent12 assert.equal(madeByG1t(pull), true);
13 assert.deepEqual(openedBy(pull), { name: "g1t", requestedBy: "syntaqx" });
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights14 // It is theirs to manage, as their own would be.
15 assert.equal(workOwner(pull).id, "usr_1");
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent16});
17
18test("anything else shows its author", () => {
19 // Someone's own agent.
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights20 assert.deepEqual(openedBy({ author: syntaqx, requestedBy: null }), { name: "syntaqx", requestedBy: null });
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent21 // A branch pushed to the repository, even with g1t named on it.
22 assert.equal(madeByG1t({ agent: "g1t", branch: "fix-login" }), false);
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights23 assert.equal(workOwner({ author: syntaqx, requestedBy: null }).id, "usr_1");
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent24});
25
26test("work g1t started itself names nobody as asking", () => {
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights27 const pull = { author: { id: "g1t", username: "g1t", kind: "system" as const }, requestedBy: null };
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent28 assert.deepEqual(openedBy(pull), { name: "g1t", requestedBy: null });
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights29 assert.equal(workOwner(pull).username, "g1t");
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent30});