aboutsummaryrefslogtreecommitdiff
path: root/tests/testutil-fixtures.el
blob: 5c55c7bb4e2eed89170a5f888b3dd167579642d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
;;; testutil-fixtures.el --- representative Linear API response fixtures -*- lexical-binding: t; -*-

;; Copyright (C) 2026 Craig Jennings

;; Author: Craig Jennings <c@cjennings.net>

;;; Commentary:

;; Small, representative response fixtures for the issue-query and
;; representation build.  They cover an assignedIssues page, a top-level
;; issues(filter:) page, custom views, a custom view's issues, an issue with
;; comments, and an issue with null/missing optional fields.
;;
;; Shapes mirror what `json-read' returns from the live API: symbol-keyed
;; alists, `t' / `:json-false' for JSON booleans, and a missing key (rather
;; than an explicit value) for absent optional fields.  Not a test file (no
;; `test-' prefix), so the suite runner ignores it; tests `require' it.
;;
;; These let normalization, query, and render tests run against stable
;; inputs without a live workspace.  Captured from the documented schema
;; shapes; replace with real recorded responses once a live key is wired in.

;;; Code:

(defun testutil-linear-fixture-issue-full ()
  "A fully-populated issue node, every optional field present."
  '((id . "uuid-1")
    (identifier . "ENG-42")
    (title . "Fix the thing")
    (description . "Line one\nLine two")
    (priority . 2)
    (updatedAt . "2026-05-20T12:00:00.000Z")
    (state . ((id . "state-1") (name . "In Progress") (type . "started") (color . "#fff")))
    (assignee . ((id . "user-1") (name . "Craig") (email . "c@example.com")))
    (team . ((id . "team-1") (key . "ENG") (name . "Engineering")))
    (project . ((id . "proj-1") (name . "Platform")))
    (cycle . ((id . "cycle-1") (number . 12) (name . "Cycle 12")))
    (labels . ((nodes . (((id . "lbl-1") (name . "bug"))
                         ((id . "lbl-2") (name . "backend"))))))))

(defun testutil-linear-fixture-issue-null-fields ()
  "An issue with optional fields absent or null (project/labels/assignee/cycle).
Description is JSON null; labels is an empty connection."
  '((id . "uuid-2")
    (identifier . "ENG-7")
    (title . "Bare issue")
    (description)
    (priority . 0)
    (updatedAt . "2026-05-19T08:30:00.000Z")
    (state . ((id . "state-2") (name . "Todo") (type . "unstarted")))
    (assignee)
    (team . ((id . "team-1") (key . "ENG") (name . "Engineering")))
    (project)
    (cycle)
    (labels . ((nodes . ())))))

(defun testutil-linear-fixture-assigned-issues-page ()
  "A viewer.assignedIssues page: two issues, no next page."
  `((data (viewer (assignedIssues
                   (nodes . (,(testutil-linear-fixture-issue-full)
                             ,(testutil-linear-fixture-issue-null-fields)))
                   (pageInfo (hasNextPage . :json-false) (endCursor . "cursor-1")))))))

(defun testutil-linear-fixture-issues-filter-page ()
  "A top-level issues(filter:) page: one issue, has a next page."
  `((data (issues
           (nodes . (,(testutil-linear-fixture-issue-full)))
           (pageInfo (hasNextPage . t) (endCursor . "cursor-2"))))))

(defun testutil-linear-fixture-custom-views ()
  "A customViews connection: one shared workspace view, one personal team view."
  '((data (customViews
           (nodes . (((id . "cv-1") (name . "My open work") (description . "Everything open assigned to me")
                      (shared . :json-false) (team) (icon . "Inbox") (color . "#aabbcc")
                      (owner . ((id . "user-1") (name . "Craig"))))
                     ((id . "cv-2") (name . "Eng in progress") (description)
                      (shared . t) (team . ((id . "team-1") (key . "ENG") (name . "Engineering")))
                      (icon) (color)
                      (owner . ((id . "user-1") (name . "Craig"))))))
           (pageInfo (hasNextPage . :json-false) (endCursor . "cv-cursor"))))))

(defun testutil-linear-fixture-custom-view-issues ()
  "A customView(id).issues page: the view's filter resolved server-side."
  `((data (customView
           (id . "cv-1")
           (name . "My open work")
           (issues
            (nodes . (,(testutil-linear-fixture-issue-full)))
            (pageInfo (hasNextPage . :json-false) (endCursor . "cvi-cursor")))))))

(defun testutil-linear-fixture-issue-with-comments ()
  "An issue carrying a comments connection, oldest first."
  `((id . "uuid-1")
    (identifier . "ENG-42")
    (title . "Fix the thing")
    (description . "Body text")
    (comments (nodes . (((id . "cm-1") (body . "First comment")
                         (createdAt . "2026-05-18T09:00:00.000Z")
                         (user . ((id . "user-2") (name . "Alice"))))
                        ((id . "cm-2") (body . "Second comment, **bold**")
                         (createdAt . "2026-05-19T10:30:00.000Z")
                         (user . ((id . "user-1") (name . "Craig")))))))))

(provide 'testutil-fixtures)
;;; testutil-fixtures.el ends here