create-feedbax 0.1.0 → 0.2.1
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/LICENSE +201 -21
- package/README.md +11 -1
- package/dist/cli.js +3283 -22
- package/dist/index.js +3394 -160
- package/package.json +40 -14
- package/template/.feedbax-template.sha256 +1 -0
- package/template/.gitignore.template +6 -0
- package/template/.npmignore.template +5 -0
- package/template/.prettierignore.template +4 -0
- package/template/AGENTS.md +13 -0
- package/template/CONNECTED.md +404 -0
- package/template/LICENSE +201 -0
- package/template/README.md +56 -5
- package/template/components.json +25 -0
- package/template/eslint.config.mjs +48 -0
- package/template/migrations/0001_connected.sql +6 -0
- package/template/migrations/0002_participation.sql +8 -0
- package/template/migrations/0003_images.sql +3 -0
- package/template/migrations/0004_followed_status.sql +9 -0
- package/template/package.json +74 -14
- package/template/public/feedbax-mark.svg +4 -0
- package/template/public/robots.txt +3 -0
- package/template/src/authorized-draft-post.test.tsx +212 -0
- package/template/src/authorized-draft-post.tsx +205 -0
- package/template/src/authorized-draft-query.ts +74 -0
- package/template/src/browser-post-state.test.ts +120 -0
- package/template/src/browser-post-state.ts +134 -0
- package/template/src/browser-vote-state.test.ts +14 -0
- package/template/src/browser-vote-state.ts +27 -0
- package/template/src/capability-authorization-error.ts +3 -0
- package/template/src/changelog-page.test.tsx +139 -0
- package/template/src/changelog-page.tsx +228 -0
- package/template/src/changelog-query.ts +13 -0
- package/template/src/changelog-runtime.ts +27 -0
- package/template/src/cloudflare-turnstile.ts +31 -0
- package/template/src/cloudflare-workers-test.ts +3 -0
- package/template/src/cloudflare-workers.d.ts +24 -0
- package/template/src/comment-creation.test.tsx +311 -0
- package/template/src/comment-profile.ts +5 -0
- package/template/src/comment-thread-page.ts +28 -0
- package/template/src/components/command-palette-context.tsx +71 -0
- package/template/src/components/command-palette.tsx +275 -0
- package/template/src/components/connected-identity-provider.tsx +108 -0
- package/template/src/components/create-post-trigger.tsx +44 -0
- package/template/src/components/device-profile-provider.tsx +324 -0
- package/template/src/components/follow-post-button.tsx +89 -0
- package/template/src/components/header.tsx +97 -0
- package/template/src/components/image-attachments.tsx +187 -0
- package/template/src/components/loader.tsx +53 -0
- package/template/src/components/notification-inbox.tsx +232 -0
- package/template/src/components/portal-footer.tsx +14 -0
- package/template/src/components/profile-menu.tsx +119 -0
- package/template/src/components/ui/components/alert-dialog.tsx +185 -0
- package/template/src/components/ui/components/attachment.tsx +207 -0
- package/template/src/components/ui/components/avatar.tsx +107 -0
- package/template/src/components/ui/components/badge.tsx +52 -0
- package/template/src/components/ui/components/bubble.tsx +128 -0
- package/template/src/components/ui/components/button-group.tsx +87 -0
- package/template/src/components/ui/components/button.tsx +56 -0
- package/template/src/components/ui/components/card.tsx +103 -0
- package/template/src/components/ui/components/checkbox.tsx +26 -0
- package/template/src/components/ui/components/command.tsx +195 -0
- package/template/src/components/ui/components/dialog.tsx +154 -0
- package/template/src/components/ui/components/drawer.tsx +229 -0
- package/template/src/components/ui/components/dropdown-menu.tsx +270 -0
- package/template/src/components/ui/components/empty.tsx +101 -0
- package/template/src/components/ui/components/field.tsx +236 -0
- package/template/src/components/ui/components/input-group.tsx +155 -0
- package/template/src/components/ui/components/input.tsx +20 -0
- package/template/src/components/ui/components/item.tsx +201 -0
- package/template/src/components/ui/components/kbd.tsx +26 -0
- package/template/src/components/ui/components/label.tsx +18 -0
- package/template/src/components/ui/components/marker.tsx +71 -0
- package/template/src/components/ui/components/message-scroller.tsx +128 -0
- package/template/src/components/ui/components/message.tsx +92 -0
- package/template/src/components/ui/components/native-select.tsx +65 -0
- package/template/src/components/ui/components/popover.tsx +88 -0
- package/template/src/components/ui/components/portal-primitives.test.tsx +85 -0
- package/template/src/components/ui/components/radio-group.tsx +36 -0
- package/template/src/components/ui/components/scroll-area.tsx +51 -0
- package/template/src/components/ui/components/secondary-form-actions.test.tsx +23 -0
- package/template/src/components/ui/components/select.tsx +199 -0
- package/template/src/components/ui/components/separator.tsx +23 -0
- package/template/src/components/ui/components/sheet.tsx +135 -0
- package/template/src/components/ui/components/skeleton.tsx +13 -0
- package/template/src/components/ui/components/sonner.tsx +43 -0
- package/template/src/components/ui/components/spinner.tsx +16 -0
- package/template/src/components/ui/components/switch.tsx +29 -0
- package/template/src/components/ui/components/tabs.tsx +80 -0
- package/template/src/components/ui/components/textarea.tsx +18 -0
- package/template/src/components/ui/components/tooltip.tsx +64 -0
- package/template/src/components/ui/hooks/.gitkeep +0 -0
- package/template/src/components/ui/lib/utils.ts +6 -0
- package/template/src/components/ui/styles/globals.css +151 -0
- package/template/src/connected-identity.test.ts +144 -0
- package/template/src/connected-identity.ts +122 -0
- package/template/src/connected-participation.test.tsx +67 -0
- package/template/src/connected-runtime.test.ts +241 -0
- package/template/src/connected-runtime.ts +176 -0
- package/template/src/connected-social.test.tsx +158 -0
- package/template/src/create-post-overlay.tsx +82 -0
- package/template/src/draft-post-list.tsx +39 -0
- package/template/src/feedback-cache-invalidation.test.ts +185 -0
- package/template/src/feedback-cache-invalidation.ts +98 -0
- package/template/src/feedback-runtime.ts +105 -0
- package/template/src/feedbax/changelog/index.test.ts +156 -0
- package/template/src/feedbax/changelog/index.ts +206 -0
- package/template/src/feedbax/changelog/notion-changelog.test.ts +395 -0
- package/template/src/feedbax/changelog/notion-changelog.ts +400 -0
- package/template/src/feedbax/config/index.test.ts +139 -0
- package/template/src/feedbax/config/index.ts +364 -0
- package/template/src/feedbax/feedback/connected-feedback.ts +206 -0
- package/template/src/feedbax/feedback/connected.test.ts +272 -0
- package/template/src/feedbax/feedback/connected.ts +215 -0
- package/template/src/feedbax/feedback/email-delivery.test.ts +65 -0
- package/template/src/feedbax/feedback/email-delivery.ts +66 -0
- package/template/src/feedbax/feedback/feedback-storage.ts +43 -0
- package/template/src/feedbax/feedback/identity-handoff.test.ts +81 -0
- package/template/src/feedbax/feedback/identity-handoff.ts +119 -0
- package/template/src/feedbax/feedback/image-feedback.ts +101 -0
- package/template/src/feedbax/feedback/images.test.ts +223 -0
- package/template/src/feedbax/feedback/images.ts +324 -0
- package/template/src/feedbax/feedback/index.test.ts +900 -0
- package/template/src/feedbax/feedback/index.ts +996 -0
- package/template/src/feedbax/feedback/notion-comments.test.ts +171 -0
- package/template/src/feedbax/feedback/notion-comments.ts +231 -0
- package/template/src/feedbax/feedback/notion-data-source.test.ts +364 -0
- package/template/src/feedbax/feedback/notion-data-source.ts +458 -0
- package/template/src/feedbax/feedback/notion-feedback.test.ts +998 -0
- package/template/src/feedbax/feedback/notion-feedback.ts +651 -0
- package/template/src/feedbax/feedback/notion-image-review.ts +55 -0
- package/template/src/feedbax/feedback/notion-request.ts +74 -0
- package/template/src/feedbax/feedback/participation.test.ts +653 -0
- package/template/src/feedbax/feedback/participation.ts +502 -0
- package/template/src/feedbax.test-fixture.ts +64 -0
- package/template/src/feedbax.ts +69 -0
- package/template/src/images-runtime.test.ts +133 -0
- package/template/src/images-runtime.ts +125 -0
- package/template/src/index.css +1795 -0
- package/template/src/lazy-create-post-overlay.tsx +6 -0
- package/template/src/lazy-post-detail-overlay.tsx +21 -0
- package/template/src/masked-post-link.tsx +27 -0
- package/template/src/overlay-post-detail.test.tsx +181 -0
- package/template/src/overlay-post-detail.tsx +43 -0
- package/template/src/participation-client.ts +63 -0
- package/template/src/participation-runtime.test.ts +35 -0
- package/template/src/participation-runtime.ts +255 -0
- package/template/src/portal-comments.test.ts +375 -0
- package/template/src/portal-comments.ts +403 -0
- package/template/src/portal-features.test.tsx +150 -0
- package/template/src/portal-feedback-form.tsx +530 -0
- package/template/src/portal-feedback-runtime.test.ts +32 -0
- package/template/src/portal-feedback-runtime.ts +58 -0
- package/template/src/portal-feedback-server-function.ts +96 -0
- package/template/src/portal-feedback-submission.test.ts +307 -0
- package/template/src/portal-feedback-submission.ts +224 -0
- package/template/src/portal-head.ts +58 -0
- package/template/src/portal-server-entry.ts +68 -0
- package/template/src/portal-voting.test.ts +106 -0
- package/template/src/portal-voting.ts +149 -0
- package/template/src/post-badges.tsx +27 -0
- package/template/src/post-creation-flow.test.tsx +230 -0
- package/template/src/post-creation-flow.tsx +88 -0
- package/template/src/post-detail-content.test.tsx +233 -0
- package/template/src/post-detail-content.tsx +162 -0
- package/template/src/post-detail-overlay.test.tsx +114 -0
- package/template/src/post-detail-overlay.tsx +67 -0
- package/template/src/post-detail-query.ts +34 -0
- package/template/src/post-feed-controls.test.tsx +239 -0
- package/template/src/post-feed-controls.tsx +298 -0
- package/template/src/post-presentation.ts +37 -0
- package/template/src/post-queries.test.ts +158 -0
- package/template/src/post-queries.ts +26 -0
- package/template/src/post-results.tsx +165 -0
- package/template/src/public-cache-policy.test.ts +148 -0
- package/template/src/public-cache-policy.ts +119 -0
- package/template/src/public-cache-tags.ts +7 -0
- package/template/src/public-changelog-page.ts +15 -0
- package/template/src/public-changelog-server-function.ts +27 -0
- package/template/src/public-date.ts +11 -0
- package/template/src/public-failure-state.test.tsx +69 -0
- package/template/src/public-feedback-index.tsx +94 -0
- package/template/src/public-feedback-page.test.tsx +355 -0
- package/template/src/public-feedback-page.ts +86 -0
- package/template/src/public-feedback-server-function.ts +22 -0
- package/template/src/public-portal-error.tsx +27 -0
- package/template/src/public-post-detail-skeleton.tsx +54 -0
- package/template/src/public-post-detail.tsx +772 -0
- package/template/src/public-post-page.test.tsx +173 -0
- package/template/src/public-post-page.ts +15 -0
- package/template/src/public-post-route.test.tsx +250 -0
- package/template/src/public-post-route.tsx +158 -0
- package/template/src/public-post-server-function.ts +48 -0
- package/template/src/public-post-unavailable.tsx +10 -0
- package/template/src/public-roadmap-page.test.tsx +139 -0
- package/template/src/public-roadmap-page.ts +24 -0
- package/template/src/public-roadmap-route.test.tsx +254 -0
- package/template/src/public-roadmap-route.tsx +50 -0
- package/template/src/public-roadmap-server-function.ts +44 -0
- package/template/src/public-roadmap-view.tsx +411 -0
- package/template/src/public-shell.test.tsx +544 -0
- package/template/src/roadmap-query.ts +21 -0
- package/template/src/root-branding.test.ts +53 -0
- package/template/src/routeTree.gen.ts +177 -0
- package/template/src/routed-post-creation-form.tsx +28 -0
- package/template/src/router.tsx +27 -0
- package/template/src/routes/__root.tsx +114 -0
- package/template/src/routes/changelog.tsx +39 -0
- package/template/src/routes/email-preferences.tsx +77 -0
- package/template/src/routes/index.tsx +61 -0
- package/template/src/routes/p.$slug.tsx +16 -0
- package/template/src/routes/roadmap.tsx +11 -0
- package/template/src/routes/submit.tsx +28 -0
- package/template/src/safe-public-failure.ts +47 -0
- package/template/src/server.ts +151 -0
- package/template/src/similar-posts.tsx +45 -0
- package/template/src/submit-route.test.tsx +134 -0
- package/template/src/trusted-feedback-handler.test.ts +425 -0
- package/template/src/trusted-feedback-handler.ts +181 -0
- package/template/src/trusted-feedback-runtime.ts +17 -0
- package/template/src/turnstile-configuration.test.ts +37 -0
- package/template/src/turnstile-configuration.ts +19 -0
- package/template/src/use-media-query.ts +17 -0
- package/template/src/vote-toggle.test.tsx +171 -0
- package/template/src/vote-toggle.tsx +244 -0
- package/template/tsconfig.json +45 -0
- package/template/vite.config.ts +20 -0
- package/template/vitest.config.ts +4 -0
- package/template/vitest.setup.ts +3 -0
- package/template/wrangler.jsonc +35 -0
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/index.d.ts +0 -21
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/template/.env.example +0 -4
- package/template/apps/portal/components.json +0 -20
- package/template/apps/portal/package.json +0 -31
- package/template/apps/portal/src/lib/utils.ts +0 -6
- package/template/apps/portal/src/routeTree.gen.ts +0 -59
- package/template/apps/portal/src/router.tsx +0 -10
- package/template/apps/portal/src/routes/__root.tsx +0 -31
- package/template/apps/portal/src/routes/index.tsx +0 -35
- package/template/apps/portal/src/styles.css +0 -91
- package/template/apps/portal/tsconfig.json +0 -15
- package/template/apps/portal/vite.config.ts +0 -13
- package/template/feedbax.config.ts +0 -13
- package/template/feedbax.jsonc +0 -11
- package/template/pnpm-workspace.yaml +0 -3
- package/template/turbo.json +0 -8
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { createFeedbackModule } from "@feedbax/feedback";
|
|
2
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
|
|
5
|
+
import { loadPublicRoadmapPage } from "./public-roadmap-page";
|
|
6
|
+
import {
|
|
7
|
+
PublicRoadmapSkeleton,
|
|
8
|
+
PublicRoadmapView,
|
|
9
|
+
} from "./public-roadmap-view";
|
|
10
|
+
|
|
11
|
+
describe("public roadmap page", () => {
|
|
12
|
+
it("loads Published Posts in the agreed roadmap groups and order", async () => {
|
|
13
|
+
const createdAt = new Date("2026-08-01T09:00:00.000Z");
|
|
14
|
+
const feedback = createFeedbackModule({
|
|
15
|
+
initialItems: [
|
|
16
|
+
roadmapItem("planned-older", "Planned earlier", "Planned", createdAt),
|
|
17
|
+
roadmapItem(
|
|
18
|
+
"planned-newer",
|
|
19
|
+
"Planned later",
|
|
20
|
+
"Planned",
|
|
21
|
+
new Date("2026-08-20T09:00:00.000Z"),
|
|
22
|
+
),
|
|
23
|
+
roadmapItem(
|
|
24
|
+
"in-progress",
|
|
25
|
+
"Building now",
|
|
26
|
+
"In Progress",
|
|
27
|
+
new Date("2026-08-19T09:00:00.000Z"),
|
|
28
|
+
),
|
|
29
|
+
roadmapItem(
|
|
30
|
+
"shipped",
|
|
31
|
+
"Already shipped",
|
|
32
|
+
"Shipped",
|
|
33
|
+
new Date("2026-08-18T09:00:00.000Z"),
|
|
34
|
+
),
|
|
35
|
+
{
|
|
36
|
+
...roadmapItem(
|
|
37
|
+
"private",
|
|
38
|
+
"Private plan",
|
|
39
|
+
"Planned",
|
|
40
|
+
new Date("2026-08-21T09:00:00.000Z"),
|
|
41
|
+
),
|
|
42
|
+
published: false,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const roadmap = await loadPublicRoadmapPage({ feedback });
|
|
48
|
+
|
|
49
|
+
expect(roadmap.Planned.items.map((item) => item.title)).toEqual([
|
|
50
|
+
"Planned later",
|
|
51
|
+
"Planned earlier",
|
|
52
|
+
]);
|
|
53
|
+
expect(roadmap["In Progress"].items.map((item) => item.title)).toEqual([
|
|
54
|
+
"Building now",
|
|
55
|
+
]);
|
|
56
|
+
expect(roadmap.Shipped.items.map((item) => item.title)).toEqual([
|
|
57
|
+
"Already shipped",
|
|
58
|
+
]);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("renders explicit empty groups", () => {
|
|
62
|
+
const html = renderToStaticMarkup(
|
|
63
|
+
<PublicRoadmapView roadmap={emptyRoadmap()} />,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
expect(html).toContain("Planned");
|
|
67
|
+
expect(html).toContain("In progress");
|
|
68
|
+
expect(html).toContain("Shipped");
|
|
69
|
+
expect(html.match(/No Posts here yet\./g)).toHaveLength(3);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("renders the roadmap workspace described by the visual brief", () => {
|
|
73
|
+
const html = renderToStaticMarkup(
|
|
74
|
+
<PublicRoadmapView roadmap={emptyRoadmap()} />,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
expect(html).toContain("What we’re planning, building, and shipping.");
|
|
78
|
+
expect(html).toContain("Search");
|
|
79
|
+
expect(html).not.toContain("Filters");
|
|
80
|
+
expect(html).toContain("New post");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("links roadmap Posts by immutable slug", () => {
|
|
84
|
+
const item = roadmapItem(
|
|
85
|
+
"stable-notion-page-id",
|
|
86
|
+
"Keyboard-first search!",
|
|
87
|
+
"Planned",
|
|
88
|
+
new Date("2026-08-20T09:00:00.000Z"),
|
|
89
|
+
);
|
|
90
|
+
const html = renderToStaticMarkup(
|
|
91
|
+
<PublicRoadmapView
|
|
92
|
+
roadmap={{
|
|
93
|
+
...emptyRoadmap(),
|
|
94
|
+
Planned: { items: [item], totalCount: 1 },
|
|
95
|
+
}}
|
|
96
|
+
/>,
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
expect(html).toContain('href="/p/keyboard-first-search"');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("renders three roadmap skeleton columns while the route is loading", () => {
|
|
103
|
+
const html = renderToStaticMarkup(<PublicRoadmapSkeleton />);
|
|
104
|
+
|
|
105
|
+
expect(html).toContain('aria-label="Loading roadmap"');
|
|
106
|
+
expect(html.match(/data-roadmap-skeleton-column/g)).toHaveLength(3);
|
|
107
|
+
expect(html).toContain("What we’re planning, building, and shipping.");
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
function roadmapItem(
|
|
112
|
+
id: string,
|
|
113
|
+
title: string,
|
|
114
|
+
status: "Planned" | "In Progress" | "Shipped",
|
|
115
|
+
updatedAt: Date,
|
|
116
|
+
) {
|
|
117
|
+
return {
|
|
118
|
+
id,
|
|
119
|
+
slug: title
|
|
120
|
+
.toLowerCase()
|
|
121
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
122
|
+
.replace(/-$/, ""),
|
|
123
|
+
title,
|
|
124
|
+
description: `${title} description`,
|
|
125
|
+
type: "Feature Request" as const,
|
|
126
|
+
status,
|
|
127
|
+
published: true,
|
|
128
|
+
createdAt: new Date("2026-08-01T09:00:00.000Z"),
|
|
129
|
+
updatedAt,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function emptyRoadmap() {
|
|
134
|
+
return {
|
|
135
|
+
Planned: { items: [], totalCount: 0 },
|
|
136
|
+
"In Progress": { items: [], totalCount: 0 },
|
|
137
|
+
Shipped: { items: [], totalCount: 0 },
|
|
138
|
+
};
|
|
139
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FeedbackModule,
|
|
3
|
+
PublicPostRoadmap,
|
|
4
|
+
PublicRoadmapPage,
|
|
5
|
+
PublicRoadmapQuery,
|
|
6
|
+
} from "@feedbax/feedback";
|
|
7
|
+
|
|
8
|
+
export function loadPublicRoadmapPage({
|
|
9
|
+
feedback,
|
|
10
|
+
}: {
|
|
11
|
+
feedback: Pick<FeedbackModule, "getPublicPostRoadmap">;
|
|
12
|
+
}): Promise<PublicPostRoadmap> {
|
|
13
|
+
return feedback.getPublicPostRoadmap();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function loadPublicRoadmapStatusPage({
|
|
17
|
+
feedback,
|
|
18
|
+
query,
|
|
19
|
+
}: {
|
|
20
|
+
feedback: Pick<FeedbackModule, "listPublicRoadmapPosts">;
|
|
21
|
+
query: PublicRoadmapQuery;
|
|
22
|
+
}): Promise<PublicRoadmapPage> {
|
|
23
|
+
return feedback.listPublicRoadmapPosts(query);
|
|
24
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
|
|
3
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
4
|
+
import {
|
|
5
|
+
cleanup,
|
|
6
|
+
fireEvent,
|
|
7
|
+
render,
|
|
8
|
+
screen,
|
|
9
|
+
waitFor,
|
|
10
|
+
} from "@testing-library/react";
|
|
11
|
+
import {
|
|
12
|
+
Outlet,
|
|
13
|
+
RouterProvider,
|
|
14
|
+
createMemoryHistory,
|
|
15
|
+
createRootRouteWithContext,
|
|
16
|
+
createRoute,
|
|
17
|
+
createRouter,
|
|
18
|
+
} from "@tanstack/react-router";
|
|
19
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
20
|
+
|
|
21
|
+
import type { RouterAppContext } from "./routes/__root";
|
|
22
|
+
import { createPublicRoadmapRoute } from "./public-roadmap-route";
|
|
23
|
+
import { PublicRoadmapView } from "./public-roadmap-view";
|
|
24
|
+
|
|
25
|
+
afterEach(cleanup);
|
|
26
|
+
|
|
27
|
+
describe("/roadmap route", () => {
|
|
28
|
+
it("hydrates once, renders ordered groups, and navigates cards canonically", async () => {
|
|
29
|
+
const queryClient = new QueryClient();
|
|
30
|
+
const fetchRoadmap = vi.fn(async () => ({
|
|
31
|
+
Planned: {
|
|
32
|
+
items: [post("planned-post", "Planned")],
|
|
33
|
+
totalCount: 1,
|
|
34
|
+
},
|
|
35
|
+
"In Progress": {
|
|
36
|
+
items: [post("building-post", "In Progress")],
|
|
37
|
+
totalCount: 1,
|
|
38
|
+
},
|
|
39
|
+
Shipped: { items: [], totalCount: 0 },
|
|
40
|
+
}));
|
|
41
|
+
const history = createMemoryHistory({ initialEntries: ["/roadmap"] });
|
|
42
|
+
const root = createRootRouteWithContext<RouterAppContext>()({
|
|
43
|
+
component: () => (
|
|
44
|
+
<QueryClientProvider client={queryClient}>
|
|
45
|
+
<Outlet />
|
|
46
|
+
</QueryClientProvider>
|
|
47
|
+
),
|
|
48
|
+
});
|
|
49
|
+
const roadmap = createPublicRoadmapRoute({ fetchRoadmap }).update({
|
|
50
|
+
id: "/roadmap",
|
|
51
|
+
path: "/roadmap",
|
|
52
|
+
getParentRoute: () => root,
|
|
53
|
+
} as never);
|
|
54
|
+
const postDetail = createRoute({
|
|
55
|
+
getParentRoute: () => root,
|
|
56
|
+
path: "/p/$slug",
|
|
57
|
+
component: () => <div>Post detail</div>,
|
|
58
|
+
});
|
|
59
|
+
const router = createRouter({
|
|
60
|
+
context: { queryClient },
|
|
61
|
+
history,
|
|
62
|
+
routeTree: root.addChildren([roadmap, postDetail]),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
render(<RouterProvider router={router} />);
|
|
66
|
+
|
|
67
|
+
const headings = await screen.findAllByRole("heading", { level: 2 });
|
|
68
|
+
expect(headings.map((heading) => heading.textContent)).toEqual([
|
|
69
|
+
"Planned",
|
|
70
|
+
"In progress",
|
|
71
|
+
"Shipped",
|
|
72
|
+
]);
|
|
73
|
+
expect(fetchRoadmap).toHaveBeenCalledTimes(1);
|
|
74
|
+
|
|
75
|
+
fireEvent.click(screen.getByRole("link", { name: /planned-post/i }));
|
|
76
|
+
|
|
77
|
+
await waitFor(() =>
|
|
78
|
+
expect(history.location.pathname).toBe("/p/planned-post"),
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("appends the next page in one column and removes its button on exhaustion", async () => {
|
|
83
|
+
const queryClient = new QueryClient();
|
|
84
|
+
const fetchRoadmap = vi.fn(async () => ({
|
|
85
|
+
Planned: {
|
|
86
|
+
items: [post("planned-page-1", "Planned")],
|
|
87
|
+
nextCursor: "planned-cursor",
|
|
88
|
+
totalCount: 2,
|
|
89
|
+
},
|
|
90
|
+
"In Progress": { items: [], totalCount: 0 },
|
|
91
|
+
Shipped: { items: [], totalCount: 0 },
|
|
92
|
+
}));
|
|
93
|
+
let resolveNextPage!: (page: {
|
|
94
|
+
items: ReturnType<typeof post>[];
|
|
95
|
+
totalCount: number;
|
|
96
|
+
}) => void;
|
|
97
|
+
const fetchRoadmapStatusPage = vi.fn(
|
|
98
|
+
() =>
|
|
99
|
+
new Promise<{
|
|
100
|
+
items: ReturnType<typeof post>[];
|
|
101
|
+
totalCount: number;
|
|
102
|
+
}>((resolve) => {
|
|
103
|
+
resolveNextPage = resolve;
|
|
104
|
+
}),
|
|
105
|
+
);
|
|
106
|
+
const history = createMemoryHistory({ initialEntries: ["/roadmap"] });
|
|
107
|
+
const root = createRootRouteWithContext<RouterAppContext>()({
|
|
108
|
+
component: () => (
|
|
109
|
+
<QueryClientProvider client={queryClient}>
|
|
110
|
+
<Outlet />
|
|
111
|
+
</QueryClientProvider>
|
|
112
|
+
),
|
|
113
|
+
});
|
|
114
|
+
const roadmap = createPublicRoadmapRoute({
|
|
115
|
+
fetchRoadmap,
|
|
116
|
+
fetchRoadmapStatusPage,
|
|
117
|
+
}).update({
|
|
118
|
+
id: "/roadmap",
|
|
119
|
+
path: "/roadmap",
|
|
120
|
+
getParentRoute: () => root,
|
|
121
|
+
} as never);
|
|
122
|
+
const router = createRouter({
|
|
123
|
+
context: { queryClient },
|
|
124
|
+
history,
|
|
125
|
+
routeTree: root.addChildren([roadmap]),
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
render(<RouterProvider router={router} />);
|
|
129
|
+
|
|
130
|
+
const loadMore = await screen.findByRole("button", {
|
|
131
|
+
name: "View more Planned Posts",
|
|
132
|
+
});
|
|
133
|
+
fireEvent.click(loadMore);
|
|
134
|
+
|
|
135
|
+
expect(fetchRoadmapStatusPage).toHaveBeenCalledWith({
|
|
136
|
+
status: "Planned",
|
|
137
|
+
cursor: "planned-cursor",
|
|
138
|
+
});
|
|
139
|
+
expect(loadMore.textContent).toContain("Loading");
|
|
140
|
+
expect((loadMore as HTMLButtonElement).disabled).toBe(true);
|
|
141
|
+
expect(
|
|
142
|
+
screen.getByRole("status", { name: "Roadmap status" }).textContent,
|
|
143
|
+
).toBe("Loading more Planned Posts.");
|
|
144
|
+
|
|
145
|
+
resolveNextPage({
|
|
146
|
+
items: [post("planned-page-2", "Planned")],
|
|
147
|
+
totalCount: 2,
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
expect(
|
|
151
|
+
await screen.findByRole("link", { name: /planned-page-2/i }),
|
|
152
|
+
).toBeTruthy();
|
|
153
|
+
await waitFor(() =>
|
|
154
|
+
expect(
|
|
155
|
+
screen.queryByRole("button", { name: "View more Planned Posts" }),
|
|
156
|
+
).toBeNull(),
|
|
157
|
+
);
|
|
158
|
+
expect(
|
|
159
|
+
screen.getByText("2", { selector: "[data-roadmap-count]" }),
|
|
160
|
+
).toBeTruthy();
|
|
161
|
+
expect(
|
|
162
|
+
screen.getByRole("status", { name: "Roadmap status" }).textContent,
|
|
163
|
+
).toBe("1 more Planned Post loaded.");
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("reveals five cards at a time before requesting another server page", async () => {
|
|
167
|
+
const items = Array.from({ length: 12 }, (_, index) =>
|
|
168
|
+
post(`planned-${index}`, "Planned"),
|
|
169
|
+
);
|
|
170
|
+
const loadMore = vi.fn().mockResolvedValue({
|
|
171
|
+
items: [post("planned-12", "Planned")],
|
|
172
|
+
totalCount: 13,
|
|
173
|
+
});
|
|
174
|
+
render(
|
|
175
|
+
<PublicRoadmapView
|
|
176
|
+
roadmap={{
|
|
177
|
+
Planned: { items, totalCount: 13, nextCursor: "next-page" },
|
|
178
|
+
"In Progress": { items: [], totalCount: 0 },
|
|
179
|
+
Shipped: { items: [], totalCount: 0 },
|
|
180
|
+
}}
|
|
181
|
+
loadMore={loadMore}
|
|
182
|
+
/>,
|
|
183
|
+
);
|
|
184
|
+
expect(screen.getAllByRole("link")).toHaveLength(5);
|
|
185
|
+
const button = screen.getByRole("button", {
|
|
186
|
+
name: "View more Planned Posts",
|
|
187
|
+
});
|
|
188
|
+
fireEvent.click(button);
|
|
189
|
+
expect(screen.getAllByRole("link")).toHaveLength(10);
|
|
190
|
+
expect(loadMore).not.toHaveBeenCalled();
|
|
191
|
+
fireEvent.click(button);
|
|
192
|
+
expect(
|
|
193
|
+
await screen.findByRole("link", { name: /planned-12 / }),
|
|
194
|
+
).toBeTruthy();
|
|
195
|
+
expect(screen.getAllByRole("link")).toHaveLength(13);
|
|
196
|
+
expect(loadMore).toHaveBeenCalledOnce();
|
|
197
|
+
expect(
|
|
198
|
+
screen.queryByRole("button", { name: "View more Planned Posts" }),
|
|
199
|
+
).toBeNull();
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("shows one status column at a time behind mobile status tabs", async () => {
|
|
203
|
+
Object.defineProperty(window, "matchMedia", {
|
|
204
|
+
configurable: true,
|
|
205
|
+
value: vi.fn().mockReturnValue({
|
|
206
|
+
matches: true,
|
|
207
|
+
addEventListener: vi.fn(),
|
|
208
|
+
removeEventListener: vi.fn(),
|
|
209
|
+
}),
|
|
210
|
+
});
|
|
211
|
+
render(
|
|
212
|
+
<PublicRoadmapView
|
|
213
|
+
roadmap={{
|
|
214
|
+
Planned: {
|
|
215
|
+
items: [post("planned-mobile", "Planned")],
|
|
216
|
+
totalCount: 1,
|
|
217
|
+
},
|
|
218
|
+
"In Progress": { items: [], totalCount: 0 },
|
|
219
|
+
Shipped: {
|
|
220
|
+
items: [
|
|
221
|
+
{
|
|
222
|
+
...post("shipped-mobile", "Planned"),
|
|
223
|
+
status: "Shipped",
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
totalCount: 1,
|
|
227
|
+
},
|
|
228
|
+
}}
|
|
229
|
+
/>,
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
expect(screen.getByRole("link", { name: /planned-mobile/i })).toBeTruthy();
|
|
233
|
+
expect(screen.queryByRole("link", { name: /shipped-mobile/i })).toBeNull();
|
|
234
|
+
|
|
235
|
+
fireEvent.click(screen.getByRole("tab", { name: /Shipped 1/i }));
|
|
236
|
+
|
|
237
|
+
expect(
|
|
238
|
+
await screen.findByRole("link", { name: /shipped-mobile/i }),
|
|
239
|
+
).toBeTruthy();
|
|
240
|
+
expect(screen.queryByRole("link", { name: /planned-mobile/i })).toBeNull();
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
function post(slug: string, status: "Planned" | "In Progress") {
|
|
245
|
+
return {
|
|
246
|
+
slug,
|
|
247
|
+
title: slug,
|
|
248
|
+
description: `${slug} description`,
|
|
249
|
+
type: "Feature Request" as const,
|
|
250
|
+
status,
|
|
251
|
+
createdAt: new Date("2026-08-22T10:00:00.000Z"),
|
|
252
|
+
updatedAt: new Date("2026-08-22T10:00:00.000Z"),
|
|
253
|
+
};
|
|
254
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useSuspenseQuery } from "@tanstack/react-query";
|
|
2
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
3
|
+
|
|
4
|
+
import { PublicPortalError } from "./public-portal-error";
|
|
5
|
+
import {
|
|
6
|
+
PublicRoadmapSkeleton,
|
|
7
|
+
PublicRoadmapView,
|
|
8
|
+
} from "./public-roadmap-view";
|
|
9
|
+
import {
|
|
10
|
+
publicRoadmapQuery,
|
|
11
|
+
type FetchPublicRoadmap,
|
|
12
|
+
type FetchPublicRoadmapStatusPage,
|
|
13
|
+
} from "./roadmap-query";
|
|
14
|
+
import feedbax from "./feedbax";
|
|
15
|
+
import { createRouteHead } from "./portal-head";
|
|
16
|
+
|
|
17
|
+
export function createPublicRoadmapRoute({
|
|
18
|
+
fetchRoadmap,
|
|
19
|
+
fetchRoadmapStatusPage,
|
|
20
|
+
}: {
|
|
21
|
+
fetchRoadmap: FetchPublicRoadmap;
|
|
22
|
+
fetchRoadmapStatusPage?: FetchPublicRoadmapStatusPage;
|
|
23
|
+
}) {
|
|
24
|
+
const query = publicRoadmapQuery(fetchRoadmap);
|
|
25
|
+
const route = createFileRoute("/roadmap")({
|
|
26
|
+
head: () =>
|
|
27
|
+
createRouteHead(feedbax.product, {
|
|
28
|
+
title: "Roadmap",
|
|
29
|
+
description: `See what ${feedbax.product.name} is considering, building, and shipping.`,
|
|
30
|
+
path: "/roadmap",
|
|
31
|
+
}),
|
|
32
|
+
loader: ({ context }) => context.queryClient.ensureQueryData(query),
|
|
33
|
+
component: RoadmapComponent,
|
|
34
|
+
pendingComponent: PublicRoadmapSkeleton,
|
|
35
|
+
errorComponent: PublicPortalError,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
function RoadmapComponent() {
|
|
39
|
+
const roadmap = useSuspenseQuery(query).data;
|
|
40
|
+
return (
|
|
41
|
+
<PublicRoadmapView
|
|
42
|
+
roadmap={roadmap}
|
|
43
|
+
loadMore={fetchRoadmapStatusPage}
|
|
44
|
+
maskPostLinks
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return route;
|
|
50
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { roadmapStatuses, type RoadmapStatus } from "@feedbax/feedback";
|
|
2
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
3
|
+
|
|
4
|
+
import { createConfiguredFeedbackModule } from "./feedback-runtime";
|
|
5
|
+
import {
|
|
6
|
+
loadPublicRoadmapPage,
|
|
7
|
+
loadPublicRoadmapStatusPage,
|
|
8
|
+
} from "./public-roadmap-page";
|
|
9
|
+
import { runSafePublicRead } from "./safe-public-failure";
|
|
10
|
+
|
|
11
|
+
const roadmapStatusSet = new Set<string>(roadmapStatuses);
|
|
12
|
+
|
|
13
|
+
export const getPublicRoadmapPage = createServerFn({ method: "GET" }).handler(
|
|
14
|
+
() =>
|
|
15
|
+
runSafePublicRead(() =>
|
|
16
|
+
loadPublicRoadmapPage({
|
|
17
|
+
feedback: createConfiguredFeedbackModule(),
|
|
18
|
+
}),
|
|
19
|
+
),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const getPublicRoadmapStatusPage = createServerFn({ method: "GET" })
|
|
23
|
+
.validator((input: unknown) => {
|
|
24
|
+
if (!input || typeof input !== "object")
|
|
25
|
+
throw new Error("Roadmap request is invalid.");
|
|
26
|
+
const status = Reflect.get(input, "status");
|
|
27
|
+
const cursor = Reflect.get(input, "cursor");
|
|
28
|
+
if (typeof status !== "string" || !roadmapStatusSet.has(status))
|
|
29
|
+
throw new Error("Roadmap request is invalid.");
|
|
30
|
+
if (cursor !== undefined && typeof cursor !== "string")
|
|
31
|
+
throw new Error("Roadmap request is invalid.");
|
|
32
|
+
return {
|
|
33
|
+
status: status as RoadmapStatus,
|
|
34
|
+
...(cursor ? { cursor } : {}),
|
|
35
|
+
};
|
|
36
|
+
})
|
|
37
|
+
.handler(({ data }) =>
|
|
38
|
+
runSafePublicRead(() =>
|
|
39
|
+
loadPublicRoadmapStatusPage({
|
|
40
|
+
feedback: createConfiguredFeedbackModule(),
|
|
41
|
+
query: data,
|
|
42
|
+
}),
|
|
43
|
+
),
|
|
44
|
+
);
|