Skip to content

Commit 9f35f4c

Browse files
committed
test(web): finished review guide notifications fit the Windows toast tag limit
1 parent 202d5b5 commit 9f35f4c

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

‎apps/web/src/components/pullRequest/guide/PullRequestGuideRunCoordinator.test.ts‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ import {
55
type PullRequestRef,
66
type PullRequestReviewGuideResult,
77
} from "@t3tools/contracts";
8+
import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings";
89
import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity";
910
import { expect, it, vi } from "vite-plus/test";
1011

12+
import {
13+
__resetClientSettingsPersistenceForTests,
14+
__setClientSettingsForTests,
15+
} from "~/hooks/useSettings";
1116
import { guideRunKey, useGuideRunStore } from "./guideRunStore";
1217
import { startGuideRunNotifications } from "./PullRequestGuideRunCoordinator";
1318

@@ -120,3 +125,51 @@ it("does not report the previous run's failure when a Running answer starts a wa
120125
expect(useGuideRunStore.getState().watches[key]).toBe(undefined);
121126
stop();
122127
});
128+
129+
it("gives each finished guide's notification its own tag within the Windows toast limit", () => {
130+
using _cleanup = {
131+
[Symbol.dispose]: () => {
132+
vi.unstubAllGlobals();
133+
__resetClientSettingsPersistenceForTests();
134+
},
135+
};
136+
const tags: string[] = [];
137+
vi.stubGlobal("document", { visibilityState: "hidden", hasFocus: () => false });
138+
vi.stubGlobal(
139+
"Notification",
140+
class {
141+
static permission = "granted";
142+
constructor(_title: string, options: NotificationOptions) {
143+
tags.push(options.tag!);
144+
}
145+
addEventListener() {}
146+
},
147+
);
148+
__setClientSettingsForTests({ ...DEFAULT_CLIENT_SETTINGS, notificationMode: "notifications" });
149+
const registry = AtomRegistry.make();
150+
const stop = startGuideRunNotifications(registry, { navigate: vi.fn() } as unknown as AnyRouter);
151+
const uuidEnvironmentId = EnvironmentId.make("fd6fff30-f90b-4ee7-9812-4cf497791b90");
152+
const written = {
153+
guide: { generatedAt: "2026-10-01T00:00:00.000Z" },
154+
run: null,
155+
} as unknown as PullRequestReviewGuideResult;
156+
for (const number of [1234, 1235]) {
157+
registry.set(guideAtom(`${uuidEnvironmentId}:${number}`), AsyncResult.success(written));
158+
useGuideRunStore.getState().watch({
159+
environmentId: uuidEnvironmentId,
160+
reference: {
161+
projectId: ProjectId.make("a8395a98-a186-4fe7-9d4c-fb8ba63b7588"),
162+
repository: "pingdotgg/t3code",
163+
number,
164+
},
165+
title: null,
166+
previousGuideAt: null,
167+
previousFailedAt: null,
168+
since: 0,
169+
});
170+
}
171+
expect(tags).toHaveLength(2);
172+
for (const tag of tags) expect(tag.length).toBeLessThanOrEqual(64);
173+
expect(new Set(tags).size).toBe(2);
174+
stop();
175+
});

0 commit comments

Comments
 (0)