feat(scheduling): use central people picker
This commit is contained in:
@@ -4,10 +4,99 @@ import type { SchedulingRequest } from "../src/api/scheduling.ts";
|
||||
import {
|
||||
applySchedulingAvailabilityChoice,
|
||||
groupSchedulingRequests,
|
||||
participantDraftFromResponse,
|
||||
participantDraftsFromPicker,
|
||||
participantPayload,
|
||||
schedulingSortPhase,
|
||||
type SchedulingActor
|
||||
} from "../src/features/scheduling/schedulingViewModel.ts";
|
||||
|
||||
test("maps visible account and contact selections into bounded scheduling participant payloads", () => {
|
||||
let sequence = 0;
|
||||
const selected = participantDraftsFromPicker([
|
||||
{
|
||||
selection_key: "account:account-2",
|
||||
kind: "account",
|
||||
reference_id: "account-2",
|
||||
display_name: "Ada Account",
|
||||
email: "ADA@EXAMPLE.TEST",
|
||||
source_module: "access",
|
||||
source_label: "Accounts",
|
||||
provenance: { tenant_id: "must-not-be-persisted" },
|
||||
metadata: { group_ids: ["must-not-be-persisted"] }
|
||||
},
|
||||
{
|
||||
selection_key: "contact:contact-3:contact@example.test",
|
||||
kind: "contact",
|
||||
reference_id: "contact-3",
|
||||
display_name: "Contact Person",
|
||||
email: "contact@example.test",
|
||||
source_module: "addresses",
|
||||
source_label: "Contacts",
|
||||
source_revision: "revision-3",
|
||||
provenance: { address_book_id: "must-not-be-persisted" }
|
||||
}
|
||||
], [], () => `participant-${++sequence}`);
|
||||
|
||||
assert.equal(selected[0].respondent_id, "account-2");
|
||||
assert.equal(selected[0].participant_type, "internal");
|
||||
assert.equal(selected[0].email, "ada@example.test");
|
||||
assert.deepEqual(selected[0].metadata, {
|
||||
directory_selection: {
|
||||
selection_key: "account:account-2",
|
||||
kind: "account",
|
||||
reference_id: "account-2",
|
||||
source_module: "access",
|
||||
source_label: "Accounts",
|
||||
source_revision: null
|
||||
}
|
||||
});
|
||||
assert.equal(selected[1].respondent_id, null);
|
||||
assert.equal(selected[1].participant_type, "external");
|
||||
assert.equal(
|
||||
(selected[1].metadata?.directory_selection as { source_revision: string }).source_revision,
|
||||
"revision-3"
|
||||
);
|
||||
assert.deepEqual(participantPayload(selected[1]), {
|
||||
respondent_id: null,
|
||||
display_name: "Contact Person",
|
||||
email: "contact@example.test",
|
||||
participant_type: "external",
|
||||
required: true,
|
||||
metadata: selected[1].metadata
|
||||
});
|
||||
});
|
||||
|
||||
test("reconstructs saved directory selections and preserves existing reconciliation identity", () => {
|
||||
const responseParticipant = {
|
||||
id: "stored-participant",
|
||||
is_current_participant: false,
|
||||
respondent_id: "account-2",
|
||||
display_name: "Ada Account",
|
||||
email: "ada@example.test",
|
||||
participant_type: "internal",
|
||||
required: true,
|
||||
status: "invited",
|
||||
poll_invitation_id: "invitation-1",
|
||||
metadata: {
|
||||
directory_selection: {
|
||||
selection_key: "account:account-2",
|
||||
kind: "account",
|
||||
reference_id: "account-2",
|
||||
source_module: "access",
|
||||
source_label: "Accounts"
|
||||
}
|
||||
}
|
||||
};
|
||||
const draft = participantDraftFromResponse(responseParticipant, "draft-1");
|
||||
const remapped = participantDraftsFromPicker([draft], [draft], () => "unexpected");
|
||||
|
||||
assert.equal(remapped[0], draft);
|
||||
assert.equal(draft.sourceId, "stored-participant");
|
||||
assert.equal(draft.identityLocked, true);
|
||||
assert.equal(participantPayload(draft).id, "stored-participant");
|
||||
});
|
||||
|
||||
const now = new Date("2026-07-20T10:00:00Z");
|
||||
const actor: SchedulingActor = {
|
||||
accountId: "account-1",
|
||||
|
||||
Reference in New Issue
Block a user