feat(scheduling-webui): model invitation actions
This commit is contained in:
@@ -7,6 +7,8 @@ import {
|
||||
participantDraftFromResponse,
|
||||
participantDraftsFromPicker,
|
||||
participantPayload,
|
||||
schedulingInvitationActionBlocks,
|
||||
schedulingPublicInvitationUrl,
|
||||
schedulingSortPhase,
|
||||
type SchedulingActor
|
||||
} from "../src/features/scheduling/schedulingViewModel.ts";
|
||||
@@ -148,6 +150,7 @@ function request(
|
||||
anonymous_password_protection_enabled: false,
|
||||
public_participation_policy_enforcement_available: false,
|
||||
public_participation_policy_enforcement_reason: "Public participation gateway not installed",
|
||||
participant_invitation_delivery_available: false,
|
||||
calendar_integration_enabled: false,
|
||||
calendar_freebusy_enabled: false,
|
||||
calendar_hold_enabled: false,
|
||||
@@ -249,6 +252,105 @@ test("orders unanswered by nearest slot before answered, closed, determined, and
|
||||
assert.equal(schedulingSortPhase(groups.invited.at(-1)!, actor, now), "past");
|
||||
});
|
||||
|
||||
test("derives stable invitation action blocks from policy, delivery, and participant state", () => {
|
||||
const managed = request("invitation-actions", { participantStatus: "invited" });
|
||||
managed.poll_id = "poll-1";
|
||||
managed.public_participation_policy_enforcement_available = true;
|
||||
managed.public_participation_policy_enforcement_reason = null;
|
||||
managed.participant_invitation_delivery_available = true;
|
||||
const participant = managed.participants[0];
|
||||
assert.deepEqual(schedulingInvitationActionBlocks(managed, participant, now), {
|
||||
copy: "participant_revision_unavailable",
|
||||
send: "participant_revision_unavailable",
|
||||
revoke: "participant_revision_unavailable"
|
||||
});
|
||||
participant.revision = "a".repeat(64);
|
||||
participant.poll_invitation_id = "invitation-1";
|
||||
|
||||
assert.deepEqual(schedulingInvitationActionBlocks(managed, participant, now), {
|
||||
copy: null,
|
||||
send: null,
|
||||
revoke: null
|
||||
});
|
||||
|
||||
managed.participant_invitation_delivery_available = false;
|
||||
assert.equal(
|
||||
schedulingInvitationActionBlocks(managed, participant, now).send,
|
||||
"delivery_unavailable"
|
||||
);
|
||||
|
||||
managed.participant_invitation_delivery_available = true;
|
||||
participant.email = null;
|
||||
participant.respondent_id = `scheduling-participant:${participant.id}`;
|
||||
assert.equal(
|
||||
schedulingInvitationActionBlocks(managed, participant, now).send,
|
||||
"no_delivery_target"
|
||||
);
|
||||
|
||||
managed.public_participation_policy_enforcement_available = false;
|
||||
assert.deepEqual(schedulingInvitationActionBlocks(managed, participant, now), {
|
||||
copy: "participation_policy_unavailable",
|
||||
send: "participation_policy_unavailable",
|
||||
revoke: "participation_policy_unavailable"
|
||||
});
|
||||
|
||||
participant.poll_invitation_id = null;
|
||||
assert.equal(
|
||||
schedulingInvitationActionBlocks(managed, participant, now).revoke,
|
||||
"no_active_invitation"
|
||||
);
|
||||
});
|
||||
|
||||
test("allows bounded cancelled-request links until the notice expires without blocking revocation", () => {
|
||||
const cancelled = request("cancelled-invitation", {
|
||||
participantStatus: "invited",
|
||||
status: "cancelled"
|
||||
});
|
||||
cancelled.poll_id = "poll-1";
|
||||
cancelled.public_participation_policy_enforcement_available = true;
|
||||
cancelled.participant_invitation_delivery_available = true;
|
||||
cancelled.cancellation_notice_until = "2026-07-20T11:00:00Z";
|
||||
cancelled.participants[0].revision = "b".repeat(64);
|
||||
cancelled.participants[0].poll_invitation_id = "invitation-1";
|
||||
|
||||
assert.deepEqual(schedulingInvitationActionBlocks(cancelled, cancelled.participants[0], now), {
|
||||
copy: null,
|
||||
send: null,
|
||||
revoke: null
|
||||
});
|
||||
|
||||
cancelled.cancellation_notice_until = "2026-07-20T09:00:00Z";
|
||||
assert.deepEqual(schedulingInvitationActionBlocks(cancelled, cancelled.participants[0], now), {
|
||||
copy: "cancellation_notice_expired",
|
||||
send: "cancellation_notice_expired",
|
||||
revoke: null
|
||||
});
|
||||
});
|
||||
|
||||
test("accepts only same-origin Scheduling public invitation URLs", () => {
|
||||
assert.equal(
|
||||
schedulingPublicInvitationUrl(
|
||||
"/scheduling/public/request-1/token-1",
|
||||
"https://govoplan.example"
|
||||
),
|
||||
"https://govoplan.example/scheduling/public/request-1/token-1"
|
||||
);
|
||||
assert.equal(
|
||||
schedulingPublicInvitationUrl(
|
||||
"https://attacker.example/scheduling/public/request-1/token-1",
|
||||
"https://govoplan.example"
|
||||
),
|
||||
null
|
||||
);
|
||||
assert.equal(
|
||||
schedulingPublicInvitationUrl(
|
||||
"/scheduling/publicity/request-1/token-1",
|
||||
"https://govoplan.example"
|
||||
),
|
||||
null
|
||||
);
|
||||
});
|
||||
|
||||
test("single-choice availability keeps one positive choice while preserving explicit no answers", () => {
|
||||
const next = applySchedulingAvailabilityChoice(
|
||||
["slot-a", "slot-b", "slot-c"],
|
||||
|
||||
Reference in New Issue
Block a user