Skip to content

Commit 7998775

Browse files
committed
test(studio): the sharing chip asks before it leaves a dirty matrix; the old pillar address's query reaches the redirect (#36905)
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QSeKYm19REy32icNSdWEsv
1 parent 718a9f8 commit 7998775

3 files changed

Lines changed: 50 additions & 4 deletions

File tree

‎.changeset/36905-permission-fullscreen.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ What the pillar drew around the matrix comes along: Discard draft, Explain acces
1313

1414
The organization-wide default sharing overview ("Who can see which records") is a page of its own, `/studio/PACKAGE/owd`, the Access group's menu entry; a set's per-object visibility badge opens it on that object (`?object=NAME`).
1515

16-
Old addresses keep working: `/studio/PACKAGE/access?surface=permission:NAME` redirects to the set's address, `?surface=owd:overview` to the overview, and a bare `/studio/PACKAGE/access` to the list of sets; other query parameters are kept. `/studio/PACKAGE/metadata/permission/NAME/history` opens the History tab. The cross-package leg (`/studio/~all/...`) keeps the matrix's environment page. No locale keys, props of published packages or exports change: the catalogue rows only the Access pillar read stay in `@object-ui/i18n`, unread.
16+
Old addresses keep working: `/studio/PACKAGE/access?surface=permission:NAME` redirects to the set's address (a set a read-only base's `.custom` pair adds, a "New similar" copy among them, to the pair's address, where it opens writable as the pillar opened it), `?surface=owd:overview` to the overview, and a bare `/studio/PACKAGE/access` to the list of sets; other query parameters are kept. `/studio/PACKAGE/metadata/permission/NAME/history` opens the History tab. The cross-package leg (`/studio/~all/...`) keeps the matrix's environment page. No locale keys, props of published packages or exports change: the catalogue rows only the Access pillar read stay in `@object-ui/i18n`, unread.

‎ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.accessPairCopy-29674.test.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,13 @@ describe('the retired pillar’s address of a set the pair adds opens it at the
383383
});
384384

385385
it('the address’s other parameters ride along through the surface', async () => {
386-
renderPillarAddress(COPY, '&changes=review');
386+
// A parameter no Studio page consumes (`?changes=review` is, by the surface: it opens the drawer).
387+
renderPillarAddress(COPY, '&ref=bookmark');
387388
await waitFor(
388-
() => expect(location()).toBe(`/studio/${PAIR}/metadata/permission/${COPY}?changes=review&package=${PAIR}`),
389+
() => expect(location()).toBe(`/studio/${PAIR}/metadata/permission/${COPY}?ref=bookmark&package=${PAIR}`),
389390
{ timeout: 8000 },
390391
);
392+
await copyOpen();
391393
});
392394

393395
it('CONTROL: the base’s own set’s old address stays on the base', async () => {

‎ui/packages/app-shell/src/views/studio-design/StudioPermissionSetPage.fullScreen-36905.test.tsx‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
* (objectui#12456): five tabs, Objects the landing, each other tab its
2121
* section, the facet panels kept mounted for the Save gate, the bulk strip
2222
* on every row with keyboard focus marking the row, CRUD granting the four
23-
* cells, and the sharing chip and the object count.
23+
* cells, and the sharing chip and the object count;
24+
* - the sharing chip leaves a dirty matrix only after the unsaved-edits
25+
* question: declined, the page stays on the set with the edit; confirmed,
26+
* it opens the overview; a clean matrix asks nothing (CONTROL).
2427
*/
2528

2629
import '@testing-library/jest-dom/vitest';
@@ -505,3 +508,44 @@ describe('the matrix\'s five sections on the page (objectui#12456)', () => {
505508
await waitFor(() => expect(where()).toBe(`/studio/${CUSTOM_PKG}/owd?object=crm_lead`));
506509
});
507510
});
511+
512+
/**
513+
* The sharing chip is a `role="button"` badge that calls `navigate()`: the
514+
* shell's link-click listener never sees it, so the page's own guard is all
515+
* that keeps a dirty matrix's edits (`confirmUnsavedLeave`).
516+
*/
517+
describe('the sharing chip asks before it leaves a dirty matrix (objectstack#36905)', () => {
518+
const editCell = () => screen.getByRole('checkbox', { name: `crm_lead ${en('perm.action.edit')}` });
519+
520+
async function openDirty() {
521+
mount(CUSTOM_PKG);
522+
await screen.findByTestId('perm-row-crm_lead', undefined, { timeout: 8000 });
523+
fireEvent.click(editCell());
524+
expect(editCell()).toBeChecked();
525+
}
526+
527+
it('declined, the page stays on the set and keeps the edit', async () => {
528+
await openDirty();
529+
window.confirm = vi.fn(() => false) as unknown as typeof window.confirm;
530+
fireEvent.click(screen.getByTestId('owd-badge-crm_lead'));
531+
expect(window.confirm).toHaveBeenCalledTimes(1);
532+
expect(window.confirm).toHaveBeenCalledWith(en('engine.edit.unsavedLeaveConfirm'));
533+
expect(where()).toBe(`/studio/${CUSTOM_PKG}/metadata/permission/${SET}?package=${CUSTOM_PKG}`);
534+
expect(editCell()).toBeChecked();
535+
});
536+
537+
it('confirmed, it opens the overview on its object', async () => {
538+
await openDirty();
539+
fireEvent.click(screen.getByTestId('owd-badge-crm_lead'));
540+
expect(window.confirm).toHaveBeenCalledTimes(1);
541+
await waitFor(() => expect(where()).toBe(`/studio/${CUSTOM_PKG}/owd?object=crm_lead`));
542+
});
543+
544+
it('CONTROL: a clean matrix asks nothing', async () => {
545+
mount(CUSTOM_PKG);
546+
await screen.findByTestId('perm-row-crm_lead', undefined, { timeout: 8000 });
547+
fireEvent.click(screen.getByTestId('owd-badge-crm_lead'));
548+
await waitFor(() => expect(where()).toBe(`/studio/${CUSTOM_PKG}/owd?object=crm_lead`));
549+
expect(window.confirm).not.toHaveBeenCalled();
550+
});
551+
});

0 commit comments

Comments
 (0)