Launch Activity Logic

Nucleic-Session: EBB24271-3AB2-4CBD-A47A-59FC73500371
Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
2026-07-06 13:45:52 -07:00
co-authored by nucleic
parent 5d0dd10728
commit 97c2b0b797
+23
View File
@@ -141,6 +141,29 @@ test("liveActivityPayload carries the content-state for an update, dismissal for
assert.ok((doneEnd.aps["dismissal-date"] as number) > (end.aps["dismissal-date"] as number));
});
test("liveActivityPayload start carries attributes + type so ActivityKit can create the activity", () => {
const start = liveActivityPayload(
"start",
{ runningCount: 1, needsYouCount: 0 },
T0,
{ type: "NucleicSessionAttributes", attributes: { hostName: "Studio" } },
) as { aps: Record<string, unknown> };
assert.equal(start.aps.event, "start");
assert.equal(start.aps.timestamp, Math.floor(T0 / 1000));
assert.deepEqual(start.aps["content-state"], { runningCount: 1, needsYouCount: 0 });
assert.equal(start.aps["attributes-type"], "NucleicSessionAttributes");
assert.deepEqual(start.aps.attributes, { hostName: "Studio" });
// A start is not an end — it must not carry a dismissal.
assert.equal(start.aps["dismissal-date"], undefined);
// Without the attributes bundle a start still encodes, just without the create fields (the
// relay only omits them when the caller didn't supply them — an update/end never has them).
const bare = liveActivityPayload("start", {}, T0) as { aps: Record<string, unknown> };
assert.equal(bare.aps.event, "start");
assert.equal(bare.aps["attributes-type"], undefined);
assert.equal(bare.aps.attributes, undefined);
});
test("sendLiveActivityApns uses the liveactivity push type and topic suffix", async () => {
const { pem } = await freshKey();
const cfg: ApnsConfig = {