diff --git a/docs/release-control/v6/internal/subsystems/organization-settings.md b/docs/release-control/v6/internal/subsystems/organization-settings.md index a65a68ae7c..bffa8874b0 100644 --- a/docs/release-control/v6/internal/subsystems/organization-settings.md +++ b/docs/release-control/v6/internal/subsystems/organization-settings.md @@ -15,6 +15,24 @@ ## Purpose +### Sharing drafts support native form submission + +The existing Create Share section is a named native form. Enter from a manual +resource field and activation of its submit button follow the same state-owner +creation path without navigating away. The manual-entry toggle remains a +non-submit button. The existing disabled fieldset and current-draft checks still +prevent incomplete drafts or repeat submissions during CSRF preparation and a +pending write from creating another grant. + +Recipient/resource choices, role, exact payload, reader and capability lifetime, +saved readback, uncertainty recovery and no-write-retry rules are unchanged. +Registered sharing-panel and real-client creation tests cover form semantics, +manual/quick-pick submission and pending/invalid drafts. Comparable desktop and +phone light/dark browser fixtures exercise native Enter, pointer creation and +read-only recovery through the production panel/state/API client. This is a +keyboard usability repair, not live authorization, original-client recovery or +release availability. + ### Pending User Access controls reflect the submitted draft While the existing role update is pending, each role checkbox, Close, Cancel diff --git a/frontend-modern/browser-verification/a8826886a4d7a87f.json b/frontend-modern/browser-verification/a8826886a4d7a87f.json new file mode 100644 index 0000000000..2d80b30b31 --- /dev/null +++ b/frontend-modern/browser-verification/a8826886a4d7a87f.json @@ -0,0 +1,35 @@ +{ + "version": 1, + "base_sha": "d0881f710d0eafffdd95c6726aebe4763a1467dc", + "verified_at": "2026-11-15T20:21:27Z", + "result": "passed", + "changed_paths": [ + "frontend-modern/src/components/Settings/OrganizationSharingCreateSection.tsx" + ], + "content_sha256": { + "frontend-modern/src/components/Settings/OrganizationSharingCreateSection.tsx": "e5a1e997241fdd595f5be470a2623d550b83a2e0e9911b2ea741db224d5e0c90" + }, + "routes": [ + "Settings > Organization Sharing (production panel/state/OrgsAPI/client/CSS in offline consuming fixture; not full App/IdP)" + ], + "viewports": [ + { + "width": 1440, + "height": 1000 + }, + { + "width": 390, + "height": 844 + } + ], + "states": [ + "Chromium141 and WebKit26; desktop-light/narrow-dark and desktop-dark/narrow-light. Playwright1.56.1 matches the integration lock. 40 native-inspected captures/20 pairs, copied to current lane output.", + "Comparable parent and candidate overview, ready manual draft, pending write, native-Enter result and unconfirmed change. Same safe fixtures, viewport/theme, locale/timezone and normalized camera anchor. Whole-page overview and full-state captures retain identities, roles, individual saved shares, status and actions." + ], + "interactions": [ + "Parent native Enter leaves the valid manual draft unchanged on all four configurations; the candidate dispatches its exact selected payload once and renders server-returned pending approval. Manual-entry toggles do not submit.", + "Pending controls remain natively disabled; repeated requestSubmit during the candidate pending write adds no request. Pointer creation remains usable. Encoded org/path, CSRF and session-only headers match the selected draft; existing outgoing and incoming rows remain intact.", + "A separate HTTP503 change withdraws the form into the existing unconfirmed warning. Explicit Reload sharing reads saved grants and never repeats the write. No page exceptions, unexpected API requests or horizontal overflow.", + "Fixture-only compiler, module-routing and cold-CSRF timing assertion failures were repaired before the successful before/after runs and retained in lane evidence. No production state/API/client behavior was mocked or changed; only resource inventory and HTTP responses are synthetic." + ] +} diff --git a/frontend-modern/src/components/Settings/OrganizationSharingCreateSection.tsx b/frontend-modern/src/components/Settings/OrganizationSharingCreateSection.tsx index c2f5bf63de..5db0ba4968 100644 --- a/frontend-modern/src/components/Settings/OrganizationSharingCreateSection.tsx +++ b/frontend-modern/src/components/Settings/OrganizationSharingCreateSection.tsx @@ -38,7 +38,14 @@ export const OrganizationSharingCreateSection: Component -
+
{ + event.preventDefault(); + void props.state.createShare(); + }} + class="p-4 sm:p-6" + >
- +
diff --git a/frontend-modern/src/components/Settings/__tests__/OrganizationSharingCreate.transport.test.tsx b/frontend-modern/src/components/Settings/__tests__/OrganizationSharingCreate.transport.test.tsx index 8642ea50a6..9929a81a35 100644 --- a/frontend-modern/src/components/Settings/__tests__/OrganizationSharingCreate.transport.test.tsx +++ b/frontend-modern/src/components/Settings/__tests__/OrganizationSharingCreate.transport.test.tsx @@ -214,10 +214,12 @@ function fillForm(entry: Entry, role: Role = 'viewer') { } function expectSavedGrant(entry: Entry, role: Role = 'viewer') { const payload = payloadFor(entry, role); + // A quick-pick draft also describes the same resource key. Assert the saved + // table row, not that still-visible draft description. const row = screen - .getAllByRole('row') - .find((candidate) => within(candidate).queryByText(`vm:${payload.resourceId}`)); - expect(row).toBeDefined(); + .getByText(`vm:${payload.resourceId}`, { exact: true, selector: 'tr bdi' }) + .closest('tr'); + expect(row).not.toBeNull(); expect(row).toHaveTextContent(payload.resourceName); expect(row).toHaveTextContent('Namesake organization'); // jsdom includes both responsive presentations; each must show the saved role. @@ -225,7 +227,11 @@ function expectSavedGrant(entry: Entry, role: Role = 'viewer') { const mobileAccess = within(row!).getByText('Access:').parentElement!; expect(within(mobileAccess).getByText(role, { exact: true })).toBeInTheDocument(); expect(row).toHaveTextContent('Pending approval'); - expect(within(row!).getByRole('button', { name: /^Remove share of / })).toBeEnabled(); + expect( + within(row!).getByRole('button', { + name: `Remove share of vm:${payload.resourceId} to ${target.displayName} (${target.id})`, + }), + ).toBeEnabled(); // This saved state comes from the actual dispatched body, not the intended // fixture choice. A wrong callback must produce a wrong saved grant. expect(outgoing).toHaveLength(1); @@ -301,6 +307,34 @@ afterEach(async () => { }); describe('rendered Create Share controls through the real transport', () => { + it.each(entries)('submits the %s draft through its named native form once', async (entry) => { + await openPanel(); + fillForm(entry, 'editor'); + const form = screen.getByRole('form', { name: 'Create Share' }); + expect(createButton()).toHaveAttribute('type', 'submit'); + expect(fireEvent.submit(form)).toBe(false); // Never navigate away from the saved view. + await waitFor(() => expect(inventoryReads()).toHaveLength(10)); + await screen.findByRole('heading', { name: 'Outgoing Shares' }); + expectWrite(entry, 'editor'); + expectSavedGrant(entry, 'editor'); + }); + + it('keeps incomplete drafts and manual-entry toggles from submitting a grant', async () => { + await openPanel(); + const form = screen.getByRole('form', { name: 'Create Share' }); + expect(fireEvent.submit(form)).toBe(false); + expect(writes()).toHaveLength(0); + expect(healthReads()).toHaveLength(0); + expect(createButton()).toBeDisabled(); + for (const name of ['Enter manually', 'Hide manual entry']) { + const toggle = screen.getByRole('button', { name }); + expect(toggle).toHaveAttribute('type', 'button'); + fireEvent.click(toggle); + expect(writes()).toHaveLength(0); + expect(inventoryReads()).toHaveLength(5); + } + }); + it('identifies every namesake option by its full saved key without choosing for the reader', async () => { await openPanel(); const destinations = Array.from((targetInput() as HTMLSelectElement).options); @@ -437,7 +471,10 @@ describe('rendered Create Share controls through the real transport', () => { expect(resourceInput()).toHaveAccessibleDescription( `Resource: Namesake workload ยท vm:${selectedResourceID}`, ); - for (const input of screen.getAllByRole('combobox')) expect(input).toBeDisabled(); + // These are the submitted form's native selects, not every role in the + // saved inventories. Keep the disabled-control proof local to its owner. + for (const input of saving.closest('form')!.querySelectorAll('select')) + expect(input).toBeDisabled(); fireEvent.click(saving); expect(writes()).toHaveLength(1); expect(notices.success).not.toHaveBeenCalled(); @@ -580,16 +617,22 @@ describe('rendered Create Share controls through the real transport', () => { document.cookie = 'pulse_csrf=; Max-Age=0; Path=/'; await openPanel(); fillForm('manual entry', 'admin'); - fireEvent.click(createButton()); + const form = screen.getByRole('form', { name: 'Create Share' }); + fireEvent.submit(form); await waitFor(() => expect(healthReads()).toHaveLength(1)); expect(writes()).toHaveLength(0); for (const input of [...screen.getAllByRole('combobox'), ...screen.getAllByRole('textbox')]) expect(input).toBeDisabled(); expect(screen.getByRole('button', { name: 'Saving...' })).toBeDisabled(); + fireEvent.submit(form); + expect(healthReads()).toHaveLength(1); + expect(writes()).toHaveLength(0); document.cookie = `pulse_csrf=${csrf}; Path=/`; health.resolve(json({})); await waitFor(() => expect(writes()).toHaveLength(1)); expectWrite('manual entry', 'admin'); + fireEvent.submit(form); + expectWrite('manual entry', 'admin'); reply.resolve(new Response(null, { status: 204 })); await waitFor(() => expect(inventoryReads()).toHaveLength(10)); await screen.findByRole('heading', { name: 'Outgoing Shares' }); diff --git a/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsx index 28137e144f..6b9caed5b8 100644 --- a/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsx +++ b/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsx @@ -184,6 +184,24 @@ afterEach(() => { }); describe('OrganizationSharingPanel', () => { + it('names the native creation form and keeps manual-entry toggles non-submitting', async () => { + renderPanel(); + const form = await screen.findByRole('form', { name: 'Create Share' }); + const create = screen.getByRole('button', { name: 'Create Share' }); + expect(create.closest('form')).toBe(form); + expect(create).toHaveAttribute('type', 'submit'); + expect(create).toBeDisabled(); + const toggle = screen.getByRole('button', { name: 'Enter manually' }); + expect(toggle.closest('form')).toBe(form); + expect(toggle).toHaveAttribute('type', 'button'); + fireEvent.click(toggle); + expect(screen.getByRole('button', { name: 'Hide manual entry' })).toHaveAttribute( + 'type', + 'button', + ); + expect(createShareMock).not.toHaveBeenCalled(); + }); + it('renders loading skeleton first, then loaded content', async () => { const orgDeferred = deferred(); orgGetMock.mockReturnValueOnce(orgDeferred.promise); @@ -411,7 +429,15 @@ describe('OrganizationSharingPanel', () => { expect(key.closest('td')).toHaveTextContent('viewer'); } - fireEvent.click(screen.getByRole('button', { name: /^Accept share of / })); + const incomingAction = (action: 'Accept' | 'Decline') => + screen.getByLabelText(`${action} share of view:alerts-high-cpu from Organization B (org-b)`, { + selector: 'button', + }); + expect(incomingAction('Accept')).toHaveAccessibleName( + 'Accept share of view:alerts-high-cpu from Organization B (org-b)', + ); + expect(incomingAction('Accept')).toBeVisible(); + fireEvent.click(incomingAction('Accept')); await waitFor(() => { expect(acceptIncomingShareMock).toHaveBeenCalledWith( @@ -422,12 +448,14 @@ describe('OrganizationSharingPanel', () => { }); await waitFor(() => { - expect( - (screen.getByRole('button', { name: /^Decline share of / }) as HTMLButtonElement).disabled, - ).toBe(false); + expect(incomingAction('Decline')).toBeEnabled(); }); - fireEvent.click(screen.getByRole('button', { name: /^Decline share of / })); + expect(incomingAction('Decline')).toHaveAccessibleName( + 'Decline share of view:alerts-high-cpu from Organization B (org-b)', + ); + expect(incomingAction('Decline')).toBeVisible(); + fireEvent.click(incomingAction('Decline')); await waitFor(() => { expect(declineIncomingShareMock).toHaveBeenCalledWith( diff --git a/frontend-modern/src/components/Settings/__tests__/OrganizationSharingRows.transport.test.tsx b/frontend-modern/src/components/Settings/__tests__/OrganizationSharingRows.transport.test.tsx index b97a83d4a9..f990dc0bbb 100644 --- a/frontend-modern/src/components/Settings/__tests__/OrganizationSharingRows.transport.test.tsx +++ b/frontend-modern/src/components/Settings/__tests__/OrganizationSharingRows.transport.test.tsx @@ -144,10 +144,11 @@ let memberIsViewer: boolean; let reload: ReturnType> | undefined; function rowFor(share: OrganizationShare): HTMLElement { - const section = screen.getByRole('heading', { - name: share.resourceId.startsWith('outgoing::') ? 'Outgoing Shares' : 'Incoming Shares', - }).parentElement!; - const row = within(section).getByText(`${share.resourceType}:${share.resourceId}`).closest('tr'); + // The exact saved resource key uniquely identifies this fixture's row. Avoid + // repeating whole-panel accessibility walks for every namesake assertion. + const row = screen + .getByText(`${share.resourceType}:${share.resourceId}`, { exact: true, selector: 'bdi' }) + .closest('tr'); expect(row).not.toBeNull(); return row!; } @@ -363,22 +364,23 @@ describe('rendered namesake sharing rows through the real transport', () => { const name = directory.find((org) => org.id === share.targetOrgId)!.displayName; expect(within(row).getByText(name, { exact: true })).toBeInTheDocument(); expect(within(row).getByText(share.targetOrgId, { exact: true }).tagName).toBe('BDI'); - expect( - within(row).getByRole('button', { - name: `Remove share of vm:${share.resourceId} to ${name} (${share.targetOrgId})`, - }), - ).toBeEnabled(); + const label = `Remove share of vm:${share.resourceId} to ${name} (${share.targetOrgId})`; + const action = within(row).getByLabelText(label, { selector: 'button' }); + expect(action).toHaveAccessibleName(label); + expect(action).toBeVisible(); + expect(action).toBeEnabled(); } for (const share of incoming) { const row = rowFor(share); expect(within(row).getByText(share.sourceOrgName, { exact: true })).toBeInTheDocument(); expect(within(row).getByText(share.sourceOrgId, { exact: true }).tagName).toBe('BDI'); - for (const action of ['Accept', 'Decline']) - expect( - within(row).getByRole('button', { - name: `${action} share of vm:${share.resourceId} from ${share.sourceOrgName} (${share.sourceOrgId})`, - }), - ).toBeEnabled(); + for (const verb of ['Accept', 'Decline']) { + const label = `${verb} share of vm:${share.resourceId} from ${share.sourceOrgName} (${share.sourceOrgId})`; + const action = within(row).getByLabelText(label, { selector: 'button' }); + expect(action).toHaveAccessibleName(label); + expect(action).toBeVisible(); + expect(action).toBeEnabled(); + } } }; expectIdentities();