Keep invitation identities readable and access actions distinct

Wrap full recipient and inviter identities without shortening them, make each revoke/remove action name its exact subject, and retain mobile controls with compact invitation spacing. Preserve current roles, ownership protection, confirmations and transport.

Contract-Neutral: Organization-access presentation and regression tests only; existing API, authority, confirmation and saved-state contracts are unchanged.
Change-source: pulse-maintainer
This commit is contained in:
pulse-triage[bot]
2026-11-06 11:09:34 +00:00
parent 280a08690c
commit 8fa2973b2a
3 changed files with 126 additions and 7 deletions

View File

@@ -71,27 +71,32 @@ export const OrganizationAccessInvitationsSection: Component<
</Show>
<Show when={props.state.canManageCurrentOrg() && props.state.pendingInvitations().length > 0}>
<section class="rounded-md border border-border p-4 space-y-3">
<section class="rounded-md border border-border p-3 space-y-2 sm:p-4 sm:space-y-3">
<div>
<h4 class="text-sm font-semibold text-base-content">Pending Invitations</h4>
<p class="text-sm text-muted">These users still need to accept access.</p>
</div>
<div class="space-y-3">
<div class="space-y-2 sm:space-y-3">
<For each={props.state.pendingInvitations()}>
{(invitation) => (
<div class="flex flex-col gap-2 rounded-md border border-border bg-surface px-3 py-3 sm:flex-row sm:items-center sm:justify-between">
<div class="space-y-1">
<div
role="group"
aria-label={`Pending invitation for ${invitation.userId}`}
class="flex flex-col gap-1 rounded-md border border-border bg-surface px-3 py-2 sm:flex-row sm:items-center sm:justify-between sm:gap-2 sm:py-3"
>
<div class="min-w-0 space-y-1 [overflow-wrap:anywhere]">
<div class="text-sm font-medium text-base-content">{invitation.userId}</div>
<div class="text-xs text-muted">
Invited by {invitation.invitedBy || 'an admin'} on{' '}
{formatOrgDate(invitation.invitedAt)}
</div>
</div>
<div class="flex items-center gap-2">
<div class="flex shrink-0 items-center gap-2">
<OrganizationRoleBadge role={invitation.role} />
<Button
variant="dangerOutline"
size="mdCompact"
aria-label={`Revoke invitation for ${invitation.userId}`}
onClick={() => void props.state.revokeInvitation(invitation.userId)}
disabled={!props.state.canChangeAccess()}
>

View File

@@ -101,6 +101,7 @@ export const OrganizationAccessMembersSection: Component<OrganizationAccessMembe
variant="dangerGhost"
size="xs"
class="gap-1"
aria-label={`Remove ${member.userId} from organization`}
onClick={() => {
void props.state.removeMember(member);
}}

View File

@@ -169,6 +169,117 @@ afterEach(() => {
});
describe('OrganizationAccessPanel', () => {
const pendingInvitations = () =>
[
'provisioningserviceaccountfortheoperationsdepartmentanddisasterrecoveryteam@example.test',
'analyst@example.test',
].map((userId) => ({
userId,
role: 'editor' as const,
invitedBy: 'centralidentitymanagementadministratorfortheoperationsdepartment@example.test',
invitedAt: '2026-11-01T12:00:00Z',
}));
it('identifies each pending invitation and its revocation action without shortening identities', async () => {
listPendingInvitationsMock.mockResolvedValue(pendingInvitations());
renderPanel();
for (const invitation of pendingInvitations()) {
const group = await screen.findByRole('group', {
name: `Pending invitation for ${invitation.userId}`,
});
expect(within(group).getByText(invitation.userId, { exact: true })).toBeVisible();
expect(group).toHaveTextContent(`Invited by ${invitation.invitedBy}`);
expect(within(group).getByText('editor', { exact: true })).toBeVisible();
expect(
within(group).getByRole('button', {
name: `Revoke invitation for ${invitation.userId}`,
}),
).toBeEnabled();
}
expectNoWrites();
});
it.each([0, 1])(
'revokes only the invitation named by action %s and rereads saved access',
async (index) => {
let invitations = pendingInvitations();
const target = invitations[index].userId;
const retained = invitations[1 - index].userId;
listPendingInvitationsMock.mockImplementation(async () => invitations);
revokeInvitationMock.mockImplementation(async (_orgId, userId) => {
invitations = invitations.filter((invitation) => invitation.userId !== userId);
});
renderPanel();
fireEvent.click(
await screen.findByRole('button', { name: `Revoke invitation for ${target}` }),
);
await waitFor(() =>
expect(
screen.queryByRole('group', { name: `Pending invitation for ${target}` }),
).not.toBeInTheDocument(),
);
expect(revokeInvitationMock).toHaveBeenCalledExactlyOnceWith(
'org-a',
target,
expect.objectContaining({ expectedOrgID: 'org-a', retry: false }),
);
expect(
await screen.findByRole('group', { name: `Pending invitation for ${retained}` }),
).toBeVisible();
expect(await screen.findByText('user-2', { exact: true })).toBeVisible();
expect(removeMemberMock).not.toHaveBeenCalled();
expect(updateMemberRoleMock).not.toHaveBeenCalled();
expect(inviteMemberMock).not.toHaveBeenCalled();
expect(acceptMyInvitationMock).not.toHaveBeenCalled();
expect(declineMyInvitationMock).not.toHaveBeenCalled();
},
);
it.each(['user-2', 'user-3'])(
'names member removal for %s and keeps the existing confirmation',
async (target) => {
listMembersMock.mockResolvedValue([
...baseMembers,
{ userId: 'user-3', role: 'viewer', addedAt: '2026-11-01T12:00:00Z' },
]);
vi.mocked(confirm).mockReturnValue(false);
renderPanel();
for (const userId of ['user-2', 'user-3']) {
expect(
await screen.findByRole('button', { name: `Remove ${userId} from organization` }),
).toBeEnabled();
}
expect(
screen.queryByRole('button', { name: 'Remove user-1 from organization' }),
).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: `Remove ${target} from organization` }));
expect(confirm).toHaveBeenCalledOnce();
expect(vi.mocked(confirm).mock.calls[0][0]).toContain(target);
expect(vi.mocked(confirm).mock.calls[0][0]).toContain('Organization A');
expectNoWrites();
},
);
it('does not expose named invitation or member administration in a read-only session', async () => {
listPendingInvitationsMock.mockResolvedValue(pendingInvitations());
setReadOnly(true);
renderPanel();
await screen.findByText('user-2', { exact: true });
expect(
screen.queryByRole('button', { name: /^Revoke invitation for / }),
).not.toBeInTheDocument();
expect(
screen.queryByRole('button', { name: /^Remove .* from organization$/ }),
).not.toBeInTheDocument();
expectNoWrites();
});
const sameNamedInvitations = () =>
['client-east', 'client-west'].map((orgId) => ({
orgId,
@@ -321,7 +432,7 @@ describe('OrganizationAccessPanel', () => {
),
);
} else {
fireEvent.click(screen.getByRole('button', { name: 'Remove' }));
fireEvent.click(screen.getByRole('button', { name: 'Remove user-2 from organization' }));
await waitFor(() =>
expect(removeMemberMock).toHaveBeenCalledWith(
'org-a',
@@ -394,7 +505,9 @@ describe('OrganizationAccessPanel', () => {
await screen.findByText('user-2');
expect(screen.queryByRole('textbox', { name: 'Invite user ID' })).not.toBeInTheDocument();
expect(screen.queryByRole('combobox', { name: 'Role for user-2' })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Remove' })).not.toBeInTheDocument();
expect(
screen.queryByRole('button', { name: /^Remove .* from organization$/ }),
).not.toBeInTheDocument();
expect(listPendingInvitationsMock).not.toHaveBeenCalled();
expectNoWrites();
},