@jant/core 0.3.23 → 0.3.25
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/dist/app.js +50 -26
- package/dist/db/schema.js +72 -47
- package/dist/i18n/locales/en.js +1 -1
- package/dist/i18n/locales/zh-Hans.js +1 -1
- package/dist/i18n/locales/zh-Hant.js +1 -1
- package/dist/index.js +5 -11
- package/dist/lib/constants.js +2 -4
- package/dist/lib/excerpt.js +76 -0
- package/dist/lib/feed.js +18 -7
- package/dist/lib/nav-reorder.js +1 -1
- package/dist/lib/navigation.js +30 -6
- package/dist/lib/pagination.js +44 -0
- package/dist/lib/render.js +7 -11
- package/dist/lib/schemas.js +80 -38
- package/dist/lib/theme.js +4 -4
- package/dist/lib/time.js +56 -1
- package/dist/lib/timeline.js +95 -0
- package/dist/lib/view.js +61 -72
- package/dist/routes/api/collections.js +124 -0
- package/dist/routes/api/nav-items.js +104 -0
- package/dist/routes/api/pages.js +91 -0
- package/dist/routes/api/posts.js +27 -33
- package/dist/routes/api/search.js +4 -5
- package/dist/routes/api/settings.js +68 -0
- package/dist/routes/api/upload.js +13 -13
- package/dist/routes/compose.js +48 -0
- package/dist/routes/dash/collections.js +24 -42
- package/dist/routes/dash/index.js +3 -3
- package/dist/routes/dash/media.js +2 -2
- package/dist/routes/dash/pages.js +440 -106
- package/dist/routes/dash/posts.js +27 -37
- package/dist/routes/dash/redirects.js +2 -2
- package/dist/routes/dash/settings.js +79 -5
- package/dist/routes/feed/rss.js +4 -6
- package/dist/routes/feed/sitemap.js +11 -8
- package/dist/routes/pages/archive.js +13 -15
- package/dist/routes/pages/collection.js +12 -9
- package/dist/routes/pages/collections.js +28 -0
- package/dist/routes/pages/featured.js +32 -0
- package/dist/routes/pages/home.js +19 -68
- package/dist/routes/pages/page.js +57 -29
- package/dist/routes/pages/post.js +7 -17
- package/dist/routes/pages/search.js +5 -9
- package/dist/services/collection.js +52 -64
- package/dist/services/index.js +5 -3
- package/dist/services/navigation.js +29 -53
- package/dist/services/page.js +84 -0
- package/dist/services/post.js +102 -69
- package/dist/services/search.js +24 -18
- package/dist/types.js +24 -40
- package/dist/ui/compose/ComposeDialog.js +452 -0
- package/dist/ui/compose/ComposePrompt.js +55 -0
- package/dist/{theme/components/TypeBadge.js → ui/dash/FormatBadge.js} +3 -15
- package/dist/{theme/components → ui/dash}/PageForm.js +15 -15
- package/dist/{theme/components → ui/dash}/PostForm.js +117 -137
- package/dist/{theme/components → ui/dash}/PostList.js +18 -13
- package/dist/ui/dash/StatusBadge.js +46 -0
- package/dist/{theme/components → ui/dash}/index.js +3 -6
- package/dist/ui/feed/LinkCard.js +72 -0
- package/dist/ui/feed/NoteCard.js +58 -0
- package/dist/{themes/minimal/timeline → ui/feed}/QuoteCard.js +29 -14
- package/dist/{themes/minimal/timeline → ui/feed}/ThreadPreview.js +20 -18
- package/dist/ui/feed/TimelineFeed.js +41 -0
- package/dist/ui/feed/TimelineItem.js +27 -0
- package/dist/{theme → ui}/layouts/BaseLayout.js +10 -0
- package/dist/{theme → ui}/layouts/DashLayout.js +0 -8
- package/dist/ui/layouts/SiteLayout.js +141 -0
- package/dist/{themes/minimal → ui}/pages/ArchivePage.js +37 -50
- package/dist/ui/pages/CollectionPage.js +70 -0
- package/dist/ui/pages/CollectionsPage.js +76 -0
- package/dist/ui/pages/FeaturedPage.js +24 -0
- package/dist/ui/pages/HomePage.js +24 -0
- package/dist/{themes/minimal → ui}/pages/PostPage.js +20 -12
- package/dist/{themes/minimal → ui}/pages/SearchPage.js +19 -18
- package/dist/{themes/minimal → ui}/pages/SinglePage.js +5 -4
- package/dist/ui/shared/MediaGallery.js +35 -0
- package/dist/{theme/components → ui/shared}/Pagination.js +41 -2
- package/dist/{theme/components → ui/shared}/ThreadView.js +3 -3
- package/dist/ui/shared/index.js +5 -0
- package/package.json +2 -9
- package/src/__tests__/helpers/app.ts +4 -0
- package/src/__tests__/helpers/db.ts +53 -73
- package/src/app.tsx +56 -28
- package/src/db/migrations/0005_v2_schema_migration.sql +268 -0
- package/src/db/migrations/0006_rename_slug_to_path.sql +5 -0
- package/src/db/migrations/meta/_journal.json +14 -0
- package/src/db/schema.ts +63 -46
- package/src/i18n/locales/en.po +443 -240
- package/src/i18n/locales/en.ts +1 -1
- package/src/i18n/locales/zh-Hans.po +443 -240
- package/src/i18n/locales/zh-Hans.ts +1 -1
- package/src/i18n/locales/zh-Hant.po +443 -240
- package/src/i18n/locales/zh-Hant.ts +1 -1
- package/src/index.ts +29 -42
- package/src/lib/__tests__/excerpt.test.ts +125 -0
- package/src/lib/__tests__/schemas.test.ts +201 -99
- package/src/lib/__tests__/time.test.ts +62 -0
- package/src/{routes/api → lib}/__tests__/timeline.test.ts +81 -75
- package/src/lib/__tests__/view.test.ts +204 -50
- package/src/lib/constants.ts +2 -4
- package/src/lib/excerpt.ts +87 -0
- package/src/lib/feed.ts +22 -7
- package/src/lib/nav-reorder.ts +1 -1
- package/src/lib/navigation.ts +45 -8
- package/src/lib/pagination.ts +50 -0
- package/src/lib/render.tsx +7 -14
- package/src/lib/schemas.ts +119 -51
- package/src/lib/theme.ts +5 -5
- package/src/lib/time.ts +64 -0
- package/src/lib/timeline.ts +141 -0
- package/src/lib/view.ts +80 -82
- package/src/preset.css +46 -0
- package/src/routes/__tests__/compose.test.ts +199 -0
- package/src/routes/api/__tests__/collections.test.ts +249 -0
- package/src/routes/api/__tests__/nav-items.test.ts +222 -0
- package/src/routes/api/__tests__/pages.test.ts +218 -0
- package/src/routes/api/__tests__/posts.test.ts +50 -108
- package/src/routes/api/__tests__/search.test.ts +2 -3
- package/src/routes/api/__tests__/settings.test.ts +132 -0
- package/src/routes/api/collections.ts +143 -0
- package/src/routes/api/nav-items.ts +115 -0
- package/src/routes/api/pages.ts +101 -0
- package/src/routes/api/posts.ts +28 -28
- package/src/routes/api/search.ts +3 -3
- package/src/routes/api/settings.ts +91 -0
- package/src/routes/api/upload.ts +16 -6
- package/src/routes/compose.ts +63 -0
- package/src/routes/dash/__tests__/pages.test.ts +225 -0
- package/src/routes/dash/collections.tsx +20 -42
- package/src/routes/dash/index.tsx +3 -3
- package/src/routes/dash/media.tsx +2 -2
- package/src/routes/dash/pages.tsx +480 -122
- package/src/routes/dash/posts.tsx +42 -54
- package/src/routes/dash/redirects.tsx +2 -2
- package/src/routes/dash/settings.tsx +83 -5
- package/src/routes/feed/rss.ts +4 -3
- package/src/routes/feed/sitemap.ts +15 -5
- package/src/routes/pages/__tests__/collections.test.ts +94 -0
- package/src/routes/pages/__tests__/featured.test.ts +94 -0
- package/src/routes/pages/archive.tsx +15 -15
- package/src/routes/pages/collection.tsx +16 -9
- package/src/routes/pages/collections.tsx +36 -0
- package/src/routes/pages/featured.tsx +38 -0
- package/src/routes/pages/home.tsx +21 -92
- package/src/routes/pages/page.tsx +62 -27
- package/src/routes/pages/post.tsx +6 -18
- package/src/routes/pages/search.tsx +3 -7
- package/src/services/__tests__/collection.test.ts +257 -158
- package/src/services/__tests__/media.test.ts +18 -18
- package/src/services/__tests__/navigation.test.ts +161 -87
- package/src/services/__tests__/page.test.ts +106 -0
- package/src/services/__tests__/post-timeline.test.ts +92 -88
- package/src/services/__tests__/post.test.ts +432 -197
- package/src/services/__tests__/search.test.ts +19 -25
- package/src/services/collection.ts +71 -113
- package/src/services/index.ts +9 -8
- package/src/services/navigation.ts +38 -71
- package/src/services/page.ts +136 -0
- package/src/services/post.ts +141 -101
- package/src/services/search.ts +38 -27
- package/src/styles/tokens.css +47 -0
- package/src/styles/ui.css +491 -0
- package/src/types.ts +212 -198
- package/src/ui/compose/ComposeDialog.tsx +395 -0
- package/src/ui/compose/ComposePrompt.tsx +55 -0
- package/src/ui/dash/FormatBadge.tsx +28 -0
- package/src/{theme/components → ui/dash}/PageForm.tsx +21 -21
- package/src/{theme/components → ui/dash}/PostForm.tsx +110 -131
- package/src/ui/dash/PostList.tsx +101 -0
- package/src/ui/dash/StatusBadge.tsx +61 -0
- package/src/ui/dash/index.ts +10 -0
- package/src/ui/feed/LinkCard.tsx +72 -0
- package/src/ui/feed/NoteCard.tsx +63 -0
- package/src/ui/feed/QuoteCard.tsx +68 -0
- package/src/ui/feed/ThreadPreview.tsx +48 -0
- package/src/ui/feed/TimelineFeed.tsx +49 -0
- package/src/ui/feed/TimelineItem.tsx +45 -0
- package/src/{theme → ui}/layouts/BaseLayout.tsx +11 -1
- package/src/{theme → ui}/layouts/DashLayout.tsx +0 -10
- package/src/ui/layouts/SiteLayout.tsx +150 -0
- package/src/ui/pages/ArchivePage.tsx +162 -0
- package/src/ui/pages/CollectionPage.tsx +70 -0
- package/src/ui/pages/CollectionsPage.tsx +73 -0
- package/src/ui/pages/FeaturedPage.tsx +31 -0
- package/src/ui/pages/HomePage.tsx +37 -0
- package/src/ui/pages/PostPage.tsx +56 -0
- package/src/{themes/minimal → ui}/pages/SearchPage.tsx +24 -20
- package/src/{themes/minimal → ui}/pages/SinglePage.tsx +5 -5
- package/src/ui/shared/MediaGallery.tsx +59 -0
- package/src/{theme/components → ui/shared}/Pagination.tsx +67 -4
- package/src/{theme/components → ui/shared}/ThreadView.tsx +6 -3
- package/src/ui/shared/__tests__/pagination.test.ts +46 -0
- package/src/ui/shared/index.ts +12 -0
- package/bin/jant.js +0 -185
- package/dist/lib/theme-components.js +0 -49
- package/dist/routes/api/timeline.js +0 -120
- package/dist/routes/dash/navigation.js +0 -288
- package/dist/theme/components/MediaGallery.js +0 -107
- package/dist/theme/components/VisibilityBadge.js +0 -37
- package/dist/theme/index.js +0 -18
- package/dist/theme/layouts/index.js +0 -2
- package/dist/themes/minimal/MinimalSiteLayout.js +0 -83
- package/dist/themes/minimal/index.js +0 -65
- package/dist/themes/minimal/pages/CollectionPage.js +0 -65
- package/dist/themes/minimal/pages/HomePage.js +0 -25
- package/dist/themes/minimal/timeline/ArticleCard.js +0 -36
- package/dist/themes/minimal/timeline/ImageCard.js +0 -67
- package/dist/themes/minimal/timeline/LinkCard.js +0 -47
- package/dist/themes/minimal/timeline/NoteCard.js +0 -34
- package/dist/themes/minimal/timeline/TimelineFeed.js +0 -48
- package/dist/themes/minimal/timeline/TimelineItem.js +0 -44
- package/src/lib/__tests__/theme-components.test.ts +0 -126
- package/src/lib/theme-components.ts +0 -68
- package/src/routes/api/timeline.tsx +0 -159
- package/src/routes/dash/navigation.tsx +0 -316
- package/src/theme/components/MediaGallery.tsx +0 -128
- package/src/theme/components/PostList.tsx +0 -92
- package/src/theme/components/TypeBadge.tsx +0 -37
- package/src/theme/components/VisibilityBadge.tsx +0 -45
- package/src/theme/components/index.ts +0 -23
- package/src/theme/index.ts +0 -22
- package/src/theme/layouts/index.ts +0 -7
- package/src/themes/minimal/MinimalSiteLayout.tsx +0 -100
- package/src/themes/minimal/index.ts +0 -83
- package/src/themes/minimal/pages/ArchivePage.tsx +0 -157
- package/src/themes/minimal/pages/CollectionPage.tsx +0 -60
- package/src/themes/minimal/pages/HomePage.tsx +0 -41
- package/src/themes/minimal/pages/PostPage.tsx +0 -43
- package/src/themes/minimal/timeline/ArticleCard.tsx +0 -37
- package/src/themes/minimal/timeline/ImageCard.tsx +0 -63
- package/src/themes/minimal/timeline/LinkCard.tsx +0 -48
- package/src/themes/minimal/timeline/NoteCard.tsx +0 -35
- package/src/themes/minimal/timeline/QuoteCard.tsx +0 -49
- package/src/themes/minimal/timeline/ThreadPreview.tsx +0 -47
- package/src/themes/minimal/timeline/TimelineFeed.tsx +0 -57
- package/src/themes/minimal/timeline/TimelineItem.tsx +0 -75
- /package/dist/{theme → ui}/color-themes.js +0 -0
- /package/dist/{theme/components → ui/dash}/ActionButtons.js +0 -0
- /package/dist/{theme/components → ui/dash}/CrudPageHeader.js +0 -0
- /package/dist/{theme/components → ui/dash}/DangerZone.js +0 -0
- /package/dist/{theme/components → ui/dash}/ListItemRow.js +0 -0
- /package/dist/{theme/components → ui/shared}/EmptyState.js +0 -0
- /package/src/{theme → ui}/color-themes.ts +0 -0
- /package/src/{theme/components → ui/dash}/ActionButtons.tsx +0 -0
- /package/src/{theme/components → ui/dash}/CrudPageHeader.tsx +0 -0
- /package/src/{theme/components → ui/dash}/DangerZone.tsx +0 -0
- /package/src/{theme/components → ui/dash}/ListItemRow.tsx +0 -0
- /package/src/{theme/components → ui/shared}/EmptyState.tsx +0 -0
|
@@ -13,76 +13,50 @@ describe("PostService - Timeline features", () => {
|
|
|
13
13
|
postService = createPostService(db);
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
describe("
|
|
17
|
-
it("
|
|
18
|
-
await postService.create({
|
|
19
|
-
await postService.create({ type: "page", content: "a page" });
|
|
16
|
+
describe("format filter", () => {
|
|
17
|
+
it("filters by format", async () => {
|
|
18
|
+
await postService.create({ format: "note", body: "a note" });
|
|
20
19
|
await postService.create({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
format: "link",
|
|
21
|
+
body: "a link",
|
|
22
|
+
url: "https://example.com",
|
|
24
23
|
});
|
|
25
|
-
|
|
26
|
-
const posts = await postService.list({ excludeTypes: ["page"] });
|
|
27
|
-
expect(posts).toHaveLength(2);
|
|
28
|
-
expect(posts.every((p) => p.type !== "page")).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("excludes multiple types", async () => {
|
|
32
|
-
await postService.create({ type: "note", content: "a note" });
|
|
33
|
-
await postService.create({ type: "page", content: "a page" });
|
|
34
24
|
await postService.create({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
await postService.create({
|
|
40
|
-
type: "link",
|
|
41
|
-
content: "a link",
|
|
42
|
-
sourceUrl: "https://example.com",
|
|
25
|
+
format: "quote",
|
|
26
|
+
body: "a quote",
|
|
27
|
+
quoteText: "something wise",
|
|
43
28
|
});
|
|
44
29
|
|
|
45
|
-
const posts = await postService.list({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
expect(posts).toHaveLength(2);
|
|
49
|
-
expect(posts.every((p) => p.type !== "page" && p.type !== "link")).toBe(
|
|
50
|
-
true,
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("returns all posts when excludeTypes is empty", async () => {
|
|
55
|
-
await postService.create({ type: "note", content: "a note" });
|
|
56
|
-
await postService.create({ type: "page", content: "a page" });
|
|
57
|
-
|
|
58
|
-
const posts = await postService.list({ excludeTypes: [] });
|
|
59
|
-
expect(posts).toHaveLength(2);
|
|
30
|
+
const posts = await postService.list({ format: "note" });
|
|
31
|
+
expect(posts).toHaveLength(1);
|
|
32
|
+
expect(posts[0]?.format).toBe("note");
|
|
60
33
|
});
|
|
61
34
|
|
|
62
|
-
it("
|
|
35
|
+
it("combines format and status filters", async () => {
|
|
63
36
|
await postService.create({
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
37
|
+
format: "note",
|
|
38
|
+
body: "published note",
|
|
39
|
+
status: "published",
|
|
67
40
|
});
|
|
68
41
|
await postService.create({
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
42
|
+
format: "note",
|
|
43
|
+
body: "draft note",
|
|
44
|
+
status: "draft",
|
|
72
45
|
});
|
|
73
46
|
await postService.create({
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
47
|
+
format: "link",
|
|
48
|
+
body: "published link",
|
|
49
|
+
status: "published",
|
|
50
|
+
url: "https://example.com",
|
|
77
51
|
});
|
|
78
52
|
|
|
79
53
|
const posts = await postService.list({
|
|
80
|
-
|
|
81
|
-
|
|
54
|
+
format: "note",
|
|
55
|
+
status: "published",
|
|
82
56
|
});
|
|
83
57
|
expect(posts).toHaveLength(1);
|
|
84
|
-
expect(posts[0]?.
|
|
85
|
-
expect(posts[0]?.
|
|
58
|
+
expect(posts[0]?.format).toBe("note");
|
|
59
|
+
expect(posts[0]?.status).toBe("published");
|
|
86
60
|
});
|
|
87
61
|
});
|
|
88
62
|
|
|
@@ -94,17 +68,17 @@ describe("PostService - Timeline features", () => {
|
|
|
94
68
|
|
|
95
69
|
it("returns preview replies for a thread root", async () => {
|
|
96
70
|
const root = await postService.create({
|
|
97
|
-
|
|
98
|
-
|
|
71
|
+
format: "note",
|
|
72
|
+
body: "root",
|
|
99
73
|
});
|
|
100
74
|
await postService.create({
|
|
101
|
-
|
|
102
|
-
|
|
75
|
+
format: "note",
|
|
76
|
+
body: "reply 1",
|
|
103
77
|
replyToId: root.id,
|
|
104
78
|
});
|
|
105
79
|
await postService.create({
|
|
106
|
-
|
|
107
|
-
|
|
80
|
+
format: "note",
|
|
81
|
+
body: "reply 2",
|
|
108
82
|
replyToId: root.id,
|
|
109
83
|
});
|
|
110
84
|
|
|
@@ -112,19 +86,19 @@ describe("PostService - Timeline features", () => {
|
|
|
112
86
|
const replies = previews.get(root.id);
|
|
113
87
|
expect(replies).toBeDefined();
|
|
114
88
|
expect(replies).toHaveLength(2);
|
|
115
|
-
expect(replies?.[0]?.
|
|
116
|
-
expect(replies?.[1]?.
|
|
89
|
+
expect(replies?.[0]?.body).toBe("reply 1");
|
|
90
|
+
expect(replies?.[1]?.body).toBe("reply 2");
|
|
117
91
|
});
|
|
118
92
|
|
|
119
93
|
it("limits preview replies to previewCount", async () => {
|
|
120
94
|
const root = await postService.create({
|
|
121
|
-
|
|
122
|
-
|
|
95
|
+
format: "note",
|
|
96
|
+
body: "root",
|
|
123
97
|
});
|
|
124
98
|
for (let i = 0; i < 5; i++) {
|
|
125
99
|
await postService.create({
|
|
126
|
-
|
|
127
|
-
|
|
100
|
+
format: "note",
|
|
101
|
+
body: `reply ${i}`,
|
|
128
102
|
replyToId: root.id,
|
|
129
103
|
});
|
|
130
104
|
}
|
|
@@ -132,19 +106,19 @@ describe("PostService - Timeline features", () => {
|
|
|
132
106
|
const previews = await postService.getThreadPreviews([root.id], 2);
|
|
133
107
|
const replies = previews.get(root.id);
|
|
134
108
|
expect(replies).toHaveLength(2);
|
|
135
|
-
expect(replies?.[0]?.
|
|
136
|
-
expect(replies?.[1]?.
|
|
109
|
+
expect(replies?.[0]?.body).toBe("reply 0");
|
|
110
|
+
expect(replies?.[1]?.body).toBe("reply 1");
|
|
137
111
|
});
|
|
138
112
|
|
|
139
113
|
it("defaults to 3 preview replies", async () => {
|
|
140
114
|
const root = await postService.create({
|
|
141
|
-
|
|
142
|
-
|
|
115
|
+
format: "note",
|
|
116
|
+
body: "root",
|
|
143
117
|
});
|
|
144
118
|
for (let i = 0; i < 5; i++) {
|
|
145
119
|
await postService.create({
|
|
146
|
-
|
|
147
|
-
|
|
120
|
+
format: "note",
|
|
121
|
+
body: `reply ${i}`,
|
|
148
122
|
replyToId: root.id,
|
|
149
123
|
});
|
|
150
124
|
}
|
|
@@ -156,21 +130,21 @@ describe("PostService - Timeline features", () => {
|
|
|
156
130
|
|
|
157
131
|
it("handles multiple thread roots", async () => {
|
|
158
132
|
const root1 = await postService.create({
|
|
159
|
-
|
|
160
|
-
|
|
133
|
+
format: "note",
|
|
134
|
+
body: "root 1",
|
|
161
135
|
});
|
|
162
136
|
const root2 = await postService.create({
|
|
163
|
-
|
|
164
|
-
|
|
137
|
+
format: "note",
|
|
138
|
+
body: "root 2",
|
|
165
139
|
});
|
|
166
140
|
await postService.create({
|
|
167
|
-
|
|
168
|
-
|
|
141
|
+
format: "note",
|
|
142
|
+
body: "reply to root 1",
|
|
169
143
|
replyToId: root1.id,
|
|
170
144
|
});
|
|
171
145
|
await postService.create({
|
|
172
|
-
|
|
173
|
-
|
|
146
|
+
format: "note",
|
|
147
|
+
body: "reply to root 2",
|
|
174
148
|
replyToId: root2.id,
|
|
175
149
|
});
|
|
176
150
|
|
|
@@ -185,17 +159,17 @@ describe("PostService - Timeline features", () => {
|
|
|
185
159
|
|
|
186
160
|
it("excludes deleted replies", async () => {
|
|
187
161
|
const root = await postService.create({
|
|
188
|
-
|
|
189
|
-
|
|
162
|
+
format: "note",
|
|
163
|
+
body: "root",
|
|
190
164
|
});
|
|
191
165
|
const reply1 = await postService.create({
|
|
192
|
-
|
|
193
|
-
|
|
166
|
+
format: "note",
|
|
167
|
+
body: "reply 1",
|
|
194
168
|
replyToId: root.id,
|
|
195
169
|
});
|
|
196
170
|
await postService.create({
|
|
197
|
-
|
|
198
|
-
|
|
171
|
+
format: "note",
|
|
172
|
+
body: "reply 2",
|
|
199
173
|
replyToId: root.id,
|
|
200
174
|
});
|
|
201
175
|
|
|
@@ -204,17 +178,47 @@ describe("PostService - Timeline features", () => {
|
|
|
204
178
|
const previews = await postService.getThreadPreviews([root.id]);
|
|
205
179
|
const replies = previews.get(root.id);
|
|
206
180
|
expect(replies).toHaveLength(1);
|
|
207
|
-
expect(replies?.[0]?.
|
|
181
|
+
expect(replies?.[0]?.body).toBe("reply 2");
|
|
208
182
|
});
|
|
209
183
|
|
|
210
184
|
it("returns empty for roots with no replies", async () => {
|
|
211
185
|
const root = await postService.create({
|
|
212
|
-
|
|
213
|
-
|
|
186
|
+
format: "note",
|
|
187
|
+
body: "root with no replies",
|
|
214
188
|
});
|
|
215
189
|
|
|
216
190
|
const previews = await postService.getThreadPreviews([root.id]);
|
|
217
191
|
expect(previews.get(root.id)).toBeUndefined();
|
|
218
192
|
});
|
|
219
193
|
});
|
|
194
|
+
|
|
195
|
+
describe("timeline assembly", () => {
|
|
196
|
+
it("fetches published non-reply posts for the timeline", async () => {
|
|
197
|
+
const root = await postService.create({
|
|
198
|
+
format: "note",
|
|
199
|
+
body: "a published note",
|
|
200
|
+
status: "published",
|
|
201
|
+
});
|
|
202
|
+
await postService.create({
|
|
203
|
+
format: "note",
|
|
204
|
+
body: "a reply",
|
|
205
|
+
status: "published",
|
|
206
|
+
replyToId: root.id,
|
|
207
|
+
});
|
|
208
|
+
await postService.create({
|
|
209
|
+
format: "note",
|
|
210
|
+
body: "a draft",
|
|
211
|
+
status: "draft",
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
const posts = await postService.list({
|
|
215
|
+
status: "published",
|
|
216
|
+
excludeReplies: true,
|
|
217
|
+
limit: 21,
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
expect(posts).toHaveLength(1);
|
|
221
|
+
expect(posts[0]?.body).toBe("a published note");
|
|
222
|
+
});
|
|
223
|
+
});
|
|
220
224
|
});
|