sdtk-code-kit 0.4.4 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/assets/manifest/toolkit-bundle.manifest.json +139 -14
- package/assets/manifest/toolkit-bundle.sha256.txt +33 -8
- package/assets/toolkit/toolkit/AGENTS.md +2 -1
- package/assets/toolkit/toolkit/SDTKCODE_TOOLKIT.md +2 -2
- package/assets/toolkit/toolkit/scripts/install-claude-skills.ps1 +4 -4
- package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +4 -4
- package/assets/toolkit/toolkit/scripts/uninstall-claude-skills.ps1 +2 -2
- package/assets/toolkit/toolkit/scripts/uninstall-codex-skills.ps1 +2 -2
- package/assets/toolkit/toolkit/skills/code-discover/SKILL.md +7 -2
- package/assets/toolkit/toolkit/skills/code-issue/SKILL.md +75 -0
- package/assets/toolkit/toolkit/skills/code-issue/references/MODE_FIX.md +31 -0
- package/assets/toolkit/toolkit/skills/code-issue/references/MODE_PICK.md +19 -0
- package/assets/toolkit/toolkit/skills/code-issue/references/MODE_PLAN.md +23 -0
- package/assets/toolkit/toolkit/skills/code-issue/references/MODE_REVIEW.md +21 -0
- package/assets/toolkit/toolkit/skills/code-issue/references/PROFILE_TEMPLATE.md +53 -0
- package/assets/toolkit/toolkit/skills/code-issue/references/RECORDS.md +39 -0
- package/assets/toolkit/toolkit/skills/code-issue/scripts/test_tracker.py +283 -0
- package/assets/toolkit/toolkit/skills/code-issue/scripts/tracker.py +465 -0
- package/assets/toolkit/toolkit/skills/code-review/SKILL.md +2 -1
- package/assets/toolkit/toolkit/skills/code-review/references/lead-review-lessons.md +30 -0
- package/assets/toolkit/toolkit/skills/code-review/references/lead-review.md +120 -0
- package/assets/toolkit/toolkit/skills/code-ui-e2e/SKILL.md +97 -0
- package/assets/toolkit/toolkit/skills/code-ui-e2e/references/PROFILE_TEMPLATE.md +30 -0
- package/assets/toolkit/toolkit/skills/code-ui-e2e/references/SAFETY.md +17 -0
- package/assets/toolkit/toolkit/skills/code-ui-e2e/references/TEST_HOOKS.md +32 -0
- package/assets/toolkit/toolkit/skills/code-ui-e2e/scripts/app_profile.py +118 -0
- package/assets/toolkit/toolkit/skills/code-ui-e2e/scripts/build_test_app.py +140 -0
- package/assets/toolkit/toolkit/skills/code-ui-e2e/scripts/cli.py +46 -0
- package/assets/toolkit/toolkit/skills/code-ui-e2e/scripts/fault_proxy.py +381 -0
- package/assets/toolkit/toolkit/skills/code-ui-e2e/scripts/run_smoke.py +242 -0
- package/assets/toolkit/toolkit/skills/code-ui-e2e/scripts/test_app_profile.py +79 -0
- package/assets/toolkit/toolkit/skills/code-ui-e2e/scripts/test_fault_proxy.py +327 -0
- package/assets/toolkit/toolkit/skills/code-ui-e2e/scripts/test_run_smoke.py +79 -0
- package/assets/toolkit/toolkit/skills/code-ui-e2e/scripts/uia_base.py +127 -0
- package/assets/toolkit/toolkit/skills/code-ui-e2e/scripts/waits.py +40 -0
- package/package.json +1 -1
- package/src/lib/scope.js +2 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Issue profile — <project>
|
|
2
|
+
|
|
3
|
+
`issue_profile.json` is read by `scripts/tracker.py`. It is found from the working directory upward in `./`,
|
|
4
|
+
`docs/`, `docs/issues/` or `.sdtk/`, or given with `--profile`. It holds no secret and may be committed; when the
|
|
5
|
+
tracker belongs to a customer, keep it untracked (`.git/info/exclude`).
|
|
6
|
+
|
|
7
|
+
## issue_profile.json
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"tracker": "redmine",
|
|
12
|
+
"base_url": "https://tracker.example.com",
|
|
13
|
+
"project": "order-app",
|
|
14
|
+
"me": "me",
|
|
15
|
+
"credentials_env": {"token": "ISSUE_TRACKER_TOKEN", "user": "ISSUE_TRACKER_USER"},
|
|
16
|
+
"statuses": {"in_progress": 2, "resolved": 3, "review": 7, "feedback": 4},
|
|
17
|
+
"priority_order": ["Immediate", "Urgent", "High", "Normal", "Low"],
|
|
18
|
+
"title_pattern": "^\\[(?P<feature>[A-Z0-9-]+)\\]",
|
|
19
|
+
"features": {"ORD": "Order management", "INV": "Invoices"},
|
|
20
|
+
"records_dir": "docs/issues",
|
|
21
|
+
"base_branch": "develop",
|
|
22
|
+
"reassign_on_fix": "qa-lead"
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
| Key | github | redmine | jira |
|
|
27
|
+
|---|---|---|---|
|
|
28
|
+
| `project` | `owner/repo` | project identifier | project key |
|
|
29
|
+
| `base_url` | optional (GitHub Enterprise API URL) | required | required |
|
|
30
|
+
| `me` | your login (used as `assignee`) | user id or `me` | ignored (`currentUser()`) |
|
|
31
|
+
| `statuses` values | `open` / `closed`, or a label to add | status id | transition name, id or target status name |
|
|
32
|
+
| priority | `priority_labels` (ordered) | issue priority name, ranked by `priority_order` | same |
|
|
33
|
+
| blocked | `blocked_labels` | a `blocks` relation pointing at the issue | an open `Blocks` inward link |
|
|
34
|
+
| credentials | `token` (or a signed-in `gh`) | `token` = API key | `user` + `token` (cloud) or `token` (PAT) |
|
|
35
|
+
|
|
36
|
+
Credentials live in environment variables or a `.env` next to the profile or at the repository root — never committed (add it to
|
|
37
|
+
`.gitignore` or `.git/info/exclude` first). `python scripts/tracker.py check` says which one is missing.
|
|
38
|
+
|
|
39
|
+
## Title convention (give this to whoever files issues)
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
[<FEATURE>] <what is wrong or wanted, in one line>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`<FEATURE>` is a key of `features` (for example `[ORD] Total is wrong after a 10 % discount`). One issue = one
|
|
46
|
+
problem. Steps, expected and actual result in the description; screenshots / logs as attachments.
|
|
47
|
+
Titles that do not match are still picked, marked `? title does not follow the convention`: map them by reading the
|
|
48
|
+
description and the code they mention, and say which feature you assumed.
|
|
49
|
+
|
|
50
|
+
## Markdown part (optional, for people)
|
|
51
|
+
|
|
52
|
+
Workflow of statuses (who moves what), who reviews, where the real app runs for smoke checks, test accounts
|
|
53
|
+
(labels only; credentials in `.env`).
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Issue records
|
|
2
|
+
|
|
3
|
+
One folder per issue: `<records_dir>/<id>/` (default `docs/issues/<id>/`). Records are how the next session — or
|
|
4
|
+
the person — knows what was done; they are written as the work happens, not at the end. Keep them out of the
|
|
5
|
+
product repository when it belongs to a customer (records dir in the team's own repository or untracked).
|
|
6
|
+
|
|
7
|
+
Every record starts with:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
# <PLAN|FIX|REVIEW> — #<id> <title>
|
|
11
|
+
State: PLANNED | REPRODUCED | ROOT_CAUSED | FIXING | IN_REVIEW | CHANGES_REQUESTED | APPROVED | DONE | ABANDONED
|
|
12
|
+
Branch: issue/<id>-<slug> · Worktree: <path> · Base: <base_branch> @ <sha7>
|
|
13
|
+
Updated: <date> by <session / person>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## PLAN.md (plan mode)
|
|
17
|
+
|
|
18
|
+
1. **Goal** — one sentence.
|
|
19
|
+
2. **Done when** — measurable criteria (a command, a screen state, a value), each checkable by someone else.
|
|
20
|
+
3. **Facts from the code** — `file:line` and what it does today. No fact without a location.
|
|
21
|
+
4. **Bugs: reproduction** — steps, expected, actual, on which commit. **Root cause** (or "not yet known" + how
|
|
22
|
+
you will find it).
|
|
23
|
+
5. **Tasks** — ordered, each small enough for one TDD cycle; which test proves each.
|
|
24
|
+
6. **Open questions** — for the person; nothing guessed.
|
|
25
|
+
|
|
26
|
+
## FIX.md (fix mode, one per issue even in a batch)
|
|
27
|
+
|
|
28
|
+
Reproduction (commit, steps, result), root cause (`file:line`, why), fix (files, test that failed first and now
|
|
29
|
+
passes), self-review findings fixed, smoke run on the real app (build, steps, result, test data cleaned), PR link,
|
|
30
|
+
tracker comment as sent.
|
|
31
|
+
|
|
32
|
+
## REVIEW.md (review mode)
|
|
33
|
+
|
|
34
|
+
1. What was verified with real commands (command → result), and what was not.
|
|
35
|
+
2. Root-cause check — does the change fix the cause or only the symptom?
|
|
36
|
+
3. Findings `F-1 … F-n`, each `blocker | major | minor | nit`, with `file:line` and the fix wanted.
|
|
37
|
+
4. What the person must run by hand (real app, real data, other platforms).
|
|
38
|
+
5. A copy-paste prompt for the author (bot or developer) listing the blocker / major findings.
|
|
39
|
+
6. Verdict: `APPROVED` or `CHANGES_REQUESTED`.
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""tracker.py against a local stub server for each tracker kind. No network beyond 127.0.0.1."""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import contextlib
|
|
6
|
+
import io
|
|
7
|
+
import json
|
|
8
|
+
import os
|
|
9
|
+
import shutil
|
|
10
|
+
import sys
|
|
11
|
+
import tempfile
|
|
12
|
+
import threading
|
|
13
|
+
import time
|
|
14
|
+
import unittest
|
|
15
|
+
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
16
|
+
from urllib.parse import parse_qs, urlparse
|
|
17
|
+
|
|
18
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
19
|
+
sys.path.insert(0, HERE)
|
|
20
|
+
import tracker # noqa: E402
|
|
21
|
+
|
|
22
|
+
TOKEN = "s3cr3t-token-value"
|
|
23
|
+
|
|
24
|
+
GITHUB_ISSUES = [
|
|
25
|
+
{"number": 7, "title": "[ORD] Total is wrong after discount", "state": "open", "assignees": [{"login": "dev1"}],
|
|
26
|
+
"labels": [{"name": "P2"}], "created_at": "2026-01-03T00:00:00Z", "updated_at": "2026-01-05T00:00:00Z",
|
|
27
|
+
"html_url": "https://example.invalid/7"},
|
|
28
|
+
{"number": 8, "title": "[ORD] Export fails on empty list", "state": "open", "assignees": [{"login": "dev1"}],
|
|
29
|
+
"labels": [{"name": "P1"}], "created_at": "2026-01-04T00:00:00Z", "updated_at": "2026-01-04T00:00:00Z",
|
|
30
|
+
"html_url": "https://example.invalid/8"},
|
|
31
|
+
{"number": 9, "title": "Login button misaligned", "state": "open", "assignees": [{"login": "dev1"}],
|
|
32
|
+
"labels": [{"name": "P1"}], "created_at": "2026-01-02T00:00:00Z", "updated_at": "2026-01-02T00:00:00Z",
|
|
33
|
+
"html_url": "https://example.invalid/9"},
|
|
34
|
+
{"number": 10, "title": "[INV] Waits for the tax table", "state": "open", "assignees": [{"login": "dev1"}],
|
|
35
|
+
"labels": [{"name": "P1"}, {"name": "blocked"}], "created_at": "2026-01-01T00:00:00Z",
|
|
36
|
+
"updated_at": "2026-01-01T00:00:00Z", "html_url": "https://example.invalid/10"},
|
|
37
|
+
{"number": 11, "title": "a pull request", "state": "open", "assignees": [], "labels": [], "pull_request": {},
|
|
38
|
+
"created_at": "2026-01-01T00:00:00Z", "updated_at": "2026-01-01T00:00:00Z", "html_url": "x"},
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
REDMINE_ISSUES = [
|
|
42
|
+
{"id": 101, "subject": "[ORD] Rounding", "status": {"name": "New"}, "assigned_to": {"name": "Dev One"},
|
|
43
|
+
"priority": {"id": 3, "name": "High"}, "created_on": "2026-01-02", "updated_on": "2026-01-02",
|
|
44
|
+
"relations": [{"issue_id": 99, "issue_to_id": 101, "relation_type": "blocks"}]},
|
|
45
|
+
{"id": 102, "subject": "[ORD] Paging", "status": {"name": "New"}, "assigned_to": {"name": "Dev One"},
|
|
46
|
+
"priority": {"id": 2, "name": "Normal"}, "created_on": "2026-01-01", "updated_on": "2026-01-01",
|
|
47
|
+
"relations": [{"issue_id": 102, "issue_to_id": 103, "relation_type": "blocks"}]},
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
JIRA_ISSUES = [{"key": "ACME-5", "fields": {
|
|
51
|
+
"summary": "[ORD] Crash on save", "status": {"name": "To Do"}, "assignee": {"displayName": "Dev One"},
|
|
52
|
+
"priority": {"name": "High"}, "created": "2026-01-01", "updated": "2026-01-02", "labels": [],
|
|
53
|
+
"issuelinks": [{"type": {"name": "Blocks"},
|
|
54
|
+
"inwardIssue": {"key": "ACME-1", "fields": {"status": {"statusCategory": {"key": "done"}}}}}],
|
|
55
|
+
"description": "Steps: open, save.", "comment": {"comments": [{"author": {"displayName": "QA"},
|
|
56
|
+
"created": "2026-01-02", "body": "Still fails."}]},
|
|
57
|
+
"attachment": [{"filename": "log.txt"}]}}]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class Stub(BaseHTTPRequestHandler):
|
|
61
|
+
calls: list = []
|
|
62
|
+
delay = 0.0
|
|
63
|
+
|
|
64
|
+
def log_message(self, *a):
|
|
65
|
+
pass
|
|
66
|
+
|
|
67
|
+
def reply(self, data, code=200):
|
|
68
|
+
raw = json.dumps(data).encode()
|
|
69
|
+
self.send_response(code)
|
|
70
|
+
self.send_header("Content-Type", "application/json")
|
|
71
|
+
self.send_header("Content-Length", str(len(raw)))
|
|
72
|
+
self.end_headers()
|
|
73
|
+
self.wfile.write(raw)
|
|
74
|
+
|
|
75
|
+
def handle_any(self):
|
|
76
|
+
if Stub.delay:
|
|
77
|
+
time.sleep(Stub.delay)
|
|
78
|
+
length = int(self.headers.get("Content-Length") or 0)
|
|
79
|
+
body = json.loads(self.rfile.read(length)) if length else None
|
|
80
|
+
u = urlparse(self.path)
|
|
81
|
+
Stub.calls.append({"method": self.command, "path": u.path, "query": parse_qs(u.query), "body": body,
|
|
82
|
+
"headers": dict(self.headers)})
|
|
83
|
+
p = u.path
|
|
84
|
+
if p == "/repos/acme/shop/issues":
|
|
85
|
+
return self.reply(GITHUB_ISSUES)
|
|
86
|
+
if p == "/repos/acme/shop/issues/7":
|
|
87
|
+
return self.reply(dict(GITHUB_ISSUES[0], body="Discount 10% gives 89.99"))
|
|
88
|
+
if p == "/repos/acme/shop/issues/7/comments":
|
|
89
|
+
return self.reply([{"user": {"login": "qa"}, "created_at": "2026-01-06", "body": "repro attached"}]
|
|
90
|
+
if self.command == "GET" else {"id": 1})
|
|
91
|
+
if p.startswith("/repos/acme/shop/issues/7/"):
|
|
92
|
+
return self.reply({})
|
|
93
|
+
if p == "/issues.json":
|
|
94
|
+
return self.reply({"issues": REDMINE_ISSUES})
|
|
95
|
+
if p.startswith("/issues/"):
|
|
96
|
+
return self.reply({"issue": REDMINE_ISSUES[0]} if self.command == "GET" else {})
|
|
97
|
+
if p == "/rest/api/2/search":
|
|
98
|
+
return self.reply({"issues": JIRA_ISSUES})
|
|
99
|
+
if p == "/rest/api/2/issue/ACME-5":
|
|
100
|
+
return self.reply(JIRA_ISSUES[0])
|
|
101
|
+
if p == "/rest/api/2/issue/ACME-5/transitions":
|
|
102
|
+
return self.reply({"transitions": [{"id": "31", "name": "Resolve", "to": {"name": "Resolved"}}]}
|
|
103
|
+
if self.command == "GET" else {})
|
|
104
|
+
return self.reply({"error": "no route " + p}, 404)
|
|
105
|
+
|
|
106
|
+
do_GET = do_POST = do_PUT = do_PATCH = handle_any
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class TrackerTests(unittest.TestCase):
|
|
110
|
+
@classmethod
|
|
111
|
+
def setUpClass(cls):
|
|
112
|
+
cls.server = ThreadingHTTPServer(("127.0.0.1", 0), Stub)
|
|
113
|
+
cls.base = "http://127.0.0.1:%d" % cls.server.server_address[1]
|
|
114
|
+
threading.Thread(target=cls.server.serve_forever, daemon=True).start()
|
|
115
|
+
|
|
116
|
+
@classmethod
|
|
117
|
+
def tearDownClass(cls):
|
|
118
|
+
cls.server.shutdown()
|
|
119
|
+
|
|
120
|
+
def setUp(self):
|
|
121
|
+
Stub.calls.clear()
|
|
122
|
+
Stub.delay = 0.0
|
|
123
|
+
self.tmp = tempfile.mkdtemp()
|
|
124
|
+
self.env = dict(os.environ)
|
|
125
|
+
os.environ["ISSUE_TRACKER_TOKEN"] = TOKEN
|
|
126
|
+
os.environ["ISSUE_TRACKER_USER"] = "dev1@example.invalid"
|
|
127
|
+
|
|
128
|
+
def tearDown(self):
|
|
129
|
+
os.environ.clear()
|
|
130
|
+
os.environ.update(self.env)
|
|
131
|
+
shutil.rmtree(self.tmp, ignore_errors=True)
|
|
132
|
+
|
|
133
|
+
def profile(self, kind, **extra):
|
|
134
|
+
prof = {"tracker": kind, "base_url": self.base, "me": "dev1", "title_pattern": r"^\[(?P<feature>[A-Z]+)\]",
|
|
135
|
+
"features": {"ORD": "Order management"},
|
|
136
|
+
"project": {"github": "acme/shop", "redmine": "shop", "jira": "ACME"}[kind],
|
|
137
|
+
"priority_order": ["P1", "P2"] if kind == "github" else ["High", "Normal"],
|
|
138
|
+
"priority_labels": ["P1", "P2"], "blocked_labels": ["blocked"],
|
|
139
|
+
"statuses": {"resolved": {"github": "closed", "redmine": 3, "jira": "Resolved"}[kind],
|
|
140
|
+
"review": "in review"}}
|
|
141
|
+
prof.update(extra)
|
|
142
|
+
os.makedirs(os.path.join(self.tmp, "docs"), exist_ok=True)
|
|
143
|
+
path = os.path.join(self.tmp, "docs", "issue_profile.json")
|
|
144
|
+
with open(path, "w", encoding="utf-8") as f:
|
|
145
|
+
json.dump(prof, f)
|
|
146
|
+
return path
|
|
147
|
+
|
|
148
|
+
def cli(self, *argv):
|
|
149
|
+
out, err = io.StringIO(), io.StringIO()
|
|
150
|
+
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
|
151
|
+
code = tracker.main(list(argv))
|
|
152
|
+
return code, out.getvalue(), err.getvalue()
|
|
153
|
+
|
|
154
|
+
# ---- profile
|
|
155
|
+
def test_profile_is_found_upward_and_validated(self):
|
|
156
|
+
path = self.profile("github")
|
|
157
|
+
deep = os.path.join(self.tmp, "src", "a")
|
|
158
|
+
os.makedirs(deep)
|
|
159
|
+
self.assertEqual(tracker.find_profile(deep), path)
|
|
160
|
+
with open(path, "w", encoding="utf-8") as f:
|
|
161
|
+
json.dump({"tracker": "trello", "title_pattern": "(x"}, f)
|
|
162
|
+
with self.assertRaises(tracker.TrackerError) as ctx:
|
|
163
|
+
tracker.load_profile(path)
|
|
164
|
+
self.assertIn("tracker must be one of", str(ctx.exception))
|
|
165
|
+
self.assertIn("project is required", str(ctx.exception))
|
|
166
|
+
self.assertIn("not a valid regular expression", str(ctx.exception))
|
|
167
|
+
|
|
168
|
+
def test_credentials_from_dotenv_beside_the_profile_and_never_printed(self):
|
|
169
|
+
path = self.profile("redmine")
|
|
170
|
+
del os.environ["ISSUE_TRACKER_TOKEN"]
|
|
171
|
+
with open(os.path.join(os.path.dirname(path), ".env"), "w", encoding="utf-8") as f:
|
|
172
|
+
f.write("# local only\nISSUE_TRACKER_TOKEN=%s\n" % TOKEN)
|
|
173
|
+
code, out, _ = self.cli("--profile", path, "check")
|
|
174
|
+
self.assertEqual(code, 0)
|
|
175
|
+
self.assertIn("credentials: ok", out)
|
|
176
|
+
self.assertNotIn(TOKEN, out)
|
|
177
|
+
code, out, _ = self.cli("--profile", path, "comment", "101", "--body-file", path)
|
|
178
|
+
self.assertNotIn(TOKEN, out)
|
|
179
|
+
|
|
180
|
+
def test_dotenv_at_the_repository_root_is_found_and_the_nearest_wins(self):
|
|
181
|
+
path = self.profile("redmine") # <tmp>/docs/issue_profile.json
|
|
182
|
+
del os.environ["ISSUE_TRACKER_TOKEN"]
|
|
183
|
+
os.makedirs(os.path.join(self.tmp, ".git"))
|
|
184
|
+
with open(os.path.join(self.tmp, ".env"), "w", encoding="utf-8") as f:
|
|
185
|
+
f.write("ISSUE_TRACKER_TOKEN=root-value\n")
|
|
186
|
+
self.assertEqual(tracker.credentials(tracker.load_profile(path))["token"], "root-value")
|
|
187
|
+
with open(os.path.join(self.tmp, "docs", ".env"), "w", encoding="utf-8") as f:
|
|
188
|
+
f.write("ISSUE_TRACKER_TOKEN=near-value\n")
|
|
189
|
+
self.assertEqual(tracker.credentials(tracker.load_profile(path))["token"], "near-value")
|
|
190
|
+
|
|
191
|
+
def test_missing_credential_is_named(self):
|
|
192
|
+
path = self.profile("jira")
|
|
193
|
+
del os.environ["ISSUE_TRACKER_USER"]
|
|
194
|
+
code, out, _ = self.cli("--profile", path, "check")
|
|
195
|
+
self.assertEqual(code, 2)
|
|
196
|
+
self.assertIn("missing ISSUE_TRACKER_USER", out)
|
|
197
|
+
|
|
198
|
+
# ---- reads
|
|
199
|
+
def test_github_pick_drops_blocked_and_prs_ranks_and_flags_titles(self):
|
|
200
|
+
path = self.profile("github")
|
|
201
|
+
code, out, _ = self.cli("--profile", path, "pick", "--json")
|
|
202
|
+
self.assertEqual(code, 0)
|
|
203
|
+
picked = json.loads(out)
|
|
204
|
+
self.assertEqual([i["id"] for i in picked["candidates"]], ["9", "8", "7"]) # P1 old, P1 newer, P2
|
|
205
|
+
self.assertEqual([i["id"] for i in picked["blocked"]], ["10"])
|
|
206
|
+
self.assertFalse(picked["candidates"][0]["title_ok"])
|
|
207
|
+
self.assertEqual(picked["candidates"][1]["feature"], "ORD")
|
|
208
|
+
self.assertEqual(Stub.calls[0]["query"]["assignee"], ["dev1"])
|
|
209
|
+
self.assertEqual(Stub.calls[0]["headers"]["Authorization"], "Bearer " + TOKEN)
|
|
210
|
+
code, text, _ = self.cli("--profile", path, "pick")
|
|
211
|
+
self.assertIn("? title does not follow the convention", text)
|
|
212
|
+
self.assertIn("ORD (Order management)", text)
|
|
213
|
+
self.assertIn("Nothing was started", text)
|
|
214
|
+
self.assertTrue(all(c["method"] == "GET" for c in Stub.calls))
|
|
215
|
+
|
|
216
|
+
def test_redmine_blocked_relation_and_show(self):
|
|
217
|
+
path = self.profile("redmine")
|
|
218
|
+
picked = json.loads(self.cli("--profile", path, "pick", "--json")[1])
|
|
219
|
+
self.assertEqual([i["id"] for i in picked["candidates"]], ["102"]) # 101 is blocked by 99
|
|
220
|
+
self.assertEqual(Stub.calls[0]["headers"]["X-Redmine-Api-Key"], TOKEN)
|
|
221
|
+
data = json.loads(self.cli("--profile", path, "show", "101", "--json")[1])
|
|
222
|
+
self.assertIn("journals", Stub.calls[-1]["query"]["include"][0])
|
|
223
|
+
self.assertTrue(data["blocked"])
|
|
224
|
+
|
|
225
|
+
def test_jira_show_reads_comments_attachments_and_done_blockers_do_not_block(self):
|
|
226
|
+
path = self.profile("jira")
|
|
227
|
+
data = json.loads(self.cli("--profile", path, "show", "ACME-5", "--json")[1])
|
|
228
|
+
self.assertFalse(data["blocked"])
|
|
229
|
+
self.assertEqual(data["comments"][0]["body"], "Still fails.")
|
|
230
|
+
self.assertEqual(data["attachments"], ["log.txt"])
|
|
231
|
+
self.assertTrue(Stub.calls[0]["headers"]["Authorization"].startswith("Basic "))
|
|
232
|
+
self.cli("--profile", path, "list")
|
|
233
|
+
self.assertIn("currentUser()", Stub.calls[-1]["query"]["jql"][0])
|
|
234
|
+
|
|
235
|
+
# ---- writes
|
|
236
|
+
def test_writes_are_dry_run_unless_applied(self):
|
|
237
|
+
path = self.profile("github")
|
|
238
|
+
body = os.path.join(self.tmp, "c.md")
|
|
239
|
+
with open(body, "w", encoding="utf-8") as f:
|
|
240
|
+
f.write("Fixed in PR #12. Root cause: discount applied twice.")
|
|
241
|
+
code, out, _ = self.cli("--profile", path, "comment", "7", "--body-file", body)
|
|
242
|
+
self.assertEqual(code, 0)
|
|
243
|
+
self.assertIn("POST /repos/acme/shop/issues/7/comments", out)
|
|
244
|
+
self.assertIn("Dry run: nothing was sent", out)
|
|
245
|
+
self.assertEqual(Stub.calls, [])
|
|
246
|
+
self.cli("--profile", path, "comment", "7", "--body-file", body, "--apply")
|
|
247
|
+
self.assertEqual(Stub.calls[-1]["method"], "POST")
|
|
248
|
+
self.assertEqual(Stub.calls[-1]["body"], {"body": "Fixed in PR #12. Root cause: discount applied twice."})
|
|
249
|
+
|
|
250
|
+
def test_transitions_per_tracker(self):
|
|
251
|
+
self.cli("--profile", self.profile("github"), "transition", "7", "--to", "review", "--assign", "qa1", "--apply")
|
|
252
|
+
self.assertEqual([(c["method"], c["path"], c["body"]) for c in Stub.calls],
|
|
253
|
+
[("POST", "/repos/acme/shop/issues/7/labels", {"labels": ["in review"]}),
|
|
254
|
+
("POST", "/repos/acme/shop/issues/7/assignees", {"assignees": ["qa1"]})])
|
|
255
|
+
Stub.calls.clear()
|
|
256
|
+
self.cli("--profile", self.profile("redmine"), "transition", "101", "--to", "resolved", "--apply")
|
|
257
|
+
self.assertEqual(Stub.calls[-1]["body"], {"issue": {"status_id": 3}})
|
|
258
|
+
Stub.calls.clear()
|
|
259
|
+
code, out, _ = self.cli("--profile", self.profile("jira"), "transition", "ACME-5", "--to", "resolved")
|
|
260
|
+
self.assertEqual([c["method"] for c in Stub.calls], ["GET"]) # reads transitions, sends nothing
|
|
261
|
+
self.assertIn('"id": "31"', out)
|
|
262
|
+
code, _, err = self.cli("--profile", self.profile("jira"), "transition", "ACME-5", "--to", "nope")
|
|
263
|
+
self.assertEqual(code, 1)
|
|
264
|
+
self.assertIn("not in the profile's statuses", err)
|
|
265
|
+
|
|
266
|
+
# ---- network hygiene
|
|
267
|
+
def test_slow_tracker_times_out_instead_of_hanging(self):
|
|
268
|
+
path = self.profile("redmine")
|
|
269
|
+
Stub.delay = 2.0
|
|
270
|
+
start = time.time()
|
|
271
|
+
code, _, err = self.cli("--profile", path, "--timeout", "0.3", "list")
|
|
272
|
+
self.assertEqual(code, 1)
|
|
273
|
+
self.assertLess(time.time() - start, 1.8)
|
|
274
|
+
self.assertIn("timeout 0.3s", err)
|
|
275
|
+
|
|
276
|
+
def test_child_processes_never_prompt(self):
|
|
277
|
+
self.cli("--profile", self.profile("github"), "check")
|
|
278
|
+
self.assertEqual(os.environ.get("GIT_TERMINAL_PROMPT"), "0")
|
|
279
|
+
self.assertEqual(os.environ.get("GH_PROMPT_DISABLED"), "1")
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
if __name__ == "__main__":
|
|
283
|
+
unittest.main()
|