Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/features/people/capo-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export function CapoPage({ area }: { area: CapoArea }) {
<span className="font-mono">{group.chatId}</span>
</span>
</span>
{group.admins ? null : <StatusBadge tone="warning">No admins</StatusBadge>}
{group.admins === 0 ? <StatusBadge tone="warning">No admins</StatusBadge> : null}
</li>
))}
</ul>
Expand Down
3 changes: 2 additions & 1 deletion src/features/people/people.contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ export type ImportPreview = z.infer<typeof importPreviewSchema>

export const capoAreaSchema = z.object({
scope: z.string(),
groups: z.array(groupSchema.extend({ admins: z.number().int() })),
// `admins` is null while the backend does not know a group's Telegram admins.
groups: z.array(groupSchema.extend({ admins: z.number().int().nullable() })),
admins: z.array(personRowSchema),
requests: z.array(z.object({ id: z.string(), person: personRefSchema, group: groupSchema, requestedOn: z.string() })),
})
Expand Down
12 changes: 12 additions & 0 deletions tests/people-input.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { validateCensusImport } from "../src/features/people/census-import.serve
import {
askToBeAddedInputSchema,
campaignInputSchema,
capoAreaSchema,
createMemberInputSchema,
personInputSchema,
resolveReviewInputSchema,
Expand Down Expand Up @@ -48,3 +49,14 @@ void test("admission cannot claim a transfer upload that does not exist", () =>
false
)
})

void test("the Capo area accepts groups whose Telegram admins the backend does not know", () => {
const area = (admins) => ({
scope: "Informatica",
groups: [{ chatId: "-1001", title: "Analisi 1", admins }],
admins: [],
requests: [],
})
assert.equal(capoAreaSchema.safeParse(area(null)).success, true)
assert.equal(capoAreaSchema.safeParse(area(2)).success, true)
})
Loading