diff --git a/docs/release-control/v6/internal/subsystems/organization-settings.md b/docs/release-control/v6/internal/subsystems/organization-settings.md index b69c1cbfad..fef9f2dc72 100644 --- a/docs/release-control/v6/internal/subsystems/organization-settings.md +++ b/docs/release-control/v6/internal/subsystems/organization-settings.md @@ -15,6 +15,27 @@ ## Purpose +### Invitation decisions identify the exact organization + +Your Invitations shows each organization's display name **and** ID beside its +existing role, inviter, date and Accept/Decline controls. A missing name or one +equal to the ID shows the ID once. Same-named organizations therefore remain +distinguishable without a tooltip or disclosure. Each invitation is an accessible +group, and both actions name its organization and ID. Long names, IDs and inviter +identities wrap instead of escaping the card at narrow or desktop widths. +`getOrganizationInvitationPresentation` owns that visible and accessible copy +in the existing organization presentation helper, with its registered unit proof. + +The existing current-reader, session/CSRF and no-automatic-retry transport is +unchanged: the action uses the invitation ID, not the display name or active +organization. Read-only sessions keep those decisions disabled. No membership +or permission is added by presentation alone. `OrganizationAccessPanel.test.tsx` +covers same-named decisions, exact dispatch/readback, ID fallbacks and read-only +controls. Comparable actual-panel desktop/narrow browser fixtures exercise the +real state, API and HTTP client with synthetic invitations, including keyboard +acceptance/decline, long identities and dark theme. This does not establish +original-account recovery or installed service acceptance. + ### Sharing requests require an explicitly chosen recipient A fresh Organization Sharing draft starts at **Select organization**. Neither diff --git a/frontend-modern/browser-verification/d150cd0d6da13b6e.json b/frontend-modern/browser-verification/d150cd0d6da13b6e.json new file mode 100644 index 0000000000..654b47d3c7 --- /dev/null +++ b/frontend-modern/browser-verification/d150cd0d6da13b6e.json @@ -0,0 +1,47 @@ +{ + "version": 1, + "result": "passed", + "base_sha": "5528d505717e3a480c4addee7a4f9d6caaa88b53", + "changed_paths": [ + "frontend-modern/src/components/Settings/OrganizationAccessInvitationsSection.tsx", + "frontend-modern/src/utils/organizationSettingsPresentation.ts" + ], + "content_sha256": { + "frontend-modern/src/components/Settings/OrganizationAccessInvitationsSection.tsx": "07c08add5d926471d511e7501234de9cda8291f8d11793ddb7f781125f875723", + "frontend-modern/src/utils/organizationSettingsPresentation.ts": "9fd38b96c93c6308cb5f97186626f61f97d9331f684ce08a4488a890099aebce" + }, + "routes": [ + "Settings / Organization Access / Your Invitations (actual panel, state, OrgsAPI and HTTP client, synthetic HTTP responses)" + ], + "states": [ + "Two same-named organizations, distinct IDs and roles", + "Keyboard acceptance of client-east leaves client-west pending", + "Read-only session with disabled decisions", + "Long organization name, ID and inviter, without hiding date or actions", + "Missing display name uses the ID once", + "Light desktop and phone; dark phone" + ], + "interactions": [ + "Keyboard Enter sends one CSRF/session-bound POST for client-east, never an API-token write, then explicit fresh readback", + "Keyboard Enter sends one DELETE for client-west, never a second acceptance, with active org-a unchanged", + "Read-only decisions remain disabled and a dispatched click sends no write", + "Each action is named with the organization identity and grouped with its own invitation", + "All 22 final captures opened through native view_image and compared: roles, inviter, date and controls remain visible; no collapse, aggregation or hover-only data" + ], + "viewports": [ + { + "width": 1440, + "height": 1000 + }, + { + "width": 390, + "height": 844 + } + ], + "verified_at": "2026-11-05T12:07:05Z", + "browser": { + "client": "1.56.1", + "browser": "141.0.7390.37" + }, + "notes": "11 comparable pairs with identical HTTP fixture data, viewport, theme, UTC locale and interaction state. Final checks use the verified launch graph e2185308. Before loads the exact assigned base panel and presentation-helper bytes through a Vite pre-load plugin; all consumers and client code are real. Final code only identifies and wraps existing invitation data; no server authorization, original-account, installed or release acceptance is claimed." +} diff --git a/frontend-modern/src/components/Settings/OrganizationAccessInvitationsSection.tsx b/frontend-modern/src/components/Settings/OrganizationAccessInvitationsSection.tsx index 0f2ce43f94..894aecd2ef 100644 --- a/frontend-modern/src/components/Settings/OrganizationAccessInvitationsSection.tsx +++ b/frontend-modern/src/components/Settings/OrganizationAccessInvitationsSection.tsx @@ -1,6 +1,7 @@ import { Component, For, Show } from 'solid-js'; import { Button } from '@/components/shared/Button'; import { OrganizationRoleBadge } from '@/components/shared/OrganizationBadges'; +import { getOrganizationInvitationPresentation } from '@/utils/organizationSettingsPresentation'; import { formatOrgDate } from '@/utils/orgUtils'; import type { useOrganizationAccessPanelState } from './useOrganizationAccessPanelState'; @@ -20,40 +21,50 @@ export const OrganizationAccessInvitationsSection: Component<
- {(invitation) => ( -
-
-
-
- {invitation.orgDisplayName || invitation.orgId} -
-
- Invited by {invitation.invitedBy || 'an admin'} on{' '} - {formatOrgDate(invitation.invitedAt)} + {(invitation) => { + const presentation = () => + getOrganizationInvitationPresentation(invitation.orgId, invitation.orgDisplayName); + return ( +
+
+
+
+ {presentation().organization} +
+
+ Invited by {invitation.invitedBy || 'an admin'} on{' '} + {formatOrgDate(invitation.invitedAt)} +
+ +
+
+ +
-
-
- - -
-
- )} + ); + }}
diff --git a/frontend-modern/src/components/Settings/__tests__/OrganizationAccessPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/OrganizationAccessPanel.test.tsx index 26e009b82a..4fa4a2e75d 100644 --- a/frontend-modern/src/components/Settings/__tests__/OrganizationAccessPanel.test.tsx +++ b/frontend-modern/src/components/Settings/__tests__/OrganizationAccessPanel.test.tsx @@ -2,7 +2,7 @@ import { createSignal } from 'solid-js'; import { useOrganizationAccessPanelState } from '../useOrganizationAccessPanelState'; import type { OrganizationMember } from '@/api/orgs'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library'; +import { cleanup, fireEvent, render, screen, waitFor, within } from '@solidjs/testing-library'; import { OrganizationAccessPanel } from '../OrganizationAccessPanel'; const orgGetMock = vi.fn(); @@ -169,6 +169,90 @@ afterEach(() => { }); describe('OrganizationAccessPanel', () => { + const sameNamedInvitations = () => + ['client-east', 'client-west'].map((orgId) => ({ + orgId, + orgDisplayName: 'Operations', + userId: 'user-1', + role: 'viewer', + invitedBy: 'admin@example.test', + invitedAt: '2026-11-01T10:00:00Z', + })); + + it('distinguishes same-named invitations with visible organization IDs and named actions', async () => { + listMyInvitationsMock.mockResolvedValue(sameNamedInvitations()); + renderPanel(); + + for (const orgId of ['client-east', 'client-west']) { + const invitation = await screen.findByRole('group', { + name: `Invitation to Operations (${orgId})`, + }); + expect(within(invitation).getByText(`Operations (${orgId})`)).toBeVisible(); + expect(invitation).toHaveTextContent('admin@example.test'); + expect(invitation).toHaveTextContent('viewer'); + for (const action of ['Accept', 'Decline']) { + expect( + within(invitation).getByRole('button', { + name: `${action} invitation to Operations (${orgId})`, + }), + ).toBeEnabled(); + } + } + expectNoWrites(); + }); + + it.each(['Accept', 'Decline'])( + '%s sends only the named invitation ID and refreshes without changing the active organization', + async (action) => { + let invitations = sameNamedInvitations(); + listMyInvitationsMock.mockImplementation(async () => invitations); + const request = action === 'Accept' ? acceptMyInvitationMock : declineMyInvitationMock; + request.mockImplementation(async (orgId) => { + invitations = invitations.filter((invitation) => invitation.orgId !== orgId); + return { kind: 'member' }; + }); + renderPanel(); + + fireEvent.click( + await screen.findByRole('button', { + name: `${action} invitation to Operations (client-west)`, + }), + ); + await waitFor(() => expect(request).toHaveBeenCalledTimes(1)); + expect(request).toHaveBeenCalledWith( + 'client-west', + expect.objectContaining({ expectedOrgID: 'org-a', retry: false }), + ); + expect( + action === 'Accept' ? declineMyInvitationMock : acceptMyInvitationMock, + ).not.toHaveBeenCalled(); + expect( + await screen.findByRole('group', { name: 'Invitation to Operations (client-east)' }), + ).toBeVisible(); + expect( + screen.queryByRole('group', { name: 'Invitation to Operations (client-west)' }), + ).not.toBeInTheDocument(); + expect(getOrgIDMock()).toBe('org-a'); + expect(inviteMemberMock).not.toHaveBeenCalled(); + expect(updateMemberRoleMock).not.toHaveBeenCalled(); + }, + ); + + it.each(['', 'client-east'])( + 'shows the ID once when the display name is %j', + async (orgDisplayName) => { + listMyInvitationsMock.mockResolvedValue([{ ...sameNamedInvitations()[0], orgDisplayName }]); + renderPanel(); + const invitation = await screen.findByRole('group', { name: 'Invitation to client-east' }); + expect(within(invitation).getByText('client-east')).toBeVisible(); + expect( + within(invitation).getByRole('button', { name: 'Accept invitation to client-east' }), + ).toBeEnabled(); + expect(invitation).not.toHaveTextContent('client-east (client-east)'); + expectNoWrites(); + }, + ); + it('renders loading skeleton first, then loaded content', async () => { const orgDeferred = deferred(); orgGetMock.mockReturnValueOnce(orgDeferred.promise); @@ -722,8 +806,16 @@ describe('Organization Access change safety', () => { setReadOnly(true); renderPanel(); await screen.findByText('Organization access is read-only for this session.'); - expect(screen.getByRole('button', { name: 'Accept' })).toBeDisabled(); - expect(screen.getByRole('button', { name: 'Decline' })).toBeDisabled(); + expect( + screen.getByRole('button', { + name: 'Accept invitation to Inviting Organization (inviting-org)', + }), + ).toBeDisabled(); + expect( + screen.getByRole('button', { + name: 'Decline invitation to Inviting Organization (inviting-org)', + }), + ).toBeDisabled(); expect(screen.queryByRole('textbox', { name: 'Invite user ID' })).not.toBeInTheDocument(); expect( screen.queryByText('Admin or owner role required to manage organization access.'), diff --git a/frontend-modern/src/utils/__tests__/organizationSettingsPresentation.test.ts b/frontend-modern/src/utils/__tests__/organizationSettingsPresentation.test.ts index 6cc68a7e3a..e0a54acf42 100644 --- a/frontend-modern/src/utils/__tests__/organizationSettingsPresentation.test.ts +++ b/frontend-modern/src/utils/__tests__/organizationSettingsPresentation.test.ts @@ -5,6 +5,7 @@ import { getOrganizationAccessMemberAddedMessage, getOrganizationAccessMemberRemovedMessage, getOrganizationAccessRoleUpdatedMessage, + getOrganizationInvitationPresentation, getOrganizationAddMemberErrorMessage, getOrganizationDisplayNameRequiredMessage, getOrganizationDisplayNameUpdateErrorMessage, @@ -40,6 +41,29 @@ import { } from '@/utils/organizationSettingsPresentation'; describe('organizationSettingsPresentation', () => { + it('keeps same-named invitation identities distinct in visible and accessible copy', () => { + for (const id of ['client-east', 'client-west']) { + expect(getOrganizationInvitationPresentation(id, 'Operations')).toEqual({ + organization: `Operations (${id})`, + groupLabel: `Invitation to Operations (${id})`, + acceptLabel: `Accept invitation to Operations (${id})`, + declineLabel: `Decline invitation to Operations (${id})`, + }); + } + }); + + it.each([undefined, '', 'client-east'])( + 'uses the invitation ID once for display name %j', + (displayName) => { + expect(getOrganizationInvitationPresentation('client-east', displayName)).toEqual({ + organization: 'client-east', + groupLabel: 'Invitation to client-east', + acceptLabel: 'Accept invitation to client-east', + declineLabel: 'Decline invitation to client-east', + }); + }, + ); + it('returns canonical multi-tenant fallback presentation', () => { expect(ORGANIZATION_SETTINGS_UNAVAILABLE_MESSAGE).toBe( 'Organization settings are not available on this server.', diff --git a/frontend-modern/src/utils/organizationSettingsPresentation.ts b/frontend-modern/src/utils/organizationSettingsPresentation.ts index 03b28936a1..24c4effd62 100644 --- a/frontend-modern/src/utils/organizationSettingsPresentation.ts +++ b/frontend-modern/src/utils/organizationSettingsPresentation.ts @@ -12,6 +12,16 @@ export function getOrganizationAccessReloadMessage(orgId: string): string { return `Reload checks saved members and invitations for ${orgId}. It does not repeat an access change.`; } +export function getOrganizationInvitationPresentation(orgId: string, displayName?: string) { + const organization = displayName && displayName !== orgId ? `${displayName} (${orgId})` : orgId; + return { + organization, + groupLabel: `Invitation to ${organization}`, + acceptLabel: `Accept invitation to ${organization}`, + declineLabel: `Decline invitation to ${organization}`, + }; +} + export const ORGANIZATION_SHARING_UNCONFIRMED_CHANGE_MESSAGE = 'The last sharing change could not be confirmed. Reload saved sharing before making another change.'; export const ORGANIZATION_SHARING_RELOAD_LABEL = 'Reload sharing';