test: seed cached briefings with their generation moment

The today check now reads briefingGeneratedAt from the cached payload
and treats a payload without it as not from today. The integration
and e2e fixtures that seed a fresh briefing write it, as every real
generation does.
This commit is contained in:
Marc-André Bombeck committed 2026-10-05 22:28:10 +02:00
1 parent 7c7576423f
commit 63b395915e
4 files changed
+14 -2

No files matched your search

+2
View File
@@ -77,6 +77,8 @@ export async function resetAiOptionalAccount(): Promise<void> {
export async function seedStoredBriefing(marker: string): Promise<void> {
const insights = {
dailyBriefing: { paragraph: marker, keyFindings: [] },
// Generated now: only text written today is served as today's read.
briefingGeneratedAt: new Date().toISOString(),
};
await withAccount(async (pool, userId) => {
await pool.query(
@@ -93,7 +93,11 @@ async function seed(recordId: string): Promise<void> {
await prisma.user.update({
where: { id: recordId },
data: {
insightsCachedText: JSON.stringify(BRIEFING),
// Generated now: only text written today is served as today's read.
insightsCachedText: JSON.stringify({
...BRIEFING,
briefingGeneratedAt: new Date().toISOString(),
}),
insightsCachedAt: new Date(),
insightsCachedLocale: "en",
},
@@ -66,7 +66,11 @@ async function seedUserWithCachedBriefing(cachedLocale: string | null) {
// snapshot read resolves the reader's locale from.
locale: "de",
insightsCachedAt: new Date(),
insightsCachedText: JSON.stringify({ dailyBriefing: BRIEFING }),
// Generated now: only text written today is served as today's read.
insightsCachedText: JSON.stringify({
dailyBriefing: BRIEFING,
briefingGeneratedAt: new Date().toISOString(),
}),
insightsCachedLocale: cachedLocale,
// The briefing is shown only while its AI capability is available, so
// the account has its own provider (presence only) and a receipt.
@@ -279,6 +279,8 @@ function cachedBriefing(marker: string): string {
paragraph: `Briefing for the ${marker}. Second sentence.`,
keyFindings: [],
},
// Generated now: only text written today is served as today's read.
briefingGeneratedAt: new Date().toISOString(),
});
}