mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-30 17:42:32 +01:00
Support native keyboard submission in Create Share (#4456)
**Support native keyboard submission in Create Share** Use the same guarded creation path for Enter and the submit button. Keep manual-entry toggles non-submitting and preserve pending controls, exact selected payloads and saved readback. Cover native semantics and invalid/pending submissions through the existing registered panel and real-client transport suites. **Scope saved sharing assertions to their exact controls** The first containing five-file run reported three five-second test timeouts. Keep the existing deadlines, transport/body/readback assertions and namesake coverage, while avoiding repeated whole-panel role walks for known saved keys and explicitly labelled actions. Retain the failed source-zxtyc2ob receipt. Contract-Neutral: Test-query scoping only; production runtime, rendered information, requests, authorization and the existing own-parent browser receipt remain unchanged. **Distinguish saved share rows from quick-pick descriptions in tests** The containing source-66pt_q6j run completed with 174 passes and ten identical multiple-element query failures. Scope the exact resource-key assertion to a saved table row; keep draft descriptions, saved-state and transport assertions, test deadlines and production runtime unchanged. Preserve the failed receipt and both retained commits. Contract-Neutral: Test lookup correction only; no runtime, rendered information, request, authorization or own-parent browser receipt change. --- Fleet candidate `20261115T210933Z-web-product` from the `web-product` lane. Reviewed tip `a169c8fc071ee73840e3517a40f5c8c206a6e38c` on `main`. [How Pulse handles triage](https://github.com/rcourtman/Pulse/blob/main/docs/AI_TRANSPARENCY.md)
This commit is contained in:
@@ -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
|
||||
|
||||
35
frontend-modern/browser-verification/a8826886a4d7a87f.json
Normal file
35
frontend-modern/browser-verification/a8826886a4d7a87f.json
Normal file
@@ -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."
|
||||
]
|
||||
}
|
||||
@@ -38,7 +38,14 @@ export const OrganizationSharingCreateSection: Component<OrganizationSharingCrea
|
||||
return (
|
||||
<>
|
||||
<Show when={props.state.canManageCurrentOrg()}>
|
||||
<div class="p-4 sm:p-6">
|
||||
<form
|
||||
aria-label="Create Share"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
void props.state.createShare();
|
||||
}}
|
||||
class="p-4 sm:p-6"
|
||||
>
|
||||
<fieldset
|
||||
disabled={props.state.saving()}
|
||||
class="rounded-md border border-border p-3 space-y-2 sm:p-4 sm:space-y-3"
|
||||
@@ -151,6 +158,7 @@ export const OrganizationSharingCreateSection: Component<OrganizationSharingCrea
|
||||
Choose a discovered resource, or switch to manual entry.
|
||||
</p>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="xs"
|
||||
class="text-blue-700 hover:text-blue-800 dark:text-blue-300 dark:hover:text-blue-200"
|
||||
@@ -231,17 +239,17 @@ export const OrganizationSharingCreateSection: Component<OrganizationSharingCrea
|
||||
|
||||
<div class="flex justify-end">
|
||||
<Button
|
||||
type="submit"
|
||||
variant="primary"
|
||||
size="settingsAction"
|
||||
class="w-full sm:w-auto"
|
||||
onClick={props.state.createShare}
|
||||
disabled={!props.state.canCreateShare()}
|
||||
>
|
||||
{props.state.saving() ? 'Saving...' : 'Create Share'}
|
||||
</Button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</form>
|
||||
</Show>
|
||||
|
||||
<Show when={!props.state.canManageCurrentOrg() && !props.state.readOnly()}>
|
||||
|
||||
@@ -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' });
|
||||
|
||||
@@ -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<typeof baseOrg>();
|
||||
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(
|
||||
|
||||
@@ -144,10 +144,11 @@ let memberIsViewer: boolean;
|
||||
let reload: ReturnType<typeof deferred<Response>> | 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();
|
||||
|
||||
Reference in New Issue
Block a user