mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
* feat: add usage-survey feedback types and gating function Claude-Session: https://claude.ai/code/session_01KAC9Lbx8AmebAnj9WQZXHp * feat: add onboarding usage-survey i18n strings to all locales Relabels three ambiguous feedback.usageTypes values (personal/team_internal/ business_workflow) and adds a new onboarding namespace (4 keys) across the reference locale and all 20 translations, so the tree compiles at every commit instead of only after both locale groups land. Claude-Session: https://claude.ai/code/session_01KAC9Lbx8AmebAnj9WQZXHp * feat: add UsageSurveyOverlay component * feat: mount UsageSurveyOverlay inside AuthGuard Claude-Session: https://claude.ai/code/session_01KAC9Lbx8AmebAnj9WQZXHp * fix: use text-start instead of text-left for RTL support in UsageSurveyOverlay * refactor: drop redundant usage-type field from the admin feedback dialog Claude-Session: https://claude.ai/code/session_01KAC9Lbx8AmebAnj9WQZXHp * feat: accept onboarding source and survey id in the feedback route Claude-Session: https://claude.ai/code/session_01KAC9Lbx8AmebAnj9WQZXHp * test: cover the onboarding source in the feedback route integration test Claude-Session: https://claude.ai/code/session_01KAC9Lbx8AmebAnj9WQZXHp * chore: remove orphaned usageTypeLabel i18n key * refactor: derive feedback source/survey_id enums from a single source of truth * perf: skip the settings fetch in UsageSurveyOverlay for non-admin users
153 lines
3.8 KiB
TypeScript
153 lines
3.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { shouldShowInstallFeedbackCard, shouldShowUsageSurvey } from "@/lib/feedback";
|
|
|
|
const NOW = new Date("2026-01-15T00:00:00Z").getTime();
|
|
|
|
describe("shouldShowInstallFeedbackCard", () => {
|
|
it("shows only for admins after analytics config is loaded and enabled", () => {
|
|
expect(
|
|
shouldShowInstallFeedbackCard({
|
|
settings: {},
|
|
role: "admin",
|
|
analyticsConfigLoaded: true,
|
|
analyticsEnabled: true,
|
|
now: NOW,
|
|
}),
|
|
).toBe(true);
|
|
|
|
expect(
|
|
shouldShowInstallFeedbackCard({
|
|
settings: {},
|
|
role: "user",
|
|
analyticsConfigLoaded: true,
|
|
analyticsEnabled: true,
|
|
now: NOW,
|
|
}),
|
|
).toBe(false);
|
|
|
|
expect(
|
|
shouldShowInstallFeedbackCard({
|
|
settings: {},
|
|
role: "admin",
|
|
analyticsConfigLoaded: false,
|
|
analyticsEnabled: true,
|
|
now: NOW,
|
|
}),
|
|
).toBe(false);
|
|
|
|
expect(
|
|
shouldShowInstallFeedbackCard({
|
|
settings: {},
|
|
role: "admin",
|
|
analyticsConfigLoaded: true,
|
|
analyticsEnabled: false,
|
|
now: NOW,
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
|
|
it("stays hidden after submit or permanent dismiss", () => {
|
|
expect(
|
|
shouldShowInstallFeedbackCard({
|
|
settings: { "feedback.install.submittedAt": "2026-01-14T00:00:00Z" },
|
|
role: "admin",
|
|
analyticsConfigLoaded: true,
|
|
analyticsEnabled: true,
|
|
now: NOW,
|
|
}),
|
|
).toBe(false);
|
|
|
|
expect(
|
|
shouldShowInstallFeedbackCard({
|
|
settings: { "feedback.install.dismissedAt": "2026-01-14T00:00:00Z" },
|
|
role: "admin",
|
|
analyticsConfigLoaded: true,
|
|
analyticsEnabled: true,
|
|
now: NOW,
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
|
|
it("honors snooze until the stored timestamp expires", () => {
|
|
expect(
|
|
shouldShowInstallFeedbackCard({
|
|
settings: { "feedback.install.snoozedUntil": "2026-01-16T00:00:00Z" },
|
|
role: "admin",
|
|
analyticsConfigLoaded: true,
|
|
analyticsEnabled: true,
|
|
now: NOW,
|
|
}),
|
|
).toBe(false);
|
|
|
|
expect(
|
|
shouldShowInstallFeedbackCard({
|
|
settings: { "feedback.install.snoozedUntil": "2026-01-14T00:00:00Z" },
|
|
role: "admin",
|
|
analyticsConfigLoaded: true,
|
|
analyticsEnabled: true,
|
|
now: NOW,
|
|
}),
|
|
).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("shouldShowUsageSurvey", () => {
|
|
it("shows only for admins after analytics config is loaded and enabled", () => {
|
|
expect(
|
|
shouldShowUsageSurvey({
|
|
settings: {},
|
|
role: "admin",
|
|
analyticsConfigLoaded: true,
|
|
analyticsEnabled: true,
|
|
}),
|
|
).toBe(true);
|
|
|
|
expect(
|
|
shouldShowUsageSurvey({
|
|
settings: {},
|
|
role: "user",
|
|
analyticsConfigLoaded: true,
|
|
analyticsEnabled: true,
|
|
}),
|
|
).toBe(false);
|
|
|
|
expect(
|
|
shouldShowUsageSurvey({
|
|
settings: {},
|
|
role: "admin",
|
|
analyticsConfigLoaded: false,
|
|
analyticsEnabled: true,
|
|
}),
|
|
).toBe(false);
|
|
|
|
expect(
|
|
shouldShowUsageSurvey({
|
|
settings: {},
|
|
role: "admin",
|
|
analyticsConfigLoaded: true,
|
|
analyticsEnabled: false,
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
|
|
it("stays hidden after answering or permanently dismissing", () => {
|
|
expect(
|
|
shouldShowUsageSurvey({
|
|
settings: { "onboarding.usageSurvey.answeredAt": "2026-01-14T00:00:00Z" },
|
|
role: "admin",
|
|
analyticsConfigLoaded: true,
|
|
analyticsEnabled: true,
|
|
}),
|
|
).toBe(false);
|
|
|
|
expect(
|
|
shouldShowUsageSurvey({
|
|
settings: { "onboarding.usageSurvey.dismissedAt": "2026-01-14T00:00:00Z" },
|
|
role: "admin",
|
|
analyticsConfigLoaded: true,
|
|
analyticsEnabled: true,
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
});
|