Skip to content

Commit 312959d

Browse files
committed
Fix tests to match v2-to-v3 API switch and plain mode ANSI stripping
Made-with: Cursor
1 parent 7c5814c commit 312959d

4 files changed

Lines changed: 15 additions & 24 deletions

File tree

internal/view/issue_test.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,7 @@ func TestIssueDetailsRenderInPlainView(t *testing.T) {
7676
}
7777

7878
expected := "🐞 Bug ✅ Done ⌛ Sun, 13 Dec 20 👷 Person A 🔑️ TEST-1 💭 0 comments \U0001F9F5 0 linked\n# This is a test\n⏱️ Sun, 13 Dec 20 🔎 Person Z 🚀 High 📦 BE, FE 🏷️ None 👀 You + 3 watchers\n\n------------------------ Description ------------------------\n\nTest description\n\n\n"
79-
if xterm256() {
80-
expected += "\x1b[38;5;242mView this issue on Jira: https://test.local/browse/TEST-1\x1b[m"
81-
} else {
82-
expected += "\x1b[0;90mView this issue on Jira: https://test.local/browse/TEST-1\x1b[0m"
83-
}
79+
expected += "View this issue on Jira: https://test.local/browse/TEST-1"
8480
actual := issue.String()
8581

8682
assert.NoError(t, issue.renderPlain(&b))
@@ -226,13 +222,8 @@ func TestIssueDetailsWithV2Description(t *testing.T) {
226222
assert.NoError(t, issue.renderPlain(&b))
227223

228224
expected := "🐞 Bug ✅ Done ⌛ Sun, 13 Dec 20 👷 Person A 🔑️ TEST-1 💭 3 comments \U0001F9F5 2 linked\n# This is a test\n⏱️ Sun, 13 Dec 20 🔎 Person Z 🚀 High 📦 BE, FE 🏷️ None 👀 0 watchers\n\n------------------------ Description ------------------------\n\n# Title\n## Subtitle\nThis is a **bold** and _italic_ text with [a link](https://ankit.pl) in between.\n\n\n------------------------ 2 Subtasks ------------------------\n\n\n SUBTASKS\n\n TEST-2 Subtask 1 • High • TO DO\n TEST-3 Subtask 2 • Normal • Done \n\n\n\n------------------------ Linked Issues ------------------------\n\n\n BLOCKS\n\n TEST-2 Something is broken • Bug • High • TO DO\n\n RELATES TO\n\n TEST-3 Everything is on fire • Bug • Urgent • Done \n\n\n\n------------------------ 3 Comments ------------------------\n\n\n Person C • Wed, 24 Nov 21 • Latest comment\n\nTest comment C\n\n\n\n Person B • Tue, 23 Nov 21\n\nTest comment B\n\n"
229-
if xterm256() {
230-
expected += "\x1b[38;5;242mUse --comments <limit> with `jira issue view` to load more comments\x1b[m\n\n"
231-
expected += "\x1b[38;5;242mView this issue on Jira: https://test.local/browse/TEST-1\x1b[m"
232-
} else {
233-
expected += "\x1b[0;90mUse --comments <limit> with `jira issue view` to load more comments\x1b[0m\n\n"
234-
expected += "\x1b[0;90mView this issue on Jira: https://test.local/browse/TEST-1\x1b[0m"
235-
}
225+
expected += "Use --comments <limit> with `jira issue view` to load more comments\n\n"
226+
expected += "View this issue on Jira: https://test.local/browse/TEST-1"
236227
actual := issue.String()
237228

238229
assert.Equal(t, tui.TextData(expected), tui.TextData(actual))

pkg/jira/delete_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ func TestDeleteIssue(t *testing.T) {
1414

1515
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1616
if unexpectedStatusCode {
17-
assert.Equal(t, "/rest/api/2/issue/BAD", r.URL.RequestURI())
17+
assert.Equal(t, "/rest/api/3/issue/BAD", r.URL.RequestURI())
1818
w.WriteHeader(400)
1919
} else {
20-
assert.Equal(t, "/rest/api/2/issue/TEST-1", r.URL.RequestURI())
20+
assert.Equal(t, "/rest/api/3/issue/TEST-1", r.URL.RequestURI())
2121
w.WriteHeader(204)
2222
}
2323
}))
@@ -36,7 +36,7 @@ func TestDeleteIssue(t *testing.T) {
3636

3737
func TestDeleteIssueWithCascade(t *testing.T) {
3838
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
39-
assert.Equal(t, "/rest/api/2/issue/TEST-1?deleteSubtasks=true", r.URL.RequestURI())
39+
assert.Equal(t, "/rest/api/3/issue/TEST-1?deleteSubtasks=true", r.URL.RequestURI())
4040
w.WriteHeader(204)
4141
}))
4242
defer server.Close()

pkg/jira/issue_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ func TestGetIssueLinkTypes(t *testing.T) {
392392
var unexpectedStatusCode bool
393393

394394
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
395-
assert.Equal(t, "/rest/api/2/issueLinkType", r.URL.Path)
395+
assert.Equal(t, "/rest/api/3/issueLinkType", r.URL.Path)
396396

397397
if unexpectedStatusCode {
398398
w.WriteHeader(400)
@@ -442,7 +442,7 @@ func TestLinkIssue(t *testing.T) {
442442
var unexpectedStatusCode bool
443443

444444
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
445-
assert.Equal(t, "/rest/api/2/issueLink", r.URL.Path)
445+
assert.Equal(t, "/rest/api/3/issueLink", r.URL.Path)
446446
assert.Equal(t, "application/json", r.Header.Get("Accept"))
447447
assert.Equal(t, "application/json", r.Header.Get("Content-Type"))
448448

@@ -469,7 +469,7 @@ func TestUnlinkIssue(t *testing.T) {
469469
var unexpectedStatusCode bool
470470

471471
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
472-
assert.Equal(t, "/rest/api/2/issueLink/123", r.URL.Path)
472+
assert.Equal(t, "/rest/api/3/issueLink/123", r.URL.Path)
473473
assert.Equal(t, http.MethodDelete, r.Method)
474474
assert.Equal(t, "application/json", r.Header.Get("Accept"))
475475
assert.Equal(t, "application/json", r.Header.Get("Content-Type"))
@@ -524,14 +524,14 @@ func TestAddIssueComment(t *testing.T) {
524524

525525
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
526526
assert.Equal(t, "POST", r.Method)
527-
assert.Equal(t, "/rest/api/2/issue/TEST-1/comment", r.URL.Path)
527+
assert.Equal(t, "/rest/api/3/issue/TEST-1/comment", r.URL.Path)
528528
assert.Equal(t, "application/json", r.Header.Get("Accept"))
529529
assert.Equal(t, "application/json", r.Header.Get("Content-Type"))
530530

531531
actualBody := new(strings.Builder)
532532
_, _ = io.Copy(actualBody, r.Body)
533533

534-
expectedBody := `{"body":"comment","properties":[{"key":"sd.public.comment","value":{"internal":false}}]}`
534+
expectedBody := `{"body":{"version":1,"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"comment"}]}]},"properties":[{"key":"sd.public.comment","value":{"internal":false}}]}`
535535

536536
assert.Equal(t, expectedBody, actualBody.String())
537537

@@ -559,7 +559,7 @@ func TestAddIssueWorklog(t *testing.T) {
559559

560560
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
561561
assert.Equal(t, "POST", r.Method)
562-
assert.Equal(t, "/rest/api/2/issue/TEST-1/worklog", r.URL.Path)
562+
assert.Equal(t, "/rest/api/3/issue/TEST-1/worklog", r.URL.Path)
563563
assert.Equal(t, "application/json", r.Header.Get("Accept"))
564564
assert.Equal(t, "application/json", r.Header.Get("Content-Type"))
565565

@@ -612,7 +612,7 @@ func TestGetField(t *testing.T) {
612612
var unexpectedStatusCode bool
613613

614614
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
615-
assert.Equal(t, "/rest/api/2/field", r.URL.Path)
615+
assert.Equal(t, "/rest/api/3/field", r.URL.Path)
616616

617617
if unexpectedStatusCode {
618618
w.WriteHeader(400)
@@ -684,7 +684,7 @@ func TestRemoteLinkIssue(t *testing.T) {
684684
var unexpectedStatusCode bool
685685

686686
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
687-
assert.Equal(t, "/rest/api/2/issue/TEST-1/remotelink", r.URL.Path)
687+
assert.Equal(t, "/rest/api/3/issue/TEST-1/remotelink", r.URL.Path)
688688
assert.Equal(t, http.MethodPost, r.Method)
689689
assert.Equal(t, "application/json", r.Header.Get("Accept"))
690690
assert.Equal(t, "application/json", r.Header.Get("Content-Type"))

pkg/jira/transition_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func TestTransition(t *testing.T) {
7575
var unexpectedStatusCode bool
7676

7777
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
78-
assert.Equal(t, "/rest/api/2/issue/TEST/transitions", r.URL.Path)
78+
assert.Equal(t, "/rest/api/3/issue/TEST/transitions", r.URL.Path)
7979
assert.Equal(t, "POST", r.Method)
8080
assert.Equal(t, "application/json", r.Header.Get("Accept"))
8181
assert.Equal(t, "application/json", r.Header.Get("Content-Type"))

0 commit comments

Comments
 (0)