Identify exact organizations in Billing Admin controls (#4509)

**Identify exact organizations in Billing Admin controls**

Name subscription and reload actions with the displayed name and saved
ID. Connect each details toggle to its named expanded region while
retaining inventory status badges, read gates and billing transport.

Contract-Neutral: Accessibility labels and disclosure relationships
only; existing billing values, requests, permissions, actions and
visible information are unchanged.

**Scope failed billing reload checks to the affected row**

Both the failed inventory row and expanded details name their reload
with the same exact organization. Exercise the original row recovery
control without an ambiguous global query, and assert the recovered read
still targets that saved ID without a write.

Contract-Neutral: Test-only query scoping for existing Billing Admin
recovery controls; runtime, transport, permissions and visible content
are unchanged.

---
Fleet candidate `20261116T184813Z-web-product` from the `web-product`
lane. Reviewed tip `7648c8e95f7b1f26be886f7b112d23b475cb9cf5` on `main`.

[How Pulse handles
triage](https://github.com/rcourtman/Pulse/blob/main/docs/AI_TRANSPARENCY.md)
This commit is contained in:
pulse-triage[bot] authored and GitHub committed 2026-11-16 20:50:08 +00:00
commit 7dfb7bec8e
5 files changed
+237 -22

No files matched your search

@@ -0,0 +1,37 @@
{
"version": 1,
"base_sha": "85601faf3a51593467186d10d0cf347cce9591f5",
"verified_at": "2026-11-16T17:41:35Z",
"result": "passed",
"changed_paths": [
"frontend-modern/src/components/Settings/BillingAdminOrganizationsTable.tsx"
],
"content_sha256": {
"frontend-modern/src/components/Settings/BillingAdminOrganizationsTable.tsx": "c8ec42a12ce6543a33ddb7e82481a918e43f330e1ac906a390ae1330efc5b50f"
},
"routes": [
"/ (offline fixture consuming existing Settings > Billing Admin panel, state owner, stores and real HTTP client)"
],
"viewports": [
{
"width": 1440,
"height": 1000
},
{
"width": 390,
"height": 844
}
],
"states": [
"Two organizations sharing one display name but different opaque IDs, with accepted Trial and Active billing states; collapsed row actions and expanded billing JSON.",
"Selected-row read failed and recovered; read-only gates. Desktop light and phone light/dark in Chromium; phone light in WebKit.",
"Suspended and soft-deleted inventory badge labels remain in final accessible details names; supplemental DOM interaction checks, not additional capture states."
],
"interactions": [
"52 baseline checks on base 85601faf and 64 repaired checks through real consuming panel with safe synthetic HTTP responses.",
"Keyboard Enter suspends then reactivates only the non-first namesake. Only the two explicit encoded-ID PUT requests occur; payload fields and sibling state retained.",
"Expand/collapse selected organization; aria-expanded tracks visibility, aria-controls identifies one exact named region; selected details reload and failed-row retry read only that ID.",
"Read-only disables all subscription writes; no stored-token fallback on billing and health endpoints. Runtime-capability bootstrap retains its ordinary stored-token behavior.",
"12 comparable before/after pairs retained in current outcome archives. Actual image content reviewed with native view_image; visible fields, identities, statuses, JSON and controls retained without layout change. No screen-reader, full App, installed paid journey or release claim."
]
}
@@ -1,4 +1,4 @@
import { Show, type Component } from 'solid-js';
import { Show, createUniqueId, type Component } from 'solid-js';
import { Button } from '@/components/shared/Button';
import { PulseDataGrid } from '@/components/shared/PulseDataGrid';
import { useBreakpoint } from '@/hooks/useBreakpoint';
@@ -36,6 +36,17 @@ export const BillingAdminOrganizationsTable: Component<BillingAdminOrganizations
props,
) => {
const { isMobile } = useBreakpoint();
const tableID = createUniqueId();
const detailsID = (orgID: string) => `${tableID}-billing-${encodeURIComponent(orgID)}`;
const organizationLabel = (org: HostedOrganizationSummary) =>
org.display_name && org.display_name !== org.org_id
? `${org.display_name} (${org.org_id})`
: org.org_id;
const detailsLabel = (org: HostedOrganizationSummary) =>
[
`Billing details for ${organizationLabel(org)}`,
...getBillingAdminOrganizationBadges(org).map((badge) => badge.label),
].join(', ');
const unreadLabel = (orgID: string) =>
props.billingLoadingByOrgID[orgID] ? 'Loading' : 'Unavailable';
const actionsDisabled = (orgID: string) =>
@@ -44,7 +55,8 @@ export const BillingAdminOrganizationsTable: Component<BillingAdminOrganizations
!!props.billingErrorByOrgID[orgID] ||
props.savingByOrgID[orgID] ||
props.billingLoadingByOrgID[orgID];
const subscriptionActions = (orgID: string) => {
const subscriptionActions = (org: HostedOrganizationSummary) => {
const orgID = (org.org_id || '').trim();
const currentSubState = () =>
(props.billingByOrgID[orgID]?.subscription_state || '').toLowerCase();
return (
@@ -52,6 +64,7 @@ export const BillingAdminOrganizationsTable: Component<BillingAdminOrganizations
<Button
variant="secondary"
size="sm"
aria-label={`Suspend Org for ${organizationLabel(org)}`}
onClick={() => props.onSuspendOrganization(orgID)}
disabled={actionsDisabled(orgID) || currentSubState() === 'suspended'}
>
@@ -60,6 +73,7 @@ export const BillingAdminOrganizationsTable: Component<BillingAdminOrganizations
<Button
variant="secondary"
size="sm"
aria-label={`Activate Org for ${organizationLabel(org)}`}
onClick={() => props.onActivateOrganization(orgID)}
disabled={actionsDisabled(orgID) || currentSubState() === 'active'}
>
@@ -84,6 +98,9 @@ export const BillingAdminOrganizationsTable: Component<BillingAdminOrganizations
<button
type="button"
class="text-left w-full whitespace-normal [overflow-wrap:anywhere]"
aria-label={detailsLabel(org)}
aria-expanded={props.expandedOrgID === orgID}
aria-controls={props.expandedOrgID === orgID ? detailsID(orgID) : undefined}
onClick={() => {
props.onToggleOrganization(orgID);
}}
@@ -132,14 +149,14 @@ export const BillingAdminOrganizationsTable: Component<BillingAdminOrganizations
<Button
variant="secondary"
size="xs"
aria-label={`Reload billing for ${org.display_name || orgID}`}
aria-label={`Reload billing for ${organizationLabel(org)}`}
onClick={() => props.onReloadOrganization(orgID)}
disabled={props.billingLoadingByOrgID[orgID] || props.savingByOrgID[orgID]}
>
Reload billing
</Button>
</Show>
<Show when={isMobile()}>{subscriptionActions(orgID)}</Show>
<Show when={isMobile()}>{subscriptionActions(org)}</Show>
</div>
);
},
@@ -176,7 +193,7 @@ export const BillingAdminOrganizationsTable: Component<BillingAdminOrganizations
label: 'Actions',
hiddenOnMobile: true,
align: 'right',
render: (org) => <Show when={!isMobile()}>{subscriptionActions(org.org_id)}</Show>,
render: (org) => <Show when={!isMobile()}>{subscriptionActions(org)}</Show>,
},
]}
keyExtractor={(org) => org.org_id}
@@ -184,13 +201,19 @@ export const BillingAdminOrganizationsTable: Component<BillingAdminOrganizations
expandedRender={(org) => {
const orgID = (org.org_id || '').trim();
return (
<div class="px-3 pb-3 bg-surface-alt whitespace-normal">
<div
id={detailsID(orgID)}
role="region"
aria-label={detailsLabel(org)}
class="px-3 pb-3 bg-surface-alt whitespace-normal"
>
<div class="rounded-md border border-border bg-surface-alt p-3">
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-2">
<div class="text-xs font-semibold text-muted">Billing state JSON</div>
<Button
variant="secondary"
size="xs"
aria-label={`Reload billing for ${organizationLabel(org)}`}
disabled={props.billingLoadingByOrgID[orgID] || props.savingByOrgID[orgID]}
onClick={() => {
props.onReloadOrganization(orgID);
@@ -130,7 +130,7 @@ const writes = () => requests.filter(({ init }) => init.method === 'PUT');
const healthReads = () => requests.filter(({ url }) => url === '/api/health');
const row = (id = selectedID) => screen.getByText(id, { exact: true }).closest('tr')!;
const action = (name: 'Suspend Org' | 'Activate Org', id = selectedID) =>
within(row(id)).getByRole('button', { name });
screen.getByRole('button', { name: `${name} for Same organization name (${id})` });
const loaded = async () => {
await waitFor(() => expect(action('Suspend Org')).toBeEnabled());
expect(action('Suspend Org', firstID)).toBeEnabled();
@@ -220,6 +220,79 @@ afterEach(() => {
});
describe('Billing Admin rendered controls through real HTTP', () => {
it.each([1440, 390])(
'names each namesake action and exposes its exact expanded billing region at width %i',
async (width) => {
Object.defineProperty(window, 'innerWidth', { configurable: true, value: width });
render(() => <BillingAdminPanel />);
await loaded();
const details = (id: string) =>
screen.getByRole('button', {
name: `Billing details for Same organization name (${id})`,
});
for (const id of [firstID, selectedID]) {
expect(action('Suspend Org', id)).toBeEnabled();
expect(action('Activate Org', id)).toHaveTextContent('Activate Org');
expect(details(id)).toHaveAttribute('aria-expanded', 'false');
expect(details(id)).not.toHaveAttribute('aria-controls');
}
fireEvent.click(details(firstID));
const firstRegion = screen.getByRole('region', {
name: `Billing details for Same organization name (${firstID})`,
});
expect(details(firstID)).toHaveAttribute('aria-controls', firstRegion.id);
expect(details(firstID)).toHaveAttribute('aria-expanded', 'true');
fireEvent.click(details(selectedID));
const selectedRegion = screen.getByRole('region', {
name: `Billing details for Same organization name (${selectedID})`,
});
expect(details(selectedID)).toHaveAttribute('aria-controls', selectedRegion.id);
expect(details(selectedID)).toHaveAttribute('aria-expanded', 'true');
expect(selectedRegion.id).not.toBe(firstRegion.id);
expect(firstRegion).not.toBeInTheDocument();
expect(details(firstID)).toHaveAttribute('aria-expanded', 'false');
expect(details(firstID)).not.toHaveAttribute('aria-controls');
expect(selectedRegion).toHaveTextContent('saved-selected-plan');
fireEvent.click(
screen.getByRole('button', {
name: `Reload billing for Same organization name (${selectedID})`,
}),
);
await waitFor(() => expect(reads(selectedID)).toHaveLength(2));
await waitFor(() => expect(action('Suspend Org')).toBeEnabled());
expect(reads(firstID)).toHaveLength(1);
expect(writes()).toHaveLength(0);
expectAuthRetained();
fireEvent.click(details(selectedID));
expect(details(selectedID)).toHaveAttribute('aria-expanded', 'false');
expect(details(selectedID)).not.toHaveAttribute('aria-controls');
expect(selectedRegion).not.toBeInTheDocument();
},
);
it('distinguishes failed namesake reads by ID and reloads only the named organization', async () => {
readReply = () => json({ error: 'synthetic-unavailable' }, 503);
render(() => <BillingAdminPanel />);
await waitFor(() => expect(screen.getAllByRole('alert')).toHaveLength(2));
const reload = (id: string) =>
screen.getByRole('button', {
name: `Reload billing for Same organization name (${id})`,
});
expect(reload(firstID)).toBeEnabled();
expect(reload(selectedID)).toBeEnabled();
readReply = (id) => json(states[id]);
fireEvent.click(reload(selectedID));
await waitFor(() => expect(action('Suspend Org')).toBeEnabled());
expect(reads(selectedID)).toHaveLength(2);
expect(reads(firstID)).toHaveLength(1);
expect(action('Suspend Org', firstID)).toBeDisabled();
expect(within(row(firstID)).getByRole('alert')).toHaveTextContent(BILLING_ADMIN_READ_ERROR);
expect(writes()).toHaveLength(0);
expectAuthRetained();
});
it.each([1440, 390])(
'suspends and reactivates only the non-first namesake organization at width %i',
async (width) => {
@@ -74,6 +74,62 @@ describe('BillingAdminPanel', () => {
cleanup();
});
it.each([
{ suspended: true, soft_deleted: false, badge: 'suspended' },
{ suspended: true, soft_deleted: true, badge: 'soft-deleted' },
])('retains the $badge inventory badge in the details name', async (status) => {
listOrganizationsMock.mockResolvedValue([
{
org_id: 'org-1',
display_name: 'Org One',
owner_user_id: 'user-1',
created_at: '2024-01-01T00:00:00Z',
suspended: status.suspended,
soft_deleted: status.soft_deleted,
},
]);
getBillingStateMock.mockResolvedValue({
capabilities: [],
limits: {},
subscription_state: 'suspended',
});
render(() => <BillingAdminPanel />);
const name = `Billing details for Org One (org-1), ${status.badge}`;
const details = await screen.findByRole('button', { name });
expect(details).toHaveTextContent(status.badge);
await fireEvent.click(details);
expect(screen.getByRole('region', { name })).toHaveAttribute(
'id',
details.getAttribute('aria-controls'),
);
});
it.each(['', 'org-1'])('uses the exact ID once when the display name is %j', async (name) => {
listOrganizationsMock.mockResolvedValue([
{
org_id: 'org-1',
display_name: name,
owner_user_id: 'user-1',
created_at: '2024-01-01T00:00:00Z',
suspended: false,
soft_deleted: false,
},
]);
getBillingStateMock.mockResolvedValue({
capabilities: [],
limits: {},
subscription_state: 'active',
});
render(() => <BillingAdminPanel />);
const suspend = await screen.findByRole('button', { name: 'Suspend Org for org-1' });
await waitFor(() => expect(suspend).toBeEnabled());
expect(screen.getByRole('button', { name: 'Activate Org for org-1' })).toBeDisabled();
await fireEvent.click(screen.getByRole('button', { name: 'Billing details for org-1' }));
expect(screen.getByRole('region', { name: 'Billing details for org-1' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Reload billing for org-1' })).toBeEnabled();
expect(putBillingStateMock).not.toHaveBeenCalled();
});
it('does not fabricate plan_version from subscription state when billing state has no plan', async () => {
const stateWithoutPlan = {
capabilities: ['multi_tenant'],
@@ -93,7 +149,7 @@ describe('BillingAdminPanel', () => {
expect(screen.getByText('Org One')).toBeInTheDocument();
});
await fireEvent.click(screen.getByRole('button', { name: 'Suspend Org' }));
await fireEvent.click(screen.getByRole('button', { name: 'Suspend Org for Org One (org-1)' }));
await waitFor(() => {
expect(putBillingStateMock).toHaveBeenCalledTimes(1);
@@ -123,7 +179,7 @@ describe('BillingAdminPanel', () => {
expect(screen.getByText('Org One')).toBeInTheDocument();
});
await fireEvent.click(screen.getByRole('button', { name: 'Suspend Org' }));
await fireEvent.click(screen.getByRole('button', { name: 'Suspend Org for Org One (org-1)' }));
await waitFor(() => {
expect(putBillingStateMock).toHaveBeenCalledTimes(1);
@@ -155,13 +211,19 @@ describe('BillingAdminPanel', () => {
});
putBillingStateMock.mockImplementation(async (_orgID, payload) => payload);
render(() => <BillingAdminPanel />);
await waitFor(() => expect(screen.getByRole('button', { name: 'Suspend Org' })).toBeEnabled());
expect(screen.getAllByRole('button', { name: 'Suspend Org' })).toHaveLength(1);
expect(screen.getAllByRole('button', { name: 'Activate Org' })).toHaveLength(1);
expect(screen.getByRole('button', { name: 'Suspend Org' }).closest('td')).toHaveTextContent(
'Active',
await waitFor(() =>
expect(screen.getByRole('button', { name: 'Suspend Org for Org One (org-1)' })).toBeEnabled(),
);
await fireEvent.click(screen.getByRole('button', { name: 'Suspend Org' }));
expect(screen.getAllByRole('button', { name: 'Suspend Org for Org One (org-1)' })).toHaveLength(
1,
);
expect(
screen.getAllByRole('button', { name: 'Activate Org for Org One (org-1)' }),
).toHaveLength(1);
expect(
screen.getByRole('button', { name: 'Suspend Org for Org One (org-1)' }).closest('td'),
).toHaveTextContent('Active');
await fireEvent.click(screen.getByRole('button', { name: 'Suspend Org for Org One (org-1)' }));
await waitFor(() => expect(putBillingStateMock).toHaveBeenCalledTimes(1));
expect(putBillingStateMock.mock.calls[0][0]).toBe('org-1');
expect(putBillingStateMock.mock.calls[0][1].subscription_state).toBe('suspended');
@@ -1,6 +1,6 @@
import { createSignal } from 'solid-js';
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 { BillingAdminPanel } from '../BillingAdminPanel';
import {
BILLING_ADMIN_READ_ERROR,
@@ -106,16 +106,28 @@ describe('Billing Admin accepted inventory and billing reads', () => {
mocks.get.mockReturnValueOnce(pending.promise);
render(() => <BillingAdminPanel />);
await waitFor(() => expect(mocks.get).toHaveBeenCalledTimes(1));
expect(screen.getByRole('button', { name: 'Suspend Org' })).toBeDisabled();
expect(screen.getByRole('button', { name: 'Activate Org' })).toBeDisabled();
expect(
screen.getByRole('button', { name: 'Suspend Org for Organization org-a (org-a)' }),
).toBeDisabled();
expect(
screen.getByRole('button', { name: 'Activate Org for Organization org-a (org-a)' }),
).toBeDisabled();
expect(screen.queryByText('N/A')).not.toBeInTheDocument();
pending.resolve(billing());
await waitFor(() => expect(screen.getByRole('button', { name: 'Suspend Org' })).toBeEnabled());
await waitFor(() =>
expect(
screen.getByRole('button', { name: 'Suspend Org for Organization org-a (org-a)' }),
).toBeEnabled(),
);
});
it('removes the former inventory on refresh and distinguishes failure from an empty inventory', async () => {
render(() => <BillingAdminPanel />);
await waitFor(() => expect(screen.getByRole('button', { name: 'Suspend Org' })).toBeEnabled());
await waitFor(() =>
expect(
screen.getByRole('button', { name: 'Suspend Org for Organization org-a (org-a)' }),
).toBeEnabled(),
);
const pending = deferred<unknown>();
mocks.list.mockReturnValueOnce(pending.promise);
await fireEvent.click(screen.getByRole('button', { name: 'Refresh' }));
@@ -165,15 +177,23 @@ describe('Billing Admin accepted inventory and billing reads', () => {
await settle();
expect(mocks.get).toHaveBeenCalledTimes(2);
expect(screen.queryByText(/SYNTHETIC PRIVATE/)).not.toBeInTheDocument();
await fireEvent.click(screen.getByRole('button', { name: 'Organization org-a org-a' }));
await fireEvent.click(
screen.getByRole('button', { name: 'Billing details for Organization org-a (org-a)' }),
);
expect(screen.getByRole('status')).toHaveTextContent(BILLING_ADMIN_READ_ERROR);
expect(screen.queryByText(/"loading": true/)).not.toBeInTheDocument();
const before = mocks.put.mock.calls.length;
// The failed row and its expanded details both offer reload for the same organization.
const failedRow = screen.getByRole('alert').closest('tr');
expect(failedRow).not.toBeNull();
await fireEvent.click(
screen.getByRole('button', { name: 'Reload billing for Organization org-a' }),
within(failedRow!).getByRole('button', {
name: 'Reload billing for Organization org-a (org-a)',
}),
);
await waitFor(() => expect(screen.queryByRole('alert')).not.toBeInTheDocument());
expect(mocks.get).toHaveBeenCalledTimes(3);
expect(mocks.get.mock.calls.map(([orgID]) => orgID)).toEqual(['org-a', 'org-b', 'org-a']);
expect(mocks.put).toHaveBeenCalledTimes(before);
});