Skip to content

Commit a3088d0

Browse files
committed
test(organizations): the update-mode preview pin answers a re-point as its write does
update-repoint-organization-wall.test.ts pinned the preview's wall-blind answer, the very defect the write-wall verdict closes: an admitted re-point reported as dropped, a refused one admitted. It now pins the preview against the write: no drop for the admitted re-point, and the write's PERMISSION_DENIED code and message under organization_id for the refused one. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0157EiYDGYnrsXE9aHv1uMxU
1 parent 0cc6f29 commit a3088d0

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

‎packages/plugins/organizations/src/update-repoint-organization-wall.test.ts‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@
4949
* crossing the wall, a tenancy-disabled object, and `preserveAudit`, whose
5050
* update-only exemption never reaches `organization_id`. A system context
5151
* never met the strip.
52-
* - The `update`-mode `validate()` preview runs no middleware, so it is
53-
* wall-blind: it still reports the drop of an admitted re-point.
52+
* - The `update`-mode `validate()` preview runs no middleware, so it was
53+
* wall-blind: it reported the drop of an admitted re-point and admitted a
54+
* refused one. It now reads the wall's own per-row verdict (#25062), and
55+
* answers a re-point as its write does.
5456
*/
5557

5658
import { describe, it, expect, afterEach, vi } from 'vitest';
@@ -578,17 +580,29 @@ describe('[#24822] where no wall judges the column, the update strip takes the r
578580
});
579581
});
580582

581-
describe('[#24822] the `update`-mode validate() preview is wall-blind (it runs no middleware)', () => {
582-
it('it still reports an admitted re-point as dropped, while the write stores it; and a refused one as dropped, while the write refuses it', async () => {
583+
describe('[#24822][#25062] the `update`-mode validate() preview answers a re-point as its write does', () => {
584+
it('an admitted re-point is reported as no drop, and the write stores it; a refused one is refused by both, with the write\'s code and message', async () => {
583585
const b = await boot('group');
584586

585587
const admitted = await b.engine.validate(INJECTED, { id: 'r1', organization_id: SISTER_ORG }, { mode: 'update', context: GROUP_CTX as never });
586588
const refused = await b.engine.validate(INJECTED, { id: 'r1', organization_id: FOREIGN_ORG }, { mode: 'update', context: GROUP_CTX as never });
587589

588-
expect(admitted.results[0]?.droppedFields).toEqual(READONLY_DROP(INJECTED));
589-
expect(refused.results[0]?.droppedFields).toEqual(READONLY_DROP(INJECTED));
590+
expect(admitted.valid).toBe(true);
591+
expect(admitted.results[0]?.droppedFields).toBeUndefined();
592+
expect(refused.valid).toBe(false);
593+
expect(refused.results[0]?.droppedFields).toBeUndefined();
594+
const refusal = refused.results[0]?.errors[0];
595+
expect(refusal?.field).toBe('organization_id');
596+
expect(refusal?.code).toBe('PERMISSION_DENIED');
597+
598+
const refusedWrite = await repoint(b, INJECTED, FOREIGN_ORG, GROUP_CTX, 'id');
599+
expectWallRefusal(refusedWrite.outcome, INJECTED);
600+
expect(refusal?.message).toBe(refusedWrite.outcome.message);
601+
expect(await b.table(INJECTED)).toEqual(SEEDED(INJECTED));
602+
590603
const write = await repoint(b, INJECTED, SISTER_ORG, GROUP_CTX, 'id');
591604
expect(write.outcome.ok, write.outcome.message).toBe(true);
605+
expect(write.dropped).toEqual([]);
592606
expect(await b.table(INJECTED)).toEqual(SEEDED(INJECTED, SISTER_ORG));
593607
});
594608
});

0 commit comments

Comments
 (0)